Here is how I do it:
1. Extend ActionServlet and overwrite init method
public void init( ServletConfig config ) throws ServletException {
initAppLog( config );
super.init( config );
...;
}
2. Initialize log4j
//-------------------------------------------------------- Log4j
Initialization
private void initAppLog(ServletConfig config) {
try {
DOMConfigurator.configure(
config.getServletContext().getRealPath (
config.getInitParameter( "logConfig" )));
cat = Category.getInstance(this.getClass().getName());
cat.info( "Logging Initialized" );
}
catch( Throwable t ) {
this.log( t );
}
}
3. In your action initianilize Category and start using it:
cat = Category.getInstance(this.getClass().getName());
cat.info("...");
etc.
You have to make sure you have all necessary jars and property file in the
appropriate places.
Mark.
P.S. I am running struts 1.01 with tiles
-----Original Message-----
From: Jay sissom [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 10, 2002 2:53 PM
To: Struts Users Mailing List
Subject: RE: Struts 1.1b/log4j
Can you please tell me the file in the log4j download tar.gz file that
tells how to configure log4j to work with struts? I did a grep for struts
in the whole log4j download and the only mention of it in the entire thing
were links to http://jakarta.apache.org/struts (and a couple of email
messages that have no documentation). I downloaded 1.1.3. Maybe it's in
a different version. Please tell me what version to download also.
I know how to use log4j, I just don't know which Categories struts 1.1b
uses in log4j. I now know that one is
org.apache.struts.action.ActionServlet. Is that the only one? Is this
documented anywhere?
Thank you very much for your help
Jay
On Wed, 10 Apr 2002, Zeltser, Mark wrote:
> Download log4j from jakarta.apache.org and read documentation on how to
> configure it with struts.
>
> Mark.
>
> -----Original Message-----
> From: Jay sissom [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 10, 2002 2:23 PM
> To: Struts Users Mailing List
> Subject: Struts 1.1b/log4j
>
>
> Can someone please point me to (or send to the list) an example
> log4j.properties file that will work with Struts 1.1b? I'm not sure what
> appenders and categories to put in there and I haven't found any
> documentation about it.
>
> Also, do I have to start log4j or does Struts start it automatically?
>
> Thanks
> Jay
>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
>
>
----------------------------------------------------------------------------
--
> This message is intended only for the personal and confidential use of the
designated recipient(s) named above. If you are not the intended recipient
of this message you are hereby notified that any review, dissemination,
distribution or copying of this message is strictly prohibited. This
communication is for information purposes only and should not be regarded as
an offer to sell or as a solicitation of an offer to buy any financial
product, an official confirmation of any transaction, or as an official
statement of Lehman Brothers. Email transmission cannot be guaranteed to be
secure or error-free. Therefore, we do not represent that this information
is complete or accurate and it should not be relied upon as such. All
information is subject to change without notice.
>
>
>
> --
> 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]>
------------------------------------------------------------------------------
This message is intended only for the personal and confidential use of the designated
recipient(s) named above. If you are not the intended recipient of this message you
are hereby notified that any review, dissemination, distribution or copying of this
message is strictly prohibited. This communication is for information purposes only
and should not be regarded as an offer to sell or as a solicitation of an offer to buy
any financial product, an official confirmation of any transaction, or as an official
statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or
error-free. Therefore, we do not represent that this information is complete or
accurate and it should not be relied upon as such. All information is subject to
change without notice.
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>