我有两个类和两个 log4j.properties 文件:每个类都有一个文件。一切正常。现在我想将两个属性文件合并为一个。但我仍然希望每个类都有自己的日志文件。我怎么做?我做了以下但它不工作:类 Abc.java 日志很好,但 Xyz.java 不再记录到它自己的文件。请注意,Xyz.java 获取动态日志文件名。
log4j.appender.CONSOLE=org.apache. log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache. log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p %c{1} - %m%n
log4j.rootLogger=INFO, CONSOLE
log4j.appender.ABC_ERR_LOG=org.apache. log4j.RollingFileAppender
log4j.appender.ABC_ERR_LOG.File=/opt/mysite/var/log/allhere.error.log
log4j.appender.ABC_ERR_LOG.MaxFileSize=4MB
log4j.appender.ABC_ERR_LOG.MaxBackupIndex=3
log4j.appender.ABC_ERR_LOG.layout=org.apache. log4j.PatternLayout
log4j.appender.ABC_ERR_LOG.layout.ConversionPattern=%d %-5p %c{1} - %m%n
log4j.appender.ABC_ERR_LOG.Threshold = WARN
log4j.appender.ABC_LOG=org.apache. log4j.RollingFileAppender
log4j.appender.ABC_LOG.File=/opt/mysite/var/log/allhere.log
log4j.appender.ABC_LOG.MaxFileSize=8MB
log4j.appender.ABC_LOG.MaxBackupIndex=3
log4j.appender.ABC_LOG.layout=org.apache. log4j.PatternLayout
log4j.appender.ABC_LOG.layout.ConversionPattern=%d %-5p %c{1} - %m%n
log4j.appender.XYZ_LOG=org.apache. log4j.RollingFileAppender
log4j.appender.XYZ_LOG.File=/opt/mysite/var/log/job-${logfilename}.log
log4j.appender.XYZ_LOG.MaxFileSize=8MB
log4j.appender.XYZ_LOG.MaxBackupIndex=3
log4j.appender.XYZ_LOG.layout=org.apache. log4j.PatternLayout
log4j.appender.XYZ_LOG.layout.ConversionPattern=%d %-5p %c{1} - %m%n
log4j.logger.com.mysite=DEBUG, ABC_LOG, ABC_ERR_LOG, XYZ_LOG