Posted By:
eric_martin
Posted On:
Friday, November 19, 2004 10:47 AM
I have an Java application using log4j for logging. I want to have 2 log files, one for only errors and the other for everything. I was hoping that I could control this in the log4j.properties file, but I haven't been able to get it working. Can someone please modify what I have below to make this work... # # Log for Java configuration don't change unless you know what you doing # The possible values here are debug, info, warn, error, fatal # These are in order of precedence. For example, if you put "warn", only the "warn", "error", & # "fatal" errors will log. If you put "error", only the "error" & "fatal" errors will lo
More>>
I have an Java application using log4j for logging. I want to have 2 log files, one for only errors and the other for everything. I was hoping that I could control this in the log4j.properties file, but I haven't been able to get it working. Can someone please modify what I have below to make this work...
#
# Log for Java configuration don't change unless you know what you doing
# The possible values here are debug, info, warn, error, fatal
# These are in order of precedence. For example, if you put "warn", only the "warn", "error", &
# "fatal" errors will log. If you put "error", only the "error" & "fatal" errors will log.
#
log4j.rootLogger=ERROR, AFile, EFile
#
# Controls the level of messages that will go the the AttachmentLoaderLog.
# Comment these lines out to prevent anything from logging to this file,
# or change the level as needed.
#
log4j.logger.com.eds.hcg.caxix.mcds.attachmentloader.Main=DEBUG,AFile
log4j.logger.com.eds.hcg.caxix.mcds.attachmentloader.ALFtp=DEBUG,AFile
log4j.logger.com.eds.hcg.caxix.mcds.attachmentloader.ALNoop=DEBUG,AFile
log4j.logger.com.eds.hcg.caxix.mcds.attachmentloader.ALProcessor=DEBUG,AFile
#
# Controls the level of messages that will go to the AttachementLoaderErrorLog
# Comment these lines out to prevent anything from logging to this file (not recommended),
# or change the level as needed.
#
log4j.logger.com.eds.hcg.caxix.mcds.attachmentloader.Main=ERROR,EFile
log4j.logger.com.eds.hcg.caxix.mcds.attachmentloader.ALFtp=ERROR,EFile
log4j.logger.com.eds.hcg.caxix.mcds.attachmentloader.ALNoop=ERROR,EFile
log4j.logger.com.eds.hcg.caxix.mcds.attachmentloader.ALProcessor=ERROR,EFile
log4j.appender.AFile=org.apache.log4j.RollingFileAppender
log4j.appender.EFile=org.apache.log4j.RollingFileAppender
#
# This is the file that becomes the log file. Older log files are renamed as fileName1 fileName2 etc.
#
log4j.appender.AFile.File=log/AttachmentLoaderLog
log4j.appender.EFile.File=log/AttachmentLoaderErrorLog
#
# The maximum size of the log file, good idea to keep the size small.
#
log4j.appender.AFile.MaxFileSize=5000KB
log4j.appender.EFile.MaxFileSize=5000KB
#
# This defines the no of log files to keep. Since this is a rolling file system, after the number of
# files reaches this number, the oldest file is rewritten
#
log4j.appender.AFile.MaxBackupIndex=10
log4j.appender.EFile.MaxBackupIndex=10
#
# Layout
#
log4j.appender.AFile.layout=org.apache.log4j.PatternLayout
log4j.appender.EFile.layout=org.apache.log4j.PatternLayout
#
# This defines the way comments are written to the log file, for e.g. %d tells the logger to write the date
# for a full list see the log4j manual. %p is the priority (debug, info etc as defined above)
#
#log4j.appender.AFile.layout.ConversionPattern=%p %t %c - %m %n
#log4j.appender.AFile.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss} | %p | %m%n
log4j.appender.AFile.layout.ConversionPattern=[%d{DATE}] [%t] %-5p %c %n %m%n%n
log4j.appender.EFile.layout.ConversionPattern=[%d{DATE}] [%t] %-5p %c %n %m%n%n
Thanks!
<<Less