Log4j looks on your class path for a properties file
"log4j.properties". If you put the file in WEB-INF/classes
it will find it.
Here's a real simple example:
log4j.rootCategory=DEBUG, dest1
log4j.appender.dest1=org.apache.log4j.RollingFileAppender
log4j.appender.dest1.file=/usr/local/tomcat/logs/myapp.log
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
log4j.appender.dest1.layout.ConversionPattern=%-5p: %m%n
On Thu, 2004-10-28 at 19:08, Mufaddal Khumri wrote:
> Hi,
>
> Am new to log4j. Am using Tomcat 5 and my webapp-myNiceWebApp is in
> Tomcat/webapps/myNiceWebApp
>
> I have a class that I have the following code in:
>
> Logger logger = Logger.getLogger(Helper.class);
> SimpleLayout layout = new SimpleLayout();
>
> FileAppender appender = null;
> try
> {
> appender = new FileAppender(layout,"output1.txt",false);
> }
> catch(Exception e)
> {
> e.printStackTrace();
> }
>
> logger.addAppender(appender);
> logger.setLevel((Level)Level.DEBUG);
>
> logger.debug("some message");
>
> Que 1. Where does the file output1.txt get created?
> Que 2. How does log4j know where to create it and can it be controlled?
> Que 3. I am going to use a configuration file either use the
> DOMConfigurator or PropertyConfigurator to load the log4j properties.
> Where do i place this file log4j configuration file?
>
> Thanks,
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]