Sunday, August 30, 2015

Configure log4j properties file for logging both in file system and console



# Root logger option
log4j.rootLogger= DEBUG,errorLogger,stdout,



# Direct log messages to a log file
log4j.appender.errorLogger=org.apache.log4j.RollingFileAppender
log4j.appender.errorLogger.Threshold = ERROR
log4j.appender.errorLogger.File=.\\Log\\logging.log
log4j.appender.errorLogger.MaxFileSize=1MB
log4j.appender.errorLogger.MaxBackupIndex=1
log4j.appender.errorLogger.layout=org.apache.log4j.PatternLayout
log4j.appender.errorLogger.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n






The above configuration will write only error log to file system and all the other log in console.
log4j.appender.errorLogger.Threshold = ERROR   does the trick.

5 Strategies for Getting More Work Done in Less Time

Summary.    You’ve got more to do than could possibly get done with your current work style. You’ve prioritized. You’ve planned. You’ve dele...