views:

795

answers:

1

I want to change the log format for Weblogic's server log. Right now it's generating logs using its default format-- I want to be able to specify my own format.

For example, it generates logs that look like this:

####<Jan 21, 2010 3:24:24 PM EST> <Info> <Socket> <FS2LOANER-00981> <DPSCoreServer1> <[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1264105464314> <BEA-000436> <Allocating 2 reader threads.> 
####<Jan 21, 2010 3:24:24 PM EST> <Info> <Socket> <FS2LOANER-00981> <DPSCoreServer1> <[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1264105464314> <BEA-000446> <Native IO Enabled.> 

I have tried to modify the log format by having Weblogic use LOG4J as its logging system and having it use my log4j.properties file which defines my desired log formats. However, weblogic does not pick up my log4j.property file settings and continues to log in its desired format, regardless of what I try.

This is effectively a very similar question to the following post, but that question never really got answered (the approved answer was regarding how to turn on log4j debugging, which hasn't helped me figure out why weblogic is not picking up my log4j.properties file). http://stackoverflow.com/questions/576937/using-log4j-logging-in-weblogic-9-10

A: 

To my knowledge, you can't (and no, you don't want to) change WebLogic Server's own Log Message Format (the support will be very happy to have the required informations in case of a problem).

But you can configure WebLogic to use Log4j (see How to Use Log4j with WebLogic Logging Services) and, when Log4j is enabled, you can get a reference to the org.apache.log4j.Logger that the server is using and attach your own appender.

When Log4j is enabled, you get a reference to the org.apache.log4j.Logger that the server is using from the weblogic.logging.log4j.Log4jLoggingHelper class.

With a Log4j Logger reference, you can attach you own custom appender to receive the server log events; for example, you might attach an appender that sends the server log events to Syslog or the Windows Event Viewer. Additionally, you can use the Logger reference to issue log requests to WebLogic logging services; this requires that the Log4j libraries be available to your deployed application.

But this is not a replacement of WebLogic's own log.

Pascal Thivent