Logging output with Tomcat...?

Hello all:

I apologize if this topic has been covered before, I've looked around for a solution and can't seem to find one. Guess I'm having one of those days.

I'm using IDEA 7.0.2 with Tomcat 6 and Log4j wrapped by commons logging. My log4j file is being properly copied to WEB-INF/classes and it appears that Spring finds it correctly. However, none of my log statements are being printed to the IDEA console or the file I've specified. I've attached my log4j.properties file if that would help. Any insight is appreciated.

TIA,
Carl



Attachment(s):
log4j.properties
4 comments

You can watch (tail) your log file by setting:
Run/Debug Configuration
Tomcat Server
your configuration
Logs
Add

However if nothing is printed to this file, you won't see anything.
Probably your log4j.properties is not setup correctly... but it's a
log4j topic.

TomP

0

Thanks for your reply. Unfortunately the change you suggested does nothing. I see the standard tomcat output for the server itself, along with the Hibernate SQL statements, but that is it. Nothing else is appended to the logs.

Any other suggestions?

Thanks.

0

In the run configuration, add a VM parameter defined like so:

-Dlog4j.configuration=file:///path.to.your.configuration

Its important to note that the value for this property needs to be a file URL, not merely a path, so the "file:///" part needs to be present.

This VM parameter is used by log4j to locate the log4j configuration -- it overrides any log4j.properties you may have in your classpath (like WEB-INF/classes/log4j.properties). Because it is a JVM parameter, it isn't unique to Tomcat, so you may also add the same parameter to other run configurations. For example, my Junit configuration also includes this parameter.

This log4j feature isn't very well documented, so I hope this helps. Holler if you need further instruction.

One more thing for extra credit. Personally I hate how Hibernate prints things to standard output, and prefer to channel its SQL statements through log4j. To do so, these are the loggers you need to define:

log4j.logger.org.hibernate.SQL
log4j.logger.org.hibernate.type

Setting the first to DEBUG will provide those SQL statements to log4j. Setting the latter to TRACE will instruct Hibernate to also log the parameter values for the SQL statements. Note that this is independent of the "show sql" configuration property of hibernate.

0

Thanks to everyone who posted a response. Turns out the error was my own. I'm using ivy for dependency management and had marked the commons-logging-api JAR for inclusion but neglected to include the impl JARs. Like I said in my original post, I guess I'm having one of those days.

0

Please sign in to leave a comment.