Logging through WebSphere Portal from Java and JSPs

Recently, I wanted to tap into the WebSphere Portal logging system so that administrators can toggle tracing for my application classes at runtime by using the Enable Tracing feature in the WebSphere Portal Admin UI.

I was attempting the typical java.util.logging business like this:


import java.util.logging.Level;
import java.util.logging.Logger;

Declare the Logger

public static final Logger LOG = Logger.getLogger(PDFUtils.class.getName());

Use the Logger (well, attempt to…)

if(LOG.isLoggable(Level.FINEST)) {
    LOG.finest("HELLO WORLD!");


I would then navigate to Portal Admin > Enable Tracing and add com.base22.*=finest, but none of my statements ever spit out to my console in Rational Software Architect or to WebSphere Portal’s SystemOut.log file. As it turns out, “log entries lower than WsLevel.DETAIL are never stored in the SystemOut.log file”. After much searching, I finally learned this from a post found online called LOGGING AND TRACING FROM A WEBSPHERE BASED J2EE APPLICATION.


My final solution was to include an import for the WebSphere specific levels like so…

import com.ibm.websphere.logging.WsLevel;

.. and then modify my logging statements to key off of WsLevel.DETAIL, which FINE, FINER, and FINEST roll up into; like this:

if (LOG.isLoggable(WsLevel.DETAIL)) {
    LOG.log(WsLevel.DETAIL,">> writePDFFromContentToOutputStream()");

Hopefully this will save you the time it took me to whittle trough it.