The Spring Framework

## org.springframework.orm.toplink.support
Class CommonsLoggingSessionLog

    java.lang.Object
      oracle.toplink.logging.AbstractSessionLog
          org.springframework.orm.toplink.support.CommonsLoggingSessionLog

All Implemented Interfaces:
  Cloneable, oracle.toplink.sessions.SessionLog

    public class CommonsLoggingSessionLog

extends oracle.toplink.logging.AbstractSessionLog

TopLink 10.1.3+ SessionLog implementation that logs through Commons Logging.

The namespace used is "oracle.toplink.xxx", with the latter part being the TopLink log category ("sql"/"transaction"/etc). In case of no category given, "session" will be used as default. This allows for fine-grained filtering of log messages, for example through Log4J configuration.

Maps TopLink's SEVERE level to CL ERROR, TopLink's WARNING to CL WARN, TopLink's INFO to CL INFO, TopLink's CONFIG/FINE/FINER to CL DEBUG, and TopLink's FINEST to CL TRACE. This results in common CL log behavior: INFO logging only at startup; operation logging at DEBUG level. Debug logging can be further filtered according to categories: for example, activate Log4J DEBUG logging for category "oracle.toplink.sql" to see the generated SQL.

Note: This implementation will only work on TopLink 10.1.3 or higher, as it is built against TopLink's new SessionLog facilities in the `oracle.toplink.logging` package, supporting log categories.

Since:
  1.2
Author:
  Juergen Hoeller
See Also:
  `CommonsLoggingSessionLog904`, `oracle.toplink.logging.JavaLog`, `LocalSessionFactory.setSessionLog(oracle.toplink.sessions.SessionLog)`

Field Summary
`static String` `DEFAULT_NAMESPACE`
`static String` `DEFAULT_SEPARATOR`
`static String` `NAMESPACE_PREFIX`

Fields inherited from class oracle.toplink.logging.AbstractSessionLog
`CONFIG_PREFIX, CONNECTION_STRING, dateFormat, defaultLog, FINE_PREFIX, FINER_PREFIX, FINEST_PREFIX, INFO_PREFIX, level, session, sessionHashCode, sessionType, SEVERE_PREFIX, shouldLogExceptionStackTrace, shouldPrintDate, shouldPrintSession, shouldPrintThread, THREAD_STRING, TOPLINK_PREFIX, WARNING_PREFIX, writer`

Fields inherited from interface oracle.toplink.sessions.SessionLog
`ALL, CONFIG, FINE, FINER, FINEST, INFO, OFF, SEVERE, WARNING`

Constructor Summary
`CommonsLoggingSessionLog()`

Method Summary
`protected String` `getCategory(oracle.toplink.logging.SessionLogEntry entry)` Determine the log category for the given log entry.
`protected Throwable` `getException(oracle.toplink.logging.SessionLogEntry entry)` Extract the exception from the given log entry.
`protected String` `getMessageString(oracle.toplink.logging.SessionLogEntry entry)` Build the message String for the given log entry, including the supplemental details (session, connection) and the formatted message.
`String` `getSeparator()` Return the separator between TopLink's supplemental details (session, connection) and the log message itself.
`protected oracle.toplink.publicinterface.Session` `getSession(oracle.toplink.logging.SessionLogEntry entry)` Extract the exception from the given log entry.
`void` `log(oracle.toplink.logging.SessionLogEntry entry)`
`void` `setSeparator(String separator)` Specify the separator between TopLink's supplemental details (session, connection) and the log message itself.

Methods inherited from class oracle.toplink.logging.AbstractSessionLog

`buildDefaultDateFormat, buildSessionHashCode, buildSessionType, clone, config, fine, finer, finest, formatMessage, getConnectionString, getDateFormat, getDateString, getLevel, getLevel, getLog, getSession, getSessionString, getSessionString, getSupplementDetailString, getThreadString, getWriter, info, isOff, log, log, log, log, log, log, log, logThrowable, printPrefixString, setDateFormat, setLevel, setLevel, setLog, setSession, setShouldLogDebug, setShouldLogExceptions, setShouldLogExceptionStackTrace, setShouldPrintConnection, setShouldPrintDate, setShouldPrintSession, setShouldPrintThread, setWriter, severe, shouldLog, shouldLog, shouldLogDebug, shouldLogExceptions, shouldLogExceptionStackTrace, shouldPrintConnection, shouldPrintDate, shouldPrintSession, shouldPrintThread, throwing, warning`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### NAMESPACE_PREFIX

    public static final String NAMESPACE_PREFIX

See Also:
  Constant Field Values

### DEFAULT_NAMESPACE

    public static final String DEFAULT_NAMESPACE

See Also:
  Constant Field Values

### DEFAULT_SEPARATOR

    public static final String DEFAULT_SEPARATOR

See Also:
  Constant Field Values

Constructor Detail

### CommonsLoggingSessionLog

    public CommonsLoggingSessionLog()

Method Detail

### setSeparator

    public void setSeparator(String separator)

  Specify the separator between TopLink's supplemental details (session, connection) and the log message itself. Default is "--".

### getSeparator

    public String getSeparator()

  Return the separator between TopLink's supplemental details (session, connection) and the log message itself. Default is "--".

### log

    public void log(oracle.toplink.logging.SessionLogEntry entry)

  Specified by:
    `log` in class `oracle.toplink.logging.AbstractSessionLog`

### getCategory

    protected String getCategory(oracle.toplink.logging.SessionLogEntry entry)

  Determine the log category for the given log entry.

  If the entry carries a name space value, it will be appended to the "oracle.toplink." prefix; else, "oracle.toplink.session" will be used.

### getMessageString

    protected String getMessageString(oracle.toplink.logging.SessionLogEntry entry)

  Build the message String for the given log entry, including the supplemental details (session, connection) and the formatted message.

  See Also:
    `AbstractSessionLog.getSessionString(oracle.toplink.sessions.Session)`, `AbstractSessionLog.getConnectionString(oracle.toplink.internal.databaseaccess.Accessor)`, `AbstractSessionLog.formatMessage(oracle.toplink.logging.SessionLogEntry)`, `getSeparator()`

### getSession

    protected oracle.toplink.publicinterface.Session getSession(oracle.toplink.logging.SessionLogEntry entry)

  Extract the exception from the given log entry.

  The default implementation calls `SessionLogEntry.getSession` via reflection: The return type varies between TopLink 10.1.3 and 11 (`Session` vs `AbstractSession`, respectively).

### getException

    protected Throwable getException(oracle.toplink.logging.SessionLogEntry entry)

  Extract the exception from the given log entry.

  The default implementation calls `SessionLogEntry.getException` via reflection: The return type varies between TopLink 9.0.4 and 10.1.3 (`Exception` vs `Throwable`, respectively).

The Spring Framework

Copyright © 2002-2008 The Spring Framework.