Perhaps the log4j.properties on this articles would help you seek what you are looking for. http://ta.cnci.org/more-about-java/35-java-blogs/238-dailyfileappender and may be you could use the DailyFileAppender.java that I wrote a while back.
The idea is simple and it is in 4 parts:
- Set the log4j.rootCategory to include your "FILE DEF"
- Define your "FILE DEF" such as log4j.appender.SOADAILY
- Tell the Logger to filter it to your "FILE DEF" as: log4j.logger.com.incresearch.soa.db=DEBUG, TDLDAILY
- Tell the Logger not delete from everywhere else as: log4j.additivity.org.cnci.tdl=false
But here is an example:
#------------------------------------------------------------------------------
# Default log4j.properties file. This should be in the LocalFiles folder
#
# Possible Log Levels:
# FATAL, ERROR, WARN, INFO, DEBUG
#
log4j.rootCategory=DEBUG, SOADAILY, TDLDAILY
log4j.logger.org.apache=ERROR
#------------------------------------------------------------------------------
# The following properties configure the Daily Rolling File appender.
# For SOA components, mostly from org.cnci.soa.* packages
#------------------------------------------------------------------------------
log4j.appender.SOADAILY = org.cnci.util.DailyFileAppender
log4j.appender.SOADAILY.File = logs/SOAServices.log
log4j.appender.SOADAILY.MaxLogs = 30
log4j.appender.SOADAILY.Append = true
log4j.appender.SOADAILY.DatePattern = '.'yyy-MM-dd
log4j.appender.SOADAILY.layout = org.apache.log4j.PatternLayout
log4j.appender.SOADAILY.layout.ConversionPattern = %d %5p %c{1}:%L - %m%n
#------------------------------------------------------------------------------
# The following properties configure the Daily Rolling File appender for TDL.
# For TDL applications, mostly from org.cnci.tdl.* packages and jboss seams, richfaces...
#------------------------------------------------------------------------------
log4j.appender.TDLDAILY = org.apache.log4j.FileAppender
log4j.appender.TDLDAILY.File = logs/TDLServices.log
log4j.appender.TDLDAILY.MaxLogs = 30
log4j.appender.TDLDAILY.Append = true
log4j.appender.TDLDAILY.DatePattern = '.'yyy-MM-dd
log4j.appender.TDLDAILY.layout = org.apache.log4j.PatternLayout
log4j.appender.TDLDAILY.layout.ConversionPattern = %d %5p %c{1}:%L - %m%n
# Extracting all Adapter logging into it own file
log4j.logger.org.cnci.soa=DEBUG, SOADAILY
log4j.additivity.org.cnci.soa=false
log4j.logger.com.hazelcast=ERROR, SOADAILY
log4j.additivity.com.hazelcast=false
log4j.logger.org.opensaml=ERROR, SOADAILY
log4j.additivity.org.opensaml=false
# Extracting all DB (TDL) logging into it own file
log4j.logger.com.incresearch.soa.db=DEBUG, TDLDAILY
log4j.additivity.org.cnci.tdl=false
log4j.logger.org.jboss.seam=ERROR, DAILY
log4j.additivity.org.jboss.seam=false
log4j.logger.org.richfaces=ERROR, DAILY
log4j.additivity.org.richfaces=false
log4j.logger.org.ajax4jsf=ERROR, DAILY
log4j.additivity.org.ajax4jsf=false
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…