I use method 2, but it doesn't require a call into that servlet.  I just use
it to initialize log4j.  After this servlet loads, I just call log4j object
methods, and it works.  I believe (someone correct me if I'm wrong) that the
servlet loads in the same JVM, so you have access to its objects in the
other servlets...

Mark

-----Original Message-----
From: Eric Ma [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 15, 2002 11:33 AM
To: [EMAIL PROTECTED]
Subject: How to use Log4j with a startup logging servlet


I want to use Log4J for logging exceptions thrown in a Struts-based web app.
After searching through this list, I found 2 common solutions:

1. Extend the Struts ActionServlet and override the init() method to set up
a Log4J Category.  Then in any custom Action class I can just call
servlet.Category.debug() (let's assume Category is a protected or public
variable).

2. Write a separate startup servlet and again set up LOG4J in the init()
method.  But my question is, how do I invoke this servlet from my custom
Action class?  Do I need to do a RequestDispatcher.forward() to the servlet
when an exception is thrown?  Then how do I get back to the page I am on to
display the error message?

Eric Ma


--

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.



--
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