> Do you initialise the log4J properties in your Struts action servlet?

No. The Facade takes care of that. Upon first call, it will initialize
itself.


> If you were to go to an xml config format, how do you package the xml file

I use the ClassLoader. The config file is placed in WEB-INF/classes. It
works great with Tomcat, WebLogic 6 seems to be having some trouble with
it... I really wonder why, this should be completely portable.

See the code, attached.

Let me know if you have questions.

--Renaud







----- Original Message -----
From: "Alex Colic" <[EMAIL PROTECTED]>
To: "Renaud Waldura" <[EMAIL PROTECTED]>
Sent: Sunday, October 21, 2001 9:30 AM
Subject: RE: How to properly use log4j with servlets.


> Hi,
>
> thanks for the reply. I found your info very interesting. If you could
> elaborate on the following it would help me sketch out what I need to do.
>
> Do you initialise the log4J properties in your Struts action servlet?
>
> If you were to go to an xml config format, how do you package the xml file
> up with your web app. I just place the properties file in the root of my
web
> app, and then get an instance of the apps path and load it that way. Would
> you do the same thing with the xml file?
>
> The Facade idea is great. I should have thought of that. Is that class a
> company proprietary one or could you pass it on to me.
>
> Thanks for any info.
>
> Alex
>
> -----Original Message-----
> From: Renaud Waldura [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, October 21, 2001 2:31 AM
> To: [EMAIL PROTECTED]
> Cc: LOG4J Users Mailing List
> Subject: Re: How to properly use log4j with servlets.
>
>
> We're using Log4J in a medium-sized Webapp, along with Struts and other
> stuff.
>
> I defined a "Logger" Facade that isolates the code base from Log4J; were
we
> to ever switch logging packages, it'd be a snap. Basically it calls
through
> to the Category methods. The Facade does the initialization also. BTW if
you
> can use the XML configuration format, by all means do, it's much easier to
> set up and maintain than the property file.
>
> At the top of each action class we have:
>
> private static final Logger log = Logger.getInstance(MyAction.class);
>
> then we do:
>
> log.warn("some harmless error occurred", exception);
>
> It's very much the same thing.
>
> --Renaud
>
>
>
>
> ----- Original Message -----
> From: "Alex Colic" <[EMAIL PROTECTED]>
> To: "Log4j" <[EMAIL PROTECTED]>
> Sent: Friday, October 19, 2001 1:32 PM
> Subject: How to properly use log4j with servlets.
>
>
> > Hi,
> >
> > I am trying to figure out how to use Log4J with servlets. Presently at
the
> > top of each class I have:
> >
> > private static Category cat =
> > Category.getInstance(wrEstimatedValuesAction.class.getName());
> >
> > Then throughout the class I use:
> >
> > if(cat.isInfoEnabled)
> > {
> >
> > }
> >
> > Questions:
> >
> > 1: Lets say you have a lot of servlets, does each servlet load the
> > logsettings.properties file?
> > 2: I am using Struts with the servlets, anyone have experience using
> Log4J.
> > Examples, ideas?
> >
> > Thanks for any info.
> >
> > Regards
> >
> > Alex
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
>
>

Logger.java

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

Reply via email to