tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject Re[2]: Log4J and tomcat
Date Thu, 13 Feb 2003 19:39:59 GMT
Hello Sloan,

You can remove the log4j.dtd.  Note that in the latest 1.2 CVS, this is
fixed.  However, there has been talk that in the 1.3 version of log4j,
the dtd might be removed for the same reason that it isn't used in
Tomcat's server.xml; because the markup is too rich and dynamic to be
described in a dtd or schema.

Also, if you use commons-logging, you should put log4j.jar in
common/lib.  It will find it there.  However, I would forgo
commons-logging altogether and just use Log4j.  BTW, how do you expect
to change the logging config without redeployment when log4j is
outside the webapp's WEB-INF/lib without shutting down Tomcat?  I'd
say that is worse than redeployment.

There are a couple solutions here.  Use Tomcat's install/uninstall
features so that you can start/stop the app in a snap, thus, allowing
you to change debug levels.  Also, look at configureAndWatch() which
will re-read your properties or xml file at a given interval without
shutting down your app or the server.  However, you can only add
loggers, not take them away.  There will be a better solution for this
in 1.3 with the WatchDog classes.

Also, you can use a custom repository selector if you want your app to
have its own logging context even when log4j is in a shared
classloader.
http://qos.ch/logging/sc.html

There is an implementation of this in the new Log4j sandbox.
http://cvs.apache.org/viewcvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/selector/ContextClassLoaderSelector.java?rev=1.1&content-type=text/vnd.viewcvs-markup

Plus, here is a log4j context initializer for use under Tomcat:
http://cvs.apache.org/viewcvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/servlet/InitContextListener.java?rev=1.1&content-type=text/vnd.viewcvs-markup

I know they work because I wrote them.

Jake


Thursday, February 13, 2003, 12:29:29 PM, you wrote:

SS> This is what I have defined at the beginning (could be causing the problem?)

SS>     private static final Log log = LogFactory.getLog(Initializer.class);

SS> The log factory is the org.apache.commons.logging.LogFactory.

SS> This is what I have in a servlet that gets preloaded...

SS>   String log4jFile = _config.getInitParameter("LOG4J_FILE");
SS>   if (log4jFile == null) throw new ServletException("Parameter LOG4J cannot
SS> be null");
SS>   DOMConfigurator.configureAndWatch(log4jFile);
SS>   log.info("Log configured");

SS> You would think that would do it but the log.info line gets sent to Tomcat's
SS> console screen and not to the file that I have defined...

SS> I do not have the log4j file in my war because I want to be able to
SS> dynamically change the log msg levels without having to re-deploy...

SS> I also had trouble with Tomcat not finding the log4j.dtd in the log4j
SS> jar....  I had to extract it from the jar and put it somewhere...

SS> ----- Original Message -----
SS> From: "Ron Day" <ronday@ronday.cc>
SS> To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
SS> Sent: Thursday, February 13, 2003 1:15 PM
SS> Subject: RE: Log4J and tomcat


>> Try putting log4j.jar in your WEB-INF/lib directory, and your log4j.props
SS> in
>> your classes directory.
>> or
>> set up a servlet that loads on startup that uses the log4j method to
SS> define
>> the path to your prop file, in the init().
>>
>> -----Original Message-----
>> From: Sloan Seaman [mailto:sloan@sgi.net]
>> Sent: Wednesday, February 12, 2003 3:23 PM
>> To: tomcat-user@jakarta.apache.org
>> Subject: Log4J and tomcat
>>
>>
>> I'm deploying a war file using tomcat and I wish to use Apache's common
>> logging api to log things (log4j behind the scenes).
>>
>> For some reason my configuration file seems to be getting ignored but my
>> log.info msgs are showing up in the console window for Tomcat.
>>
>> Can someone tell me why this is happening?
>>
>> How do I get my app to use my log4j conf file?
>>
>> Thanks!
>> --
>> Sloan
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>


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



-- 
Best regards,
 Jacob                            mailto:hoju@visi.com


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


Mime
View raw message