You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Venkateshwar Bommineni <vb...@elogex.com> on 2002/09/19 17:23:46 UTC

RE: Request for working log4j configuration file (properties or XML) in Tomcat 4.0.4

How that file gets read? through a Servlet. I had the similar problem. 

For short fix, I am initilazing through Properties file which loads
log4j.properites file using hard coded path. code snippet:

       try {
            InputStream inStream =
getServletContext().getResourceAsStream("/WEB-INF/classes/log4j.properti
es");

            Properties configProps = new Properties();
            configProps.load(inStream);
            PropertyConfigurator.configure(configProps);

            log = Logger.getLogger("com.foo");

        } catch (Exception ep) {
            throw new ServletException("Unable to initialize Logging
Service");
        }


Any one can provide solution or suggest some other better way to do
that.

thanks in advance
Venkat

-----Original Message-----
From: Koes, Derrick [mailto:Derrick.Koes@smith-nephew.com]
Sent: Thursday, September 19, 2002 11:24 AM
To: 'log4j-user@jakarta.apache.org'
Subject: Request for working log4j configuration file (properties or
XML) in Tomcat 4.0.4


If anyone has a working log4j configuration file that they are using in
Tomcat 4.0.4, please forward.

 

I always get the no appenders warnings.

log4j:WARN No appenders could be found for logger (DoraLogger).

log4j:WARN Please initialize the log4j system properly.

 

The following configuration file in my webapp's web-inf/classes
directory
never gets read.

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

 

<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>

 

  <appender name="DoraAsync" class="org.apache.log4j.AsyncAppender">

    <appender-ref ref="Dora" />

    <appender-ref ref="NT"/>

  </appender>

 

  <appender name="Dora" class="org.apache.log4j.RollingFileAppender">

    <param name="File" value="dora.log"/>

    <param name="Append" value="true"/>

    <param name="ImmediateFlush" value="true"/>

    <layout class="org.apache.log4j.PatternLayout">

      <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS}
[%t] %-5p %c %x - %m%n"/>

    </layout>

  </appender>

 

  <appender name="NT" class="org.apache.log4j.nt.NTEventLogAppender">

    <param name="Threshold" value="warn"/>

  </appender>

 

  <appender name="Dora.Audit"
class="org.apache.log4j.DailyRollingFileAppender">

    <param name="File" value="audit.log"/>

    <param name="Append" value="true"/>

    <param name="ImmediateFlush" value="true"/>

    <layout class="org.apache.log4j.PatternLayout">

      <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS}
[%t] %-5p %c %x - %m%n"/>

    </layout>

  </appender>

 

  <appender name="Console" class="org.apache.log4j.ConsoleAppender">

    <param name="ImmediateFlush" value="true"/>

    <layout class="org.apache.log4j.PatternLayout">

      <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS}
[%t] %-5p %c %x - %m%n"/>

    </layout>

  </appender>

 

  <logger name="DoraLogger">

    <appender-ref ref="DoraAsync"/>

  </logger>

 

  <logger name="AuditLogger">

    <appender-ref ref="Dora.Audit"/>

  </logger>

 

  <!-- This will contain all available child loggers.  This should only
be
used in development.-->

  <root>

    <!-- Possible values:  all, debug, info, warn, error, fatal, off -->

    <priority value ="info" />

    <appender-ref ref="Console"/>

  </root>

 

</log4j:configuration>

This electronic transmission is strictly confidential to Smith & Nephew
and
intended solely for the addressee.  It may contain information which is
covered by legal, professional or other privilege.  If you are not the
intended addressee, or someone authorized by the intended addressee to
receive transmissions on behalf of the addressee, you must not retain,
disclose in any form, copy or take any action in reliance on this
transmission.  If you have received this transmission in error, please
notify the sender as soon as possible and destroy this message.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>