Log4j not appending file extension

2019-09-10 09:39发布

问题:

I've set my log4j.properties file to this configuration below

log4j.rootLogger=INFO, CATALINA

# Define all the appenders
log4j.appender.CATALINA=org.apache.log4j.DailyRollingFileAppender
log4j.appender.CATALINA.File=${catalina.base}/logs/catalina.
log4j.appender.CATALINA.Append=true
log4j.appender.CATALINA.Encoding=UTF-8
# Roll-over the log once per day
log4j.appender.CATALINA.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.CATALINA.layout = org.apache.log4j.PatternLayout
log4j.appender.CATALINA.layout.ConversionPattern = %d [%t] %-5p %c- %m%n

The issue is when creating my logs (I'm using OS x Lion and Tomcat 6.0.32), the logs are created without the extension, just a final dot.

However, if I use this same configuration in a Windows box, it does the work OK.

回答1:

log4j.appender.CATALINA.File=${catalina.base}/logs/catalina.

needs to be:

log4j.appender.CATALINA.File=${catalina.base}/logs/catalina.log