• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

log4j - configureAndWatch on JBoss+Tomcat

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's what I would like to have using log4j :

I would like to have 2 appenders: RollingFileAppender, ConsoleAppender.
It should work on JBoss and Tomcat at least.
If log4j.properties is modified, the new settings should be picked up dynamically.


Here's what my log4j.properties file looks like:
log4j.logger.com.pocolap=DEBUG
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.category.com.pocolap=, R
log4j.appender.R.layout.ConversionPattern=[%d] %p %x - %m%n
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.File=C\:\\pocolapDB\\pocolaplog.txt
log4j.appender.R.MaxFileSize=100KB
log4j.appender.R.layout=org.apache.log4j.PatternLayout


This how my init code looks like:

My problem is when the app is deployed on Tomcat and I modify log4j.properties. It is watching the directory but It ends up having zero appenders 'log4j:WARN No appenders found for logger'.
How can I have atleast the RollingFileAppender (if not ConsoleAppender) ?

Any help really apreciated.
TIA,
Regards,
Rashmi
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These two lines conflict. logger is the new term for the old term category. So, they are both trying to configure the logger/category for com.pocolap.
The logger one probably wins, and it doesnt' have an appender associated with it:

log4j.logger.com.pocolap=DEBUG
log4j.category.com.pocolap=, R

Not sure why you're configuring the console appender in code and not in the properties file.
 
Rashmi Banthia
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for your reply. It worked as expected. I am configuring ConsoleAppender manually and not in properties file, because JBoss already has ConsoleAppender configured. So it conflicts and I get an error 'Console Stream is looping'.
If you have any better suggestion to make ConsoleAppender work on JBoss as well as Tomcat. Please let me know.

Thanks once again,
Regards,
Rashmi
 
Carol Enderlin
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't use JBoss, so I don't know the issues involved. Are you trying to see the JBoss logging or some of your own logging that is going only to the root logger?

Quick google shows some people say configuring console appender with JBoss is pretty tricky. Others say to modify JBoss's log4j.xml in the directory $jboss/server/default/conf. Since you're using the properties format I assume you're creating a separate config file.
 
Rashmi Banthia
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I figured this out. This is what my log4j looks like:



This gives logger messages once on Tomcat and twice on JBoss console. Because JBoss already has a ConsoleAppender configured. I'll live with this for now. (Also no more manual configuring ConsoleAppender in the code)

Thanks!
Rashmi
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic