logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject Re: log4j...help.
Date Fri, 03 Mar 2006 03:50:24 GMT

In your config file, put something like...

<param name="File" value="${mywebap.log.home}/main.log" />

Then, in your ServletContextListener, set the location of the webapp's 
absolute system path as the system variable 
"mywebapp.log.home".  Immediately after that, you can perform Log4j 
configuration.  Your config file will now write the log file to a directory 
within your webapp.  This assumes that you have a distinct logger 
repository for each webapp.  This can be done either by using child-first 
classloading behavior and including log4j.jar in WEB-INF/lib or using a 
repository selector.

Actually, I have this all worked out my InitContextlistener in the log4j 
sandbox.  Read here for more...

Oh, and just map all the links to the CVS repository to their equivalents 
in the SVN repository.  That page hasn't been updated since the move to 
SVN.  The latest fully 1.2.xx compatible version of the sandbox code was 
tagged, unofficially, as 0.3alpha in CVS (note, any checkins having to do 
with Log4j-1.3 compatibility may now be broken since the 1.3 api has 
changed since then).  However, CVS is gone and those tags don't exist in 
SVN.  I think Revision 311918 looks to be the equivalent, although I 
haven't checked for sure.  In any case, you can always just look at the 
code and roll your own.  See InitContextListener for lots of javadoc 
instructions and see InitShutdownController for the logic.



At 04:18 PM 3/2/2006 -0600, you wrote:
 >I haven't used log4j a whole lot.  Having noticed that logging in not
 >particularly a strongsuit in the applications at my job, I decided that I
 >would implement this industry-standard in my next project.  I downloaded
 >the latest version, installed and configured it rather easily and I was
 >off and running.. i thought.  I've been stumped by this one problem...
 >I've been going nuts trying to figure out how to output to a
 >file/directory in my web application.  I'm able to go to database and
 >console just fine.  A few other Appenders worked as well.   As I've found,
 > log4j prints directly to my WSAD root install directory.  This is a
 >problem for me since I share a server with other teams and applications. I
 >could create a NAS share but that creates portability issues.  This has to
 >be simple but I'm Googlestumped.  Here's my log file.  Any ideas?
 ><?xml version="1.0" encoding="UTF-8"?>
 ><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
 ><log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
 >        <appender name="USER_LOG" class="org.apache.log4j.ConsoleAppender"
 >                <param name="Threshold" value="debug" />
 >                <layout class="org.apache.log4j.PatternLayout">
 >                        <param name="ConversionPattern" value="%-5p %c{2}
 >- %m\n" />
 >                </layout>
 >        </appender>
 >        <appender name="PERF_LOG" class="org.apache.log4j.FileAppender">
 >                <param name="File" value="perf.log" />
 >                <param name="Threshold" value="info" />
 >                <layout class="org.apache.log4j.PatternLayout">
 >                        <param name="ConversionPattern" value="%-5p %c{2}
 >- %m\n" />
 >                </layout>
 >        </appender>
 >        <appender name="ROLE_LOG" class=
 >                <param name="File" value="es_edi.log" />
 >                <param name="MaxBackupIndex" value="10" />
 >                <param name="MaxFileSize" value="1000KB" />
 >                <param name="Threshold" value="debug" />
 >                <layout class="org.apache.log4j.PatternLayout">
 >                        <param name="ConversionPattern" value="[%d] %t %c
 >%-5p - %m%n" />
 >                </layout>
 >        </appender>
 >        <logger name="com.xxx.xxx">
 >                <level value="DEBUG" />
 >                <appender-ref ref="PERF_LOG" />
 >                <appender-ref ref="USER_LOG" />
 >                <appender-ref ref="ROLE_LOG" />
 >        </logger>
 >        <root>
 >                <priority value="debug" />
 >                <appender-ref ref="USER_LOG" />
 >        </root>

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

View raw message