I posted a question yesterday in the Other Open Source forum but didn't get any responses, so I'm reposting here with additional information because this now appears to be a
Tomcat issue rather than a log4j issue. I don't like to post in more than one forum, but replying to myself in the other forum doesn't seem productive, especially since I think I've pretty well determined that this is a Tomcat configuration issue. This is for application logging, not Tomcat logging. For
testing, I've created a simple project with a
servlet like so:
Here is the log4j.properties file which is located in the applications WEB-INF/classes directory.
The console appender is working as those messages appear in catalina.out, but the file for the file appender is never getting created. The only clue I've been able to find after a lot of searching indicates that I may need to add an entry to the catalina.policy file in order to allow the application to create the log file, but in all the guides to log4j that I've read, that is the only place where this issue of policies has been mentioned. Could that be the problem? If so, could someone expand a bit on how to modify that policy file? I'm not at all familiar with Tomcat security and this policy file.
I should also mention that this app DOES log to the file when I run it on my local test server (with the path changed accordingly), which is Tomcat running on Windows. The failure occurs when it's deployed to the RedHat server.
Any tips are appreciated. I'm now into my second day of trying to get log4j working and I'm getting a little frustrated. In the meantime, I'm going to try creating the log file manually and see if it gets appended to, and I'll do some more reading about this catalina.policy file to see if I can understand how it works.