• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Getting Spring's FINE logging

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On Tomcat, I am trying to get the logging output from the Spring libraries that I am using on my project.

My problem is that I am not getting the FINE logging from Spring. However, for other libraries such as JSF, I do get the FINE logging. What am I doing wrong?

I have noticed that when I remove log4j.jar from the classpath, I do get logging from Spring. But when I add log4j.jar to the classpath, the logging from Spring is gone. Can you explain why?

BTW I do need log4j and commons-logging(JCL) in my classpath, since some of the other jars I am using, refer to log4j and JCL explicitly in their code.


Here are the settings I am using, in Tomcat's conf/logging.properties:

 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, log4J needs to be in the classpath (usually WEN-INF/lib).

Do any changes in the properties file take effect?
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Bear Bibeault: Why does log4j need to be in the classpath? AS far as I know, Spring uses Commons logging (JCL), so if there's no log4j on the classpath, it will use the JDK logging API (java.util.logging).

As I said, when I remove log4j from the classpath, the logging for some of the jars works (e.g. JSF jars), for others it doesn't (e.g. Spring jars). I wonder why. Any ideas?

Also, I am using log4j.xml to config log4j.

Changes to the conf/logging.properties do take effect. I am expecting to get the logging at the file ${catalina.home}/logs/catalina.log

Here is my conf/logging.properties:



My log4j.xml:

 
Bear Bibeault
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because you said that one of your jars references log4j. If it's not on the classpath, you'll likely end up with a ClassNotFound exception.

BTW I do need log4j in my classpath, since one of the other jars I am using, refers to log4j explicitly in its code.



As to why Spring logging ceases to work with Log4J present, I can only assume that Spring uses Log4J if it is present, and reverts to Java logging otherwise (lots of stuff does this). And you likely have no Log4J config for Spring, so no logging.

But that's just a guess. Maybe you'd prefer this be moved to the Spring forum where the Spring-savvy hang out?
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Bear Bibeault: I see, I thought you were trying to say that each time I need some jar to output its logging through Tomcat, I need log4j to be on the classpath.

I was actually wondering too which forum should be the best for posting this. So yes, if you think it has more to do with Spring, please move this thread to there. Thank you for this and for your answers!
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This might help http://blog.springsource.org/2009/12/04/logging-dependencies-in-spring/
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I too faced similar logging issues but able to resolve it by setting system parameter as -Dlog4j.configuration=log4j.properties and adding log4j.properties in the classpath.
Here is my log4j property file for reference.


 
I guess everyone has an angle. Fine, what do you want? Just know that you cannot have this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic