Reputation: 19320
I'm using Java 6 on Win XP and log4j 1.2.12. I'm having trouble getting my logs output to a file (no log4j.log appears). Below is my log4j.properties config, which appears in my war's WEB-INF/classes directory ...
log4j.rootLogger=DEBUG, A2
log4j.appender.A1 = org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout = org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n
log4j.appender.A2 = org.apache.log4j.DailyRollingFileAppender
log4j.appender.A2.File = c:\apache-tomcat-6.0.33\logs\log4j.log
log4j.appender.A2.Append = true
log4j.appender.A2.DatePattern = '.'yyy-MM-dd
log4j.appender.A2.layout = org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n
And here's how I access the logger in my class ...
public class XMLNode {
private static Logger logger = Logger.getLogger(XMLNode.class);
...
logger.debug("test:" + main.toString());
Any other ideas what else I should do or check to get my log4j.properties file to appear? Thanks, - Dave
Upvotes: 1
Views: 1231
Reputation: 7737
Your problem appears to be with the format of the file name.
log4j.appender.A2.File = c:\apache-tomcat-6.0.33\logs\log4j.log
You will need to change the file path to use either forward slashes (/
) or double back slashes (\\
)
log4j.appender.A2.File = c:/apache-tomcat-6.0.33/logs/log4j.log
I ran your example above, and when I changed the file path it worked fine.
Upvotes: 2
Reputation:
use direct LOGGER.info(String-Message).. hope so you will get the log file.. i think your log file is present but you are not searching it at right place.. find it in
Upvotes: 0