How to retrofit the logging of an OC4j based app into running under weblogic 10.3.6?
There are two basic components in any logging system: a component that produces log messages and another component to distribute (publish) messages. WebLogic Server subsystems use a message catalog feature to produce messages and the Java Logging APIs to distribute them, by default.
Logging mechanism provided by weblogic:
(1) Using the I18N Message Catalog Framework: the message catalog framework is used when there is a need for internationalization
(2) Using the NonCatalogLogger APIs: Used when no need to internationalize
(3) Server Logging Bridge
Used for Apps useing other logging mechanism, and have its messages redirected to WebLogic logging services without the need to make code changes or implement any of the propriety WebLogic Logging APIs
Our application are in the (3) category.
The Jakarta Commons Logging APIs define a factory API to get a Logger reference which dispatches log requests to the server Logger object.
The server Logger object can be an instance of java.util.logging.Logger or org.apache.log4j.Logger. We are using log4j logger. From our code, the import package shows that.
Best Practices: Integrating Java Logging or Log4j with WebLogic Logging Services
• If your application is configured for Java Logging or Log4j, in order to publish application events using WebLogic logging services, you can do either of the following:
• (Recommended) Configure your application's logger to use the Server Logging Bridge, which provides a lightweight means for your application's log messages to be redirected to WebLogic logging services without requiring any code changes. For more information, see Server Logging Bridge.
• Create a custom handler or appender that relays the application events to WebLogic logging services using programmatic API. For information, see How to Use Log4j with WebLogic Logging Services.
We can let app logs integrated into Weblogic server logs, at the same time, also output them to separate log4j log file. The drawback is that it may negatively impact the performance.
common-logging has a few implementations:
(1) Java JDK implementation (it is bundled after java 1.3 ): some perceive this as an inferior implementation than log4j. basic
(2) Log4j implementation
The Jakarta Commons Logging APIs provide an abstraction layer that insulates users from the underlying logging implementation, which can be Log4j or Java Logging APIs.
WebLogic Server provides an implementation of the Commons LogFactory interface, letting you issue requests to the server Logger using this API.
WebLogic Server supports Java based logging by default. The LoggingHelper class provides access to the java.util.logging.Logger object used for server logging. This lets developers take advantage of the Java Logging APIs to add custom handlers, filters, and formatters. See the java.util.logging API documentation at http://download.oracle.com/javase/6/docs/api/java/util/logging/package-summary.html.
Things to do to retro fit our application into weblogic logging :
(1) Set up the bridge in log4j.properties so that the log4j logs can be directed to weblogic server logging. This can also be done by
Setting “Logging Bridge Uses Parent Loggers” at the admin console configuration .
(2) Include log4j configuration, and the change to the build.xml to rebuild to ensure putting log4j.xml or log4j.properties to be under "classes" folder. Redeploy.
(3) Check server logs: Search log4j to confirm log4j subsystem is initialized.
(4) Check our config.xml to see whether there are already log4j configurations there. Some say this may superseds log4j.properties. If there are, remove them. Use log4j.properties instead. The new 11g weblogic doc did not mention config.xml.
(5) Need to do one of the following:
To specify logging to a Log4j Logger instead of the default Java Logging:
When you start the Administration Server, include the following Java option in the weblogic.Server command:
-Dweblogic.log.Log4jLoggingEnabled=true
Or:
After the Administration Server has started, use the Administration Console to specify the Log4j logging implementation. See "Specifying the Logging Implementation" in the Administration Console Online Help.
Admin console logging configuration for Weblogic 10.3.6 (oracle fusion 11g):
http://docs.tpu.ru/docs/oracle/en/fmw/11.1.1.6.0/apirefs.1111/e13952/pagehelp/Corecoreserverserverlogginggeneraltitle.html
This is also a nice blog article on log4j and weblogic:
http://ananthkannan.blogspot.ca/2009/09/how-to-configure-log4j-in-weblogic.html
-------------------------------------------------------------------------------------
The following is from weblogic older version reference, not sure if they still apply.
Need to check config.xml, and still need to include log4j configuration if want app to use log4j logging.
http://stackoverflow.com/questions/576937/using-log4j-logging-in-weblogic-9-10
No comments:
Post a Comment