Logging in JDeveloper 11g / WebLogic Server

When developing an application it makes sense to add logging to this application. The Apache Commons Logging is a way to implement logging to your application independent of the eventually used implementation. While adding log messages to a Fusion Web Application (ADF) and running this application with JDeveloper the logging is not displayed in the application log window. This is not what expected en certainly undesirable.

The Apache commons logging is a wrapper around a third party logging implementation. Well the only thing we have to do is configuring this to use the Weblogic Logging implementation. so lets go:
I created a standard Fusion Web Application (ADF) with a default model and a viewController project.
Add the “Commons Logging 1.0.4” library to both projects  (Project -> properties -> Libraries and Classpath -> Add Library…)
It’s now possible to add logging to your application. I have added logging to my application module (nl.amis.wlslogging.model.ApplicationModuleImpl) like:
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
…
public AppModuleImpl() {
    sLog.debug("Application Module created.");
}
This will compile and run, but is this debug-message displayed? The answer is no, we didn’t configure a Logging implementation to the Apache Commons Logging. We have to add a “commons-logging.properties” configuration file to the src directory of both the Model and the ViewController projects. This properties file contains only one line:
org.apache.commons.logging.LogFactory=weblogic.logging.commons.LogFactoryImpl
This tells the Apache Commons Logging framework which log implementation to use. In this case an implementation for the WebLogic Application server. But when running this application an exception is raised, because of the unknown implementation class: weblogic.logging.commons.LogFactoryImpl.

We have to add the implementation class(es) to our project. Define in JDeveloper a new Library for this and assign it to both projects. The Library must contain the <JDEV_HOME>\modules\com.bea.core.weblogic.commons.logging_1.3.0.0.jar.

Logging in JDeveloper 11g / WebLogic Server library

Strictly it’s not necessary to add this library to the ViewControler project while this project depends on the Model project with the library added already.
When running the Business Components Tester, by running the Application Module, the message is showed as expected. But when running the application, from the ViewController project, there is no debug-message showed in the application log window. For this we have to configure the Weblogic Server. Start the Weblogic application server either by running the View Controller project or start the application server by Run -> Start server Instance.  Open the WebLogic Console (default: http://localhost:7101/console) and choose to configure the DefaultServer via Environment/Servers. In the advanced section of the Logging tab, you can configure the logging options. With the Logger severity properties it’s possible to assign a log level to s specific class structure. By adding nl.amis=Debug all messages with severity debug or higher from classes beneath nl.amis are displayed when running the application.

Example log configuration:

Logging in JDeveloper 11g / WebLogic Server log config(1)

4 Comments

  1. John March 4, 2009
  2. Jean-Philippe Melanson February 20, 2009
  3. Erwin Vrielink February 20, 2009
  4. Phil Tran February 18, 2009