I'm working on a set of web services and we'd like to have a daily rotated log.
I'm trying to get org.apache.log4j.rolling.RollingFileAppender
from the log4j extras companion working, since the documentation suggests this is best for production environments.
I have both the main log4J library (log4j-1.2.15.jar
) and the log4j extras library (apache-log4j-extras-1.1.jar
) on the classpath.
I have the following configuration for the appender in the log4j.properties
file:
### SOAP Request Appender
log4j.appender.request=org.apache.log4j.rolling.RollingFileAppender
log4j.appender.request.File=SOAPmessages.log
log4j.appender.request.RollingPolicy=org.apache.log4j.rolling.TimeBasedRollingPolicy
log4j.appender.request.RollingPolicy.ActiveFileName =SOAPmessages-%d.log
log4j.appender.request.RollingPolicy.FileNamePattern=SOAPmessages-%d.log.zip
log4j.appender.request.layout = org.apache.log4j.PatternLayout
log4j.appender.request.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
However, when I start the web service with log4j in debug mode I get these error messages:
log4j: Parsing appender named "request".
log4j: Parsing layout options for "request".
log4j: Setting property [conversionPattern] to [%d{ABSOLUTE} %5p %c{1}:%L - %m%n].
log4j: End of parsing for "request".
log4j: Setting property [file] to [/logs/SOAPmessages.log].
log4j:WARN Failed to set property [rollingPolicy] to value "org.apache.log4j.rolling.TimeBasedRollingPolicy".
log4j:WARN Please set a rolling policy for the RollingFileAppender named 'request'
log4j: Parsed "request" options.
I've found documentation about how to configure this appender a little sparse, so can anyone help me fix my configuration?
EDIT0: Added debug mode output, rather than just the standard warnings
Regarding error:
log4j:ERROR Element type "rollingPolicy" must be declared
log4j.dtd
definingrollingPolicy
.apache-log4j-extras-1.1.jar
I'm suspicious of the
ActiveFileName
property. According to the log4j javadoc, there isn't such a property on theTimeBasedRollingPolicy
class. (NosetActiveFileName
orgetActiveFileName
methods.)I don't know what specifying an unknown property would do, but it is possible that it will cause the containing object to be abandoned, and that could lead to the warnings that you saw.
Try leaving it out and seeing what happens.