Last active
August 6, 2018 18:17
-
-
Save AshwinJay/5510965 to your computer and use it in GitHub Desktop.
Log4J settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BasicConfigurator.configure(); | |
org.apache.log4j.Logger.getRootLogger().setLevel(Level.INFO); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); | |
loggerContext.reset(); | |
PatternLayoutEncoder ple = new PatternLayoutEncoder(); | |
ple.setPattern("%msg%n"); | |
ple.setContext(loggerContext); | |
ple.start(); | |
ConsoleAppender console = new ConsoleAppender(); | |
console.setEncoder(ple); | |
console.setContext(loggerContext); | |
console.start(); | |
Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); | |
rootLogger.setLevel(Level.INFO); | |
rootLogger.addAppender(console); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Before Jetty starts: | |
org.eclipse.jetty.util.log.Log.setLog(new org.eclipse.jetty.util.log.Slf4jLog()); | |
Classpath: | |
lib/log4j2/2.0-beta4/log4j-api-2.0-beta4.jar | |
lib/log4j2/2.0-beta4/log4j-core-2.0-beta4.jar | |
lib/log4j2/2.0-beta4/log4j-slf4j-impl-2.0-beta4.jar | |
lib/slf4j/1.7.5/slf4j-api-1.7.5.jar | |
lib/slf4j/1.7.5/slf4j-ext-1.7.5.jar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Programmatic logger configuration > xml-based logger configuration. If you use XML, you're giving the middle finger to the Java compiler which is there to HELP you.