Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 21st, 2006, 09:21 AM
Pompiuses Pompiuses is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Oslo
Posts: 105 Pompiuses User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 49 m 53 sec
Reputation Power: 7
Log4j and Tomcat problem

I'm using Tomcat 5.0.30 running on Ubuntu Linux (6.06).

I've made a small webapp which runs fine under Tomcat on Windows, but on Linux I've got a problem with log4j.

I've put "commons-logging-1.1.jar" and "log4j-1.2.13.jar" in the webapps libs directory. In the classes directory I've put log4j.properties which point to the log file: /var/log/ne/ne.log

The problem is that the webapp won't even run as log as the log4j.properties is in the class path. If I remove log4j.properties from the classes directory the application will run, but there's no logging.

This looks like a Tomcat problem, since the webapp runs fine on windows. There's also no error messages in any of the files in /var/log/tomcat5/

What's wrong?

My log4j.properties look like this:

# The log4j configuration file.

log4j.rootCategory=DEBUG, FileApp

# FileApp
log4j.appender.FileApp=org.apache.log4j.RollingFileAppender

# File appender
log4j.appender.FileApp.File=/var/log/ne/ne.log

# Max filesize before creating new log file.
log4j.appender.FileApp.MaxFileSize=10MB

# How many backup files to keep
log4j.appender.FileApp.MaxBackupIndex=10

# Log layout
log4j.appender.FileApp.layout=org.apache.log4j.PatternLayout
log4j.appender.FileApp.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-35.35F | %25M() | %-4L | %m%n

Reply With Quote
  #2  
Old August 21st, 2006, 11:10 AM
stdunbar stdunbar is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: May 2004
Location: Superior, CO, USA
Posts: 1,740 stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level)stdunbar User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 3 Days 1 h 59 m 26 sec
Reputation Power: 381
Send a message via ICQ to stdunbar Send a message via Yahoo to stdunbar
I'm not sure what is wrong as that is very similar to my configuration. I'd make sure that the user who runs Tomcat has permission to write to the log file. Additionally you might want to set the environment variable CATALINA_OPTS to -Dlog4j.debug and then restart Tomcat. This will printout what log4j thinks it is doing to stdout (System.out).
__________________
Need Java help? Want to help people who do? Sit down with a cup of Java at the hotjoe forums.

Reply With Quote
  #3  
Old August 22nd, 2006, 03:42 AM
Pompiuses Pompiuses is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Oslo
Posts: 105 Pompiuses User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 49 m 53 sec
Reputation Power: 7
Quote:
Originally Posted by stdunbar
I'm not sure what is wrong as that is very similar to my configuration. I'd make sure that the user who runs Tomcat has permission to write to the log file. Additionally you might want to set the environment variable CATALINA_OPTS to -Dlog4j.debug and then restart Tomcat. This will printout what log4j thinks it is doing to stdout (System.out).


I've changed permission so that everyone can do everything with the log file and the directory it's in (/var/log/ne). Tomcat is also started with the root user.

I think this is a classpath issue, because when I remove "commons-logging-1.1.jar" from the webapp's classpath (WEB-INF/lib) it will run fine but without logging.

I see that in CATALINA_HOME/bin (which I assume is Tomcats class path?) there's a file called "commons-logging-api.jar". I don't know if I can safely remove that file without breaking something else?

I've not added the log4j.jar to CATALINA_HOME/common/lib since it's in the webapp's class path.

I'll try to add log4j.DEBUG=true to the log4j.properties as it will also force log4j to print debug info to stdout.

Reply With Quote
  #4  
Old August 22nd, 2006, 09:29 AM
Pompiuses Pompiuses is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Oslo
Posts: 105 Pompiuses User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 49 m 53 sec
Reputation Power: 7
I give up.... I've tried everything without getting log4j to work.

If I remove both log4j.jar and commons-logging.jar from the webapp classpath (WEB_INF/lib) I don't get any errors, so it looks like they're already included in tomcats classpath.

I've tried changing the log4j.properties to write to system.out (/var/log/tomcat5/catalina.out) without luck:

# The log4j configuration file.
log4j.rootLogger=debug, R
log4j.appender.R=org.apache.log4j.ConsoleAppender
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%-5p %-30.30c{1} %x - %m%n


Then I tried putting log4j.properties in $CATALINA_HOME/shared/classes and $CATALINA_HOME/common/classes, but it still would'nt log anything.

I'm almost starting to cry now..... I hope someone can chime in because I really have run out of ideas.

I tried adding CATALINA_OPTS to the environment, but there was nothing printed to system.out (/var/log/tomcat5/catalina.out).

How can I test if log4j.properties really is in the classpath? Perhaps that's what's wrong...

Reply With Quote
  #5  
Old August 24th, 2006, 05:48 AM
Pompiuses Pompiuses is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Oslo
Posts: 105 Pompiuses User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 49 m 53 sec
Reputation Power: 7
Found a solution:
I had installed Tomcat through the Ubuntu Synaptic Package manager. It would seem this was not a healthy install, because I just uninstalled it and installed Tomcat 5.5 manually and everything worked perfectly. What the problem was I never figured out since the install was scattered all over the hard drive.

The only thing that bothers me now is that if I open up /var/log/ne/ne.log in a text editor, say vi, and edit it, log4j will stop logging to the file. I have to restart the webapp to make it start logging again. Anyone know what might cause that?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Log4j and Tomcat problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT