Hi,
Is there a way to do this? I have a class in a shared package in which I want to log into a separate log file.
I'm using the text configuration file - not the xml one.
I tried this (a suggestion from google):
log4j.rootLogger = ERROR, WebLog
log4j.category.se.aftonbladet.elitserien=ERROR
log4j.category.org.apache.struts2=ERROR
log4j.category.org.apache=ERROR
log4j.category.catalia=ERROR
# An extra category to a log file
log4j.category.AlternativeLog=A3
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Threshold = DEBUG
log4j.appender.stdout.Target = System.out
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = %d{ISO8601} %-5p [%F:%L] : %m%n
log4j.appender.WebLog = org.apache.log4j.RollingFileAppender
log4j.appender.WebLog.file = /opt/tomcat/logs/elitserienservice.log
log4j.appender.WebLog.MaxFileSize=2048KB
log4j.appender.WebLog.MaxBackupIndex = 5
log4j.appender.WebLog.layout = org.apache.log4j.PatternLayout
log4j.appender.WebLog.layout.ConversionPattern = %d{ISO8601} %-5p [%F:%L] : %m%n
# A3 is set to be a FileAppender which will log all actions in the application.
log4j.appender.A3=org.apache.log4j.RollingFileAppender
log4j.appender.A3.file=/opt/tomcat/logs/elitserienservice_alt.log
log4j.appender.A3.MaxFileSize=2048KB
log4j.appender.A3.MaxBackupIndex = 5
log4j.appender.A3.layout=org.apache.log4j.PatternLayout
log4j.appender.A3.layout.ConversionPattern=%d{ISO8601} %-5p [%F:%L] : %m%n
And in my class I get my logger like this:
private static final Logger logger = Logger.getLogger("AlternativeLog");
But it doesnt work. All logging still ends up in the 'elitserienservice.log'.
Any help much appreciated!
/best regards, HÃ¥kan Jacobsson