You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Pawson, David" <Da...@rnib.org.uk> on 2005/04/13 13:34:37 UTC

RE: clean start. Logging in tomcat 559

Now I have logging working.
Using log4j-1.2.9

My application is 'hub'

put the properties file named log4j.properties in tc's classpath
(I use webapps/hub/WEB-INF/classes )

put the log4j-1.2.9.jar into webapps/hub/WEB-INF/lib

Init as follows:

//jakarta log4j
import org.apache.log4j.*;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;

	Logger lg = Logger.getLogger("hub1");
The 'name' (hubl) is arbitrary, read the log4j manual for more.
then use as needed, e.g.

	lg.error("** hub logging started **");

The properties file I used is below.
It produces output in ${catalina.home}/logs/tomcat.log
as specified in the properties file


log4j.rootLogger=DEBUG, hubl
#log4j.appender.hubl=org.apache.log4j.ConsoleAppender
log4j.appender.hubl=org.apache.log4j.RollingFileAppender
log4j.appender.hubl.File=/tomcat559/logs/tomcat.log 
log4j.appender.hubl.MaxFileSize=1MB
log4j.appender.hubl.MaxBackupIndex=3
log4j.appender.hubl.layout=org.apache.log4j.PatternLayout
log4j.appender.hubl.layout.ConversionPattern=<e><t>%d{yyyy-MMM-dd HH:mm}</t><lvl>%-5p</lvl><m>%m</m></e>%n

You may not want output in XML format, in which case again
go do some reading.
http://logging.apache.org/log4j/docs/api/org/apache/log4j/PatternLayout.html  (warning, long url)
provides the full story.

http://logging.apache.org/log4j/docs/manual.html is worth reading,
and I found
http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/log4j.html to be useful.


Perhaps the tomcat documentation might benefit from such a tiny inclusion?

HTH DaveP.


-- 
DISCLAIMER:

NOTICE: The information contained in this email and any attachments is 
confidential and may be privileged.  If you are not the intended 
recipient you should not use, disclose, distribute or copy any of the 
content of it or of any attachment; you are requested to notify the 
sender immediately of your receipt of the email and then to delete it 
and any attachments from your system.

RNIB endeavours to ensure that emails and any attachments generated by
its staff are free from viruses or other contaminants.  However, it 
cannot accept any responsibility for any  such which are transmitted.
We therefore recommend you scan all attachments.

Please note that the statements and views expressed in this email and 
any attachments are those of the author and do not necessarily represent
those of RNIB.

RNIB Registered Charity Number: 226227

Website: http://www.rnib.org.uk




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org