Quoting Michael A Chase <[EMAIL PROTECTED]>:

> On Mon, 12 Sep 2005 09:05:18 -0500, Jacob Kjome wrote:
>
> > Quoting Michael A Chase <[EMAIL PROTECTED]>:
>
> >> Can anyone point me to some way to capture the logging done via
> >> (ServletContext).log() so everything can go through log4j?
> >>
> > Grab the LOG4J_SANDBOX_ALPHA3 tag of the logging-log4j-sandbox and build
> > yourself to get the ServletContextLogAppender, compatible with
> > Log4j-1.2.xx (HEAD compatible with Log4j-1.3... to the best of my
> > recollection).
> >
> >
>
http://cvs.apache.org/viewcvs.cgi/logging-log4j-sandbox/src/java/org/apache/log4j/servlet/ServletContextLogAppender.java?rev=1.6&view=log
> >
> > Note that this doesn't always seem to work well (or at all) in an
> > environment that does parent-first classloading and/or log4j.jar isn't
> > stored in each individual webapp along with parent-last classloading
> > (such as Tomcat).  So, if you deploy log4j-sandbox.jar and log4j.jar in
> > each webapp's WEB-INF/lib along with parent-last classloading, this
> > should work pretty well for you.  Make sure to test this yourself before
> > assuming it will work in your environment. Consider this the reason why
> > it is still in the sandbox rather than log4j proper.
>
> Thank you for the pointer to the sandbox.  It provided useful concepts for
> managing logging levels dynamically and we have been pleased with the
> results.
>
> If I understand the comments and code in these Java files, this is the
> reverse of what I'm trying to do; it allows log4j to send its messages
> to the servlet context's log instead of managing its own output.  One of
> the most interesting features of log4j for us is the ability to rotate
> logs automatically, so I hope to cause messages from the servlet context
> logger to go through log4j instead of the other way around.
>

Ahhh, yes.  Of course you are right.  I guess I hastily read the question.  If
you want Log4j to control the output of servlet context logging, then configure
the server to use Log4j for logging, simple as that.  Tomcat-5.5 has been set up
in such a way that they've named their loggers like....

org.apache.catalina.core.ContainerBase.[serverName].[hostName].[/contextName]

So, just configure that logger to go to whatever appenders you want.  When
people use context.log("blah"), it will go to your Log4j-configured appender.

To get Tomcat-5.5 to use Log4j, you need to put commons-logging.jar (not
commons-logging-api.jar) and log4j.jar in common/lib and put log4j.properties
in commons/classes (or, if you are using Log4j-1.3, you can use log4j.xml.  The
problem is the '[' and ']' chars in the logger name above which conflicts with
the Log4j-1.2.xx dtd becasue the 'name' attribute is of type 'Id' which is
restricted in the chars allowed.  Since Joran XML configuration in Log4j-1.3
doesn't use a DTD, there is no problem).


Jake

> --
> Mac :})
> Give a hobbit a fish and he eats fish for a day.
> Give a hobbit a ring and he eats fish for an age.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>




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

Reply via email to