You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Michael A Chase <mc...@ix.netcom.com> on 2005/09/11 05:56:40 UTC

Capturing OC4J logging

I'm not at work now so I don't have the exact version information, but I
don't think it matters much.

We are running a web application under OC4J which provides logging via a
ServletContext com.evermind.http.Application.  We've converted all our
code to use log4j, but we are still seeing errors from lower level code
going to the original log file.

Can anyone point me to some way to capture the logging done via
(ServletContext).log() so everything can go through log4j?

-- 
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: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Capturing OC4J logging

Posted by Michael A Chase <mc...@ix.netcom.com>.
On Tue, 13 Sep 2005 19:36:52 -0700, Michael A Chase wrote:

> The only things showing up in the context.log() output now are startup
> messages which I'm not worried about and exception messages from low-level
> libraries which I'd really like to see in the log4j logs.

I eventually found the com.evermind.util.Logger interface used in
http://www.orionserver.com/docs/orion-application.xml.html . 
Unfortunately the DTD for orion-application that comes with OC4J doesn't
define the logger tag, so I can't use it in current versions of OC4J. 
Maybe someday.

-- 
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: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Capturing OC4J logging

Posted by Michael A Chase <mc...@ix.netcom.com>.
On Tue, 13 Sep 2005 09:19:09 -0500, Jacob Kjome wrote:

>>> Quoting Michael A Chase <mc...@ix.netcom.com>:
>>
>>>> Can anyone point me to some way to capture the logging done via
>>>> (ServletContext).log() so everything can go through log4j?

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

I don't know how OC4J is related to Tomcat.  I've been wading through
Oracle's tech site trying to find anything that says how to configure
logging and haven't turned up anything yet that would allow me configure
the server to use log4j for logging.

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

We just started using log4j with version 1.2.11 and don't plan to move to
1.3 until it's at least in beta.  First I'll have to see if OC4J's
configuration scheme is similar to Tomcat's.  If I'm lucky, maybe just
putting commons-logging.jar in /WEB-INF/lib along with log4j.jar and in
the project class path will get me most of what I'm looking for.

The only things showing up in the context.log() output now are startup
messages which I'm not worried about and exception messages from low-level
libraries which I'd really like to see in the log4j logs.

-- 
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: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Capturing OC4J logging

Posted by Jacob Kjome <ho...@visi.com>.
Quoting Michael A Chase <mc...@ix.netcom.com>:

> On Mon, 12 Sep 2005 09:05:18 -0500, Jacob Kjome wrote:
>
> > Quoting Michael A Chase <mc...@ix.netcom.com>:
>
> >> 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: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>




---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Capturing OC4J logging

Posted by Michael A Chase <mc...@ix.netcom.com>.
On Mon, 12 Sep 2005 09:05:18 -0500, Jacob Kjome wrote:

> Quoting Michael A Chase <mc...@ix.netcom.com>:

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

-- 
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: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Capturing OC4J logging

Posted by Jacob Kjome <ho...@visi.com>.
Quoting Michael A Chase <mc...@ix.netcom.com>:

> I'm not at work now so I don't have the exact version information, but I
> don't think it matters much.
>
> We are running a web application under OC4J which provides logging via a
> ServletContext com.evermind.http.Application.  We've converted all our
> code to use log4j, but we are still seeing errors from lower level code
> going to the original log file.
>
> 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.

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: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org