What I want to do is very simple, but I cannot get it to work with log4j.
I need 2 log files. The first should contain all debug statements of debug level or higher, but only from classes in my.app. *
The second log file should contain all warning messages of a level and higher, regardless of the source class.
I tried the following configuration, but it does not work:
log4j.rootLogger=warn,root log4j.appender.root=org.apache.log4j.FileAppender log4j.appender.root.layout = org.apache.log4j.PatternLayout log4j.appender.root.layout.conversionPattern = %d [%t] %-5p %c - %m%n log4j.appender.root.file = /tmp/logs/warn.file log4j.appender.root.append = true log4j.appender.root.MaxFileSize=10MB log4j.appender.root.MaxBackupIndex=7 log4j.logger.my.app=debug,debugAppender log4j.appender.debugAppender = org.apache.log4j.RollingFileAppender log4j.appender.debugAppender.file = /tmp/logs/my.debug.file log4j.appender.debugAppender.layout = org.apache.log4j.PatternLayout log4j.appender.debugAppender.layout.conversionPattern = %d [%t] %-5p %c - %m%n log4j.appender.debugAppender.append = true log4j.appender.debugAppender.MaxFileSize=10MB log4j.appender.debugAppender.MaxBackupIndex=7 log4j.additivity.my.app=false
I think the problem is with the last line. If I set additivity to true, debug messages and level information will also be added to my warn.file. But if I set it to false, warnings from my.app only get logged in debug.file.
source share