Log4j FileAppender not logging to file

This happens often when you don’t give the absolute path in log4j config file. For example, I gave the path as this log4j.appender.fileout.File=${webapp.root}/WEB-INF/log4j.log . And log4j was creating a file in d:/tomcat/webapps/myapp/WEB-INF/ but the file was empty even though I could see the logs in the console. Then after pulling some hair, I found there was directory created at “d:/WEB-INF” which had a log4j.log file and log4j was logging to this file. I had this issue with tomcat 6.0.18. After setting the absolute path, I was able to see the logs where I wanted them to go.