I use Log4j with Tomcat with no problems.

I do _not_ explicitly initialize a configurator. I simply do the following:

1. Place log4j.properties in:
$MY_WEB_APP_HOME/WEB-INF/classes

2. Create a 'logs' directory in my WEB-INF

3.  EXPLICITLY set a FULL path for the log file in the properties file as follows:
log4j.appender.A1.File=/this/is/a/full/path/MY_WEB_APP/WEB-INF/logs

If, like me, you deploy your app to many different locations, you can use a build and 
deploy tool like Ant to dynamically write out
the full path on deploy. So my actual properties file looks like this:

log4j.appender.A1.File=@logfile@

On deploy, Ant substitutes the actual full path for "@logfile@"

- jeff

----- Original Message -----
From: "Januski, Ken" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Tuesday, October 01, 2002 10:04 AM
Subject: RE: log4j


> You might want to take a look at this:
> http://jakarta.apache.org/log4j/docs/manual.html
> to get an overview of log4j.
>
> I'd tell you more but I'm still trying to digest it, and how I can use it in
> Tomcat, myself.
>
>
> -----Original Message-----
> From: Maxime Colas des Francs [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, October 01, 2002 12:57 PM
> To: Tomcat Users List
> Subject: Re: log4j
>
>
> tks
> i'm sorry but where can i find the log file ?
>
> my logj4.properties in WEB-INF/classes:
> log4j.rootCategory=DEBUG, htmlFile
> log4j.appender.htmlFile.layout=org.apache.log4j.HTMLLayout
> log4j.appender.htmlFile=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.htmlFile.DatePattern='.'yyyy-MM-dd
> log4j.appender.htmlFile.File=myapp-log.html
>
> for a test in a jsp, i put these lines :
>
> Category log = Category.getInstance("LOG");
> PropertyConfigurator.configure("log4j.properties");
> log.info("log sentence");
>
> it's executed but no file created.
>
> tks
>
> ----- Original Message -----
> From: "Dan Lipofsky" <[EMAIL PROTECTED]>
> To: "Tomcat Users List" <[EMAIL PROTECTED]>
> Sent: Tuesday, October 01, 2002 12:30 PM
> Subject: Re: log4j
>
>
> > You have to call PropertyConfigurator.configure().
> > I have a JSP which gets run when tomcat starts.
> > It has a jspInit() method which calls an init class
> > I wrote which initializes log4j like this:
> >
> >         URL url = Init.class.getResource(filename);
> >         PropertyConfigurator.configure(url);
> >
> > To get tomcat to run the JSP at startup I have this in
> > my web.xml
> >
> > <web-app>
> >   <servlet>
> >     <servlet-name>/Startup.jsp</servlet-name>
> >     <jsp-file>/Startup.jsp</jsp-file>
> >     <load-on-startup>1</load-on-startup>
> >   </servlet>
> >
> >   ...
> >
> > </web-app>
> >
> > - Dan
> >
> > ----- Original Message -----
> > From: "Maxime Colas des Francs" <[EMAIL PROTECTED]>
> > Sent: Tuesday, October 01, 2002 9:08 AM
> >
> > How to use log4j with a tomcat application ?
> >
> > I put the log4j.properties in WEB-INF/classes
> > No error but no file created (certainly rights ?)
> >
> > Can i put some log in a directory of the webapp ?
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to