private void initLog4J() {
        logger.setLevel(Level.INFO);
        
        Logger.getRootLogger().addAppender(new ConsoleAppender(new PatternLayout("%d %-5p [%c] - %m%n")));
        try {
            if(logfile != null)
                Logger.getRootLogger().addAppender(new FileAppender(new PatternLayout("%d %-5p [%c] - %m%n"), logfile));
        } catch (IOException e) {
            logger.error("Could not write log file", e);
        } catch (SecurityException e) {
            logger.debug("Could not create log file. Running in an applet.");
        }
    }