logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sathiskumar Govindasamy <gsat...@yahoo.com>
Subject Log4J and Tomcat 4 - Newbie
Date Tue, 02 Apr 2002 01:28:13 GMT
  Hello,

I am very new to both Tomcat4 and Log4J. I have been using apache-jserv 
for a very long time and finally decided to jump into Tomcat. I found 
tomcat doing the System.err logging to catalina.out file in 
/vat/tomcat4/logs directory. I would like to leave whatever tomcat4 does 
as it is. In addition to that I would like to use Log4J to log debug, 
info, warning messages that are specific to different context. I have 
gone through this mailing list's archeive and couldn't find any 
reference to similar question. So, I am posting it.

Here is what I have done

in /etc/tomcat4/conf/tomcat4.conf file I added this

export CATALINA_OPTS="-Dlog4j.configuration=log4j.properties"

I have placed the log4j-core.jar, parser.jar, jaxp.jar files in 
/var/tomcat4/webapps/myapp/WEB-INF/lib/ directory

I have the file log4j.properties in 
/var/tomcat4/webapps/myapp/WEB-INF/classes/ directory. Follwing is the 
content of that file

log4j.rootCategory=DEBUG, A1
log4j.appender.A1=org.apache.log4j.FileAppender
log4j.appender.A1.File={CATALINA_HOME}/logs/myapp.log
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r %-5p [%t] (%x) - %m\n

In my servlet I have the follwoing lines

import org.apache.log4j.*;
....
...

                        
PropertyConfigurator.configure("/var/tomcat4/webapps/eis/WEB-INF/classes/log4j.properties");
                        
PropertyConfigurator.configureAndWatch("/var/tomcat4/webapps/eis/WEB-INF/classes/log4j.properties");



                         // Initialize a logging category.  Here, we get 
THE ROOT CATEGORY
                        //static Category cat = Category.getRoot();
                        // Or, get a custom category

                        cat = Category.getRoot();
                        cat.setPriority(Priority.DEBUG);

                        // From here on, log away!  Methods are: 
cat.debug(your_message_string),
                        // cat.info(...), cat.warn(...), cat.error(...), 
cat.fatal(...)
                        cat.debug("Testing the logger DEBUG");
                        cat.info("Testing the logger INFO");
                        cat.warn("Testing the logger WARN");
                        cat.error("Testing the logger ERROR");
                        cat.fatal("Testing the logger FATAL");

   


I am basically using tomcat4 as servlet container. myapp is my context. 
The servlet part of it working just fine. I does rest of the things that 
I have, except the log4j part. I have the tomcat4 threads that looks 
like this

tomcat4  30939 30938  0 16:26 ?        00:00:02 
/usr/java/j2sdk1.4.0/bin/java -Dlog4j.configuration=log4j.properties 
-Djava.endorsed.dirs= -cl
tomcat4  30940 30938  0 16:26 ?        00:00:00 
/usr/java/j2sdk1.4.0/bin/java -Dlog4j.configuration=log4j.properties 
-Djava.endorsed.dirs= -cl
tomcat4  30941 30938  0 16:26 ?        00:00:00 
/usr/java/j2sdk1.4.0/bin/java -Dlog4j.configuration=log4j.properties 
-Djava.endorsed.dirs= -cl
tomcat4  30942 30938  0 16:26 ?        00:00:00 
/usr/java/j2sdk1.4.0/bin/java -Dlog4j.configuration=log4j.properties 
-Djava.endorsed.dirs= -cl
tomcat4  30943 30938  0 16:26 ?        00:00:00 
/usr/java/j2sdk1.4.0/bin/java -Dlog4j.configuration=log4j.properties 
-Djava.endorsed.dirs= -cl
tomcat4  30944 30938  0 16:26 ?        00:00:00 
/usr/java/j2sdk1.4.0/bin/java -Dlog4j.configuration=log4j.properties 
-Djava.endorsed.dirs= -cl
tomcat4  30945 30938  0 16:26 ?        00:00:04 
/usr/java/j2sdk1.4.0/bin/java -Dlog4j.configuration=log4j.properties 
-Djava.endorsed.dirs= -cl
tomcat4  30948 30938  0 16:26 ?        00:00:00 
/usr/java/j2sdk1.4.0/bin/java -Dlog4j.configuration=log4j.properties 
-Djava.endorsed.dirs= -cl
tomcat4  30949 30938  0 16:26 ?        00:00:00 
/usr/java/j2sdk1.4.0/bin/java -Dlog4j.configuration=log4j.properties 
-Djava.endorsed.dirs= -cl

I would greatly appreciate if you folks can help me out in configuring 
this correctly. I wish the log4j documentation had more information on 
installation of configuration with tomcat.

Thanks
Sathis


--
To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>


Mime
View raw message