Tomcat Cannot Find log4j.properties file

J

John

I am trying to install log4j into an existing web app. However, when I
debug it seem that the ligger is using ConsoleAppender instead of
RollingFileAppender.

I am guessing that it is not finding the log4j.properties file.

Any ideas?

-----
log4j.properties:

# Sample properties to initialize log4j
log4j.rootCategory=debug, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=./regreporting.log
log4j.appender.R.MaxFileSize=100KB
log4j.appender.R.MaxBackupIndex=2
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %d %c - %m%n


---
java file:

import org.apache.log4j.Logger;

public class RegRptTaskSpecInitAction extends Action {

private static Logger logger =
Logger.getLogger(RegRptTaskSpecInitAction.class.getName());

......
public void getValue(){
logger.debug("*****TEST THIS TODAY");
}
}
 
J

Juha Laiho

(e-mail address removed) (John) said:
I am trying to install log4j into an existing web app. However, when I
debug it seem that the ligger is using ConsoleAppender instead of
RollingFileAppender.

I am guessing that it is not finding the log4j.properties file.

If you can, restart Tomcat so that the system property log4j.debug is set
to true. This will cause log4j to emit internal logging information into
Tomcats logs.
 
A

Andrea Spinelli

(e-mail address removed) (John) wrote in @posting.google.com:
I am trying to install log4j into an existing web app. However, when I
debug it seem that the ligger is using ConsoleAppender instead of
RollingFileAppender.

I am guessing that it is not finding the log4j.properties file.

Sorry if this is too stupid, but where have you put the log4j.properties?

The most common solution is in <your-app>/WEB-INF/classes/

The documentation state that it is easy and works, and
I confirm this statement.

Other choices are possible, but less common.

Moreover, you miss the log4.rootLogger:
# Sample properties to initialize log4j
log4j.rootCategory=debug, R
should be, AFAIK,

log4j.rootLogger=DEBUG, R

(maybe yous is good, but i can swear only about mine!)

My two cents...
 
J

Josh

It may be the ./ you're using to locate the file. The present
directory may not be where you're assuming it is. Instead, I'd use a
full path. As an FYI, you can also use system variables:

log4j.appender.R.File=${catalina.home}/webapps/yourapp/dir/regreporting.log
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top