Sunday, August 23, 2009

Log4j

Am I wrong? I hope so. Log4j enables the logging to different appenders. But I wanna have is a logger to do an INFO logging to logger the CONSOLE, and a DEBUG logging a FILE.
What I get is a logging to both systems without the necessary differentiation.
The log4j property file:

# Sets root logger level to INFO
# Sets its appender to CONSOLE.
log4j.rootLogger=INFO, CONSOLE
# Sets my own logger
log4j.logger.STOCK=DEBUG, STOCK

# Sets the appender to CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
# Sets the appender for STOCK to FileAppender
log4j.appender.STOCK=org.apache.log4j.FileAppender
log4j.appender.STOCK.File=/usr/home/props/logs/StockLogger.log

# CONSOLE uses PatternLayout.
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%m%n
# STOCK uses PatterLayout
log4j.appender.STOCK.layout=org.apache.log4j.PatternLayout
log4j.appender.STOCK.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

# Print only message for the following packages
log4j.logger.StockCurrentPrice=INFO,CONSOLE,STOCK
log4j.additivity.StockCurrentPrice=false

Any ideas?

No comments: