-----Ursprüngliche Nachricht-----
Von: Azeem Niazi [mailto:[EMAIL PROTECTED]]
Gesendet: Samstag, 31. März 2001 00:58
An: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Betreff: Re: AW: using log4J with Struts>From: Rainer Alföldi <[EMAIL PROTECTED]> >Reply-To: [EMAIL PROTECTED] >To: <[EMAIL PROTECTED]>, "Jon Wilmoth" <[EMAIL PROTECTED]> >Subject: AW: using log4J with Struts >Date: Sat, 31 Mar 2001 00:27:06 +0200 > >Hi Jon, > >we set up a startup servlet, that initializes our application. This is very >simple and basically just calls various init routines. (No subclassing) >After that the ActionServlet is called. > >All applications use init.props to get up and running. The same with log4j. >I have attached the routines for startup as well as the configuration for >log4j. > >I really wounldn´t start mixing the ActionServlet with anything else but >Struts. > >Hope this helps. > > >Greeting > > >Rainer > -----Ursprüngliche Nachricht----- > Von: Jon Wilmoth [mailto:[EMAIL PROTECTED]] > Gesendet: Freitag, 30. März 2001 23:56 > An: [EMAIL PROTECTED] > Betreff: Re: using log4J with Struts > > > So your suggesting subclassing the default controller, >org.apache.struts.action.ActionServlet, to override only the init method? >Also, I'm not familiar enough with the web.xml format as to be able to >configure the org.apache.log4j.PropertyConfigurator. How would one do this? > > Thanks, > Jon Wilmoth > ----- Original Message ----- > From: Tomer Meshorer > To: '[EMAIL PROTECTED]' > Sent: Friday, March 30, 2001 11:28 AM > Subject: RE: using log4J with Struts > > > Yes, In the init() method of the controller servlet define all your >categories and give them a priority. You may also want to put the categris >in web.xml so you can read them in runtime and thus be able to change the >log detail level (i.e. only ERROR log messages) when you are in production. > > Tomer Meshorer > NewChannel > > > > > -----Original Message----- > From: Azeem Niazi [mailto:[EMAIL PROTECTED]] > Sent: Friday, March 30, 2001 11:22 AM > To: [EMAIL PROTECTED] > Subject: using log4J with Struts > > > Has anyone used log4J with struts. If so, how did you do it. Do you >need to register log4j with controller servlet? > > >-------------------------------------------------------------------------- > Get your FREE download of MSN Explorer at http://explorer.msn.com > > ><< init-mailinglist.conf >> ><< log-config-mailinglist.xml >> ><< Startup-mailinglist.java >>Rainer
You forgot to attach the routines and log4 J config file. I am new to both Struts and Log4j.So what it is coming down to is you define init params in one of the routines you are talking here and then reference them in web.xml, so it gets registered with controller servlet. Could you send a sample of web.xml with log4J categories registered in it along with some init routines.
What would be the best way of passing config file for log4J to PropertyConfigurator(config), in cases where you are developing your application in one environment and then want to move your application transparently to a differently env without affecting passing of config file location(e.g moving from Windows to Unix)
ThanksAzeem
Get your FREE download of MSN Explorer at http://explorer.msn.com
Hi
Azeem,
I
think I attached all needed files. I just renamed them and deleted everthing not
needed for log4j.
-
Startup-mailinglist.java:
Contains public void init(ServletConfig config) which
is called during servlet initialisation. This method calls private void
initLog4J( Properties initProps ).
-
init-mailinglist.conf:
This is the properties file used by Startup-javaand
contains all parameter used to init log4j. (Basically path for log4j config file
and time intervall for the reload option of
log4j.)
-
log-config-mailinglist.xml:
this is the xml-config file for log4j. here you define
what packages should be logging where to and at what logging level. This file is
used in Startup.java at "DOMConfigurator.configureAndWatch( url, reloadTime );".
Check the log4j documentation if you need more support on
this.
Moving the application transparently? The appender
files are still hardcoded. If we ever have to much time during this project,
we´ll fix that up... ;-)). Everthing else is independent of absolute
paths.
Greeting
Rainer
- Re: AW: using log4J with Struts Azeem Niazi
- Rainer Alföldi