org.eclipse.persistence.logging
Class CommonsLoggingSessionLog

java.lang.Object
  extended by org.eclipse.persistence.logging.AbstractSessionLog
      extended by org.eclipse.persistence.logging.CommonsLoggingSessionLog
All Implemented Interfaces:
java.lang.Cloneable, org.eclipse.persistence.logging.SessionLog

public final class CommonsLoggingSessionLog
extends org.eclipse.persistence.logging.AbstractSessionLog

PUBLIC: This is a wrapper class for org.apache.commons.logging.Log. It is used when messages need to be logged through apache commons logging 1.1. History : - 05/05/2009 : Updated API to EclipseLink 1.1 version + Javadoc fixes - 08/05/2009 : Fix for log4j levels in conflict with eclipselink jpa levels (shouldLog) TODO : Use Enum instead of int values for Levels (OO Design) Requires : - Jakarta Commons Logging 1.1 : http://commons.apache.org/logging/ - commons-logging-1.1.1.jar - Log4j 1.2 : http://logging.apache.org/log4j/ - log4j-1.2.15.jar

Author:
laurent bourges (voparis) : bourges.laurent@gmail.com
See Also:
AbstractSessionLog, JavaLog, SessionLogEntry

Field Summary
static java.lang.String DEFAULT_ECLIPSELINK_NAMESPACE
          org.eclipse.persistence.default used by Log4J configuration
static java.lang.String ECLIPSELINK_NAMESPACE
          Stores the default session name in case there is the session name is missing.
static boolean FORCE_APACHE_COMMONS_LOGGING_DIAGNOSTICS
          internal apache commons Logging diagnostic FLAG : use System.out
static boolean FORCE_INTERNAL_DEBUG
          internal debugger FLAG : use System.out
static boolean FORCE_INTERNAL_DEBUG_STACK
          internal debugger FLAG : use a stack trace to find caller class
static java.util.logging.Level[] JAVA_LEVELS
          Stores all the java.util.logging.Levels.
static java.lang.String LOGGING_LOCALIZATION_STRING
          Copied from JavaLog for compatibility issues
static java.lang.String SESSION_ECLIPSELINK_NAMESPACE
          org.eclipse.persistence.session used by Log4J configuration
static java.lang.String TRACE_LOCALIZATION_STRING
          Copied from JavaLog for compatibility issues
static int UNDEFINED_LEVEL
          value -1 corresponds to an undefined Level
static boolean USE_INTERNAL_CACHE
          internal cache FLAG for LogWrapper's levels
 
Fields inherited from class org.eclipse.persistence.logging.AbstractSessionLog
CONFIG_PREFIX, CONNECTION_STRING, DATE_FORMAT_STR, dateFormat, defaultLog, FINE_PREFIX, FINER_PREFIX, FINEST_PREFIX, INFO_PREFIX, level, session, SEVERE_PREFIX, shouldDisplayData, shouldLogExceptionStackTrace, shouldPrintConnection, shouldPrintDate, shouldPrintSession, shouldPrintThread, THREAD_STRING, TOPLINK_PREFIX, WARNING_PREFIX, writer
 
Fields inherited from interface org.eclipse.persistence.logging.SessionLog
ALL, ALL_LABEL, CACHE, CONFIG, CONFIG_LABEL, CONNECTION, DMS, EJB, EJB_OR_METADATA, EVENT, FINE, FINE_LABEL, FINER, FINER_LABEL, FINEST, FINEST_LABEL, INFO, INFO_LABEL, loggerCatagories, METAMODEL, OFF, OFF_LABEL, PROPAGATION, PROPERTIES, QUERY, SEQUENCING, SERVER, SEVERE, SEVERE_LABEL, SQL, TRANSACTION, WARNING, WARNING_LABEL, WEAVER
 
Constructor Summary
CommonsLoggingSessionLog()
          PUBLIC: CommonsLoggingSessionLog Constructor.
 
Method Summary
 java.lang.Object clone()
          INTERNAL: Each session owns its own session log because session is stored in the session log
protected static void debug(java.lang.String message)
          Prints the message in Std out
protected static void debug(java.lang.String message, boolean printStack)
          Prints the message in Std out
protected static void error(java.lang.String message)
          Prints the message in Std err
protected static void error(java.lang.Throwable th)
          Prints the message in Std err
 int getLevel(java.lang.String category)
          PUBLIC: Return the effective log level for the name space extracted from session and category.
 void log(org.eclipse.persistence.logging.SessionLogEntry entry)
          PUBLIC: Log a SessionLogEntry
static void onExit()
          PUBLIC: onExit method : release all ClassLoader references due to apache commons logging LogFactory NOTE : This method must be called in the context of a web application via ServletContextListener.contextDestroyed(ServletContextEvent)
static void onInit()
          PUBLIC: OnInit method : define system properties for org.apache.commons.logging
 void setLevel(int level, java.lang.String category)
          PUBLIC: Set the log level to a logger with name space extracted from the given category.
 void setSession(org.eclipse.persistence.sessions.Session pSession)
          PUBLIC: Set the session and session namespace.
 void setWriter(java.io.OutputStream fileOutputStream)
          PUBLIC: Set the output stream that will receive the formatted log entries.
 boolean shouldLog(int level, java.lang.String category)
          PUBLIC: Check if a message of the given lev would actually be logged by the logger with name space built from the given session and category.
 void throwing(java.lang.Throwable throwable)
          PUBLIC: Log a throwable.
 
Methods inherited from class org.eclipse.persistence.logging.AbstractSessionLog
config, fine, finer, finest, formatMessage, getConnectionString, getDateFormat, getDateString, getDefaultLoggingLevel, getLevel, getLevelString, getLog, getSession, getSessionString, getSupplementDetailString, getThreadString, getWriter, info, isOff, log, log, log, log, log, log, log, logThrowable, printPrefixString, setDateFormat, setLevel, setLog, setShouldDisplayData, setShouldLogExceptionStackTrace, setShouldPrintConnection, setShouldPrintDate, setShouldPrintSession, setShouldPrintThread, setWriter, severe, shouldDisplayData, shouldLog, shouldLogExceptionStackTrace, shouldPrintConnection, shouldPrintDate, shouldPrintSession, shouldPrintThread, translateLoggingLevelToString, translateStringToLoggingLevel, warning
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORCE_INTERNAL_DEBUG

public static final boolean FORCE_INTERNAL_DEBUG
internal debugger FLAG : use System.out

See Also:
Constant Field Values

FORCE_INTERNAL_DEBUG_STACK

public static final boolean FORCE_INTERNAL_DEBUG_STACK
internal debugger FLAG : use a stack trace to find caller class

See Also:
Constant Field Values

USE_INTERNAL_CACHE

public static final boolean USE_INTERNAL_CACHE
internal cache FLAG for LogWrapper's levels

See Also:
Constant Field Values

FORCE_APACHE_COMMONS_LOGGING_DIAGNOSTICS

public static final boolean FORCE_APACHE_COMMONS_LOGGING_DIAGNOSTICS
internal apache commons Logging diagnostic FLAG : use System.out

See Also:
Constant Field Values

UNDEFINED_LEVEL

public static final int UNDEFINED_LEVEL
value -1 corresponds to an undefined Level

See Also:
Constant Field Values

ECLIPSELINK_NAMESPACE

public static final java.lang.String ECLIPSELINK_NAMESPACE
Stores the default session name in case there is the session name is missing. org.eclipse.persistence package used by Log4J configuration

See Also:
Constant Field Values

DEFAULT_ECLIPSELINK_NAMESPACE

public static final java.lang.String DEFAULT_ECLIPSELINK_NAMESPACE
org.eclipse.persistence.default used by Log4J configuration

See Also:
Constant Field Values

SESSION_ECLIPSELINK_NAMESPACE

public static final java.lang.String SESSION_ECLIPSELINK_NAMESPACE
org.eclipse.persistence.session used by Log4J configuration

See Also:
Constant Field Values

LOGGING_LOCALIZATION_STRING

public static final java.lang.String LOGGING_LOCALIZATION_STRING
Copied from JavaLog for compatibility issues

See Also:
Constant Field Values

TRACE_LOCALIZATION_STRING

public static final java.lang.String TRACE_LOCALIZATION_STRING
Copied from JavaLog for compatibility issues

See Also:
Constant Field Values

JAVA_LEVELS

public static final java.util.logging.Level[] JAVA_LEVELS
Stores all the java.util.logging.Levels. The indexes are EclipseLink logging levels.

Constructor Detail

CommonsLoggingSessionLog

public CommonsLoggingSessionLog()
PUBLIC: CommonsLoggingSessionLog Constructor. Used by : org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.updateLoggers : creates an instance for singletonLog and sessionLog This adds a root logger for DEFAULT_ECLIPSELINK_NAMESPACE.

Method Detail

onInit

public static final void onInit()
PUBLIC: OnInit method : define system properties for org.apache.commons.logging


onExit

public static final void onExit()
PUBLIC: onExit method : release all ClassLoader references due to apache commons logging LogFactory NOTE : This method must be called in the context of a web application via ServletContextListener.contextDestroyed(ServletContextEvent)

See Also:
LogFactory.release(ClassLoader)

getLevel

public final int getLevel(java.lang.String category)
PUBLIC: Return the effective log level for the name space extracted from session and category. If a Logger's level is set to be null then the Logger will use an effective Level that will be obtained by walking up the parent tree and using the first non-null Level.

Specified by:
getLevel in interface org.eclipse.persistence.logging.SessionLog
Overrides:
getLevel in class org.eclipse.persistence.logging.AbstractSessionLog
Parameters:
category - category
Returns:
the effective level according to the java.util.logging.Levels

setLevel

public final void setLevel(int level,
                           java.lang.String category)
PUBLIC: Set the log level to a logger with name space extracted from the given category.

Specified by:
setLevel in interface org.eclipse.persistence.logging.SessionLog
Overrides:
setLevel in class org.eclipse.persistence.logging.AbstractSessionLog
Parameters:
level - value according to the java.util.logging.Levels
category - category

setWriter

public final void setWriter(java.io.OutputStream fileOutputStream)
PUBLIC: Set the output stream that will receive the formatted log entries. DO nothing as Log4J manages the appenders (console or files) via Log4J configuration

Overrides:
setWriter in class org.eclipse.persistence.logging.AbstractSessionLog
Parameters:
fileOutputStream - the file output stream will receive the formatted log entries.

setSession

public final void setSession(org.eclipse.persistence.sessions.Session pSession)
PUBLIC: Set the session and session namespace.

Specified by:
setSession in interface org.eclipse.persistence.logging.SessionLog
Overrides:
setSession in class org.eclipse.persistence.logging.AbstractSessionLog
Parameters:
pSession - an eclipselink Session

shouldLog

public final boolean shouldLog(int level,
                               java.lang.String category)
PUBLIC: Check if a message of the given lev would actually be logged by the logger with name space built from the given session and category. Return the shouldLog for the given category Note : this method is very very used so optimized for performance.

Specified by:
shouldLog in interface org.eclipse.persistence.logging.SessionLog
Overrides:
shouldLog in class org.eclipse.persistence.logging.AbstractSessionLog
Parameters:
level - value according to the java.util.logging.Levels
category - category
Returns:
true if the given message will be logged

log

public final void log(org.eclipse.persistence.logging.SessionLogEntry entry)
PUBLIC: Log a SessionLogEntry

Specified by:
log in interface org.eclipse.persistence.logging.SessionLog
Specified by:
log in class org.eclipse.persistence.logging.AbstractSessionLog
Parameters:
entry - SessionLogEntry that holds all the information for a EclipseLink logging event

throwing

public final void throwing(java.lang.Throwable throwable)
PUBLIC: Log a throwable.

Specified by:
throwing in interface org.eclipse.persistence.logging.SessionLog
Overrides:
throwing in class org.eclipse.persistence.logging.AbstractSessionLog
Parameters:
throwable - a throwable

clone

public final java.lang.Object clone()
INTERNAL: Each session owns its own session log because session is stored in the session log

Specified by:
clone in interface org.eclipse.persistence.logging.SessionLog
Overrides:
clone in class org.eclipse.persistence.logging.AbstractSessionLog
Returns:
value TODO : Value Description

debug

protected static final void debug(java.lang.String message)
Prints the message in Std out

Parameters:
message - message to print

debug

protected static final void debug(java.lang.String message,
                                  boolean printStack)
Prints the message in Std out

Parameters:
message - message to print
printStack - adds a stack trace to find caller class

error

protected static final void error(java.lang.String message)
Prints the message in Std err

Parameters:
message - message to print

error

protected static final void error(java.lang.Throwable th)
Prints the message in Std err

Parameters:
message - message to print