Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

log4j does not do anything in servlet!

Status
Not open for further replies.

developerinlondon

Programmer
Jan 11, 2003
196
GB
i am trying to install and use log4j, i am using netbeans to develop. however i can get log4j working fine with a plain java application, but from within a servlet it doesnt seem to do anything, nor does it show any messages, exceptions, errors etc. any ideas how i can find out whats going on? I spent a whole day yesterday looking at the net to see if there is a way but didnt seem to go far.
 
What does your config file for log4j look like, and where do you put it ?

--------------------------------------------------
Free Database Connection Pooling Software
 
log4j.properties file (put in the WEB-INF folder) -
# Sample ResourceBundle properties file
log4j.rootLogger=debug, R

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=c:\\example.log

log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n


In the Servlet I added the following at class level :
static Logger logger = Logger.getLogger(MultiFetcher.class);

and the following in 'init' method :
super.init(config);
PropertyConfigurator.configure("log4j.properties"); // for configuring log4j
logger.debug("please log me!!");


 
thanks! its working to their instructions now! only difference I had seems to be the filename...

whats the best place to find some good documentation on log4j and how to configure it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top