Log4j with tomcat integration

I'm having a problem using log4j with integrated tomcat. When I run tomcat within IDEA even though it's correctly copying my log4j.properties file to the compile directory prior to starting tomcat log4j doesn't seen to initialize itself nor does it start appending to my log file that I specified in my log4j.properties file.

It's also definitely copying my log4j-1.2.8.jar file and my commons-logging-1.0.2.jar file to the WEB-INF/lib directory. My log4j.properties file is also being copied to WEB-INF/classes. But still, no logging statements show up in the console in IDEA nor do any statements get appended to my log file.

I'm using JDK 1.5, IDEA 5.0.2 on a Mac, Tomcat 5.5.12. When I compile and run my web app outside of IDEA it works fine with tomcat and the logging does work as expected.

Any help would be appreciated.

Thanks,
Christian

3 comments
Comment actions Permalink

Is your log4j.properties file in the /WEB-INF/classes directory?

What I have found (I am using version 6.0) is that the log4j.properties needs to be physically moved to the /WEB-INF/classes directory.

However, then the file doesn't show-up in the Project Tree within Project pane in IntelliJ - but Tomcat will start-up with the log4j.properties file.

If the log4j.properties is at just in the /WEB-INF directory - IntelliJ will see the file in the Project Tree within the Project pane - but Tomcat will not start-up with the log4j.properties file.

Fun, eh?

I haven't figured out if I can set a single file to be moved at build time or not. I may need to customize my Ant build file...

Thanks,

0
Comment actions Permalink

Hello Todd,

If log4j.properties is located under a source root it will be copied to /WEB-INF/classes
directory (make sure that "*.properties" pattern is included in Settings
| Compiler | Resource Patterns).

Is your log4j.properties file in the /WEB-INF/classes directory?

What I have found (I am using version 6.0) is that the
log4j.properties needs to be physically moved to the /WEB-INF/classes
directory.

However, then the file doesn't show-up in the Project Tree within
Project pane in IntelliJ - but Tomcat will start-up with the
log4j.properties file.

If the log4j.properties is at just in the /WEB-INF directory -
IntelliJ will see the file in the Project Tree within the Project pane
- but Tomcat will not start-up with the log4j.properties file.

Fun, eh?

I haven't figured out if I can set a single file to be moved at build
time or not. I may need to customize my Ant build file...

Thanks,



0
Comment actions Permalink

Nikolay: Thank you.

This has been tested and confirmed.

Sincerely,

0

Please sign in to leave a comment.