private void initializeLogging ( ) { // Since logging is static, make sure this is done only once even if // multiple clients are created (e.g., during tests) if ( consoleAppender != null ) { return ; } consoleAppender = new ConsoleAppender ( ) ; consoleAppender . setLayout ( new PatternLayout ( LOG_PATTERN ) ) ; consoleAppender . setThreshold ( Level . INFO ) ; LevelRangeFilter filter = new LevelRangeFilter ( ) ; filter . setLevelMin ( Level . TRACE ) ; filter . setLevelMax ( Level . INFO ) ; consoleAppender . addFilter ( filter ) ; consoleAppender . activateOptions ( ) ; org . apache . log4j . Logger . getRootLogger ( ) . addAppender ( consoleAppender ) ; errorAppender = new ConsoleAppender ( ) ; errorAppender . setLayout ( new PatternLayout ( LOG_PATTERN ) ) ; errorAppender . setThreshold ( Level . WARN ) ; errorAppender . setTarget ( ConsoleAppender . SYSTEM_ERR ) ; errorAppender . activateOptions ( ) ; org . apache . log4j . Logger . getRootLogger ( ) . addAppender ( errorAppender ) ; }
Sets up Log4J to write log messages to the console . Low - priority messages are logged to stdout while high - priority messages go to stderr .