Interface SessionLog

All Superinterfaces:
Cloneable
All Known Implementing Classes:
AbstractSessionLog, DefaultSessionLog, JavaLog, ServerLog, SLF4JLogger

public interface SessionLog extends Cloneable
SessionLog is the ever-so-simple interface used by EclipseLink to log generated messages and SQL. An implementor of this interface can be passed to the EclipseLink session (via the #setSessionLog(SessionLog) method); and all logging data will be passed through to the implementor via an instance of SessionLogEntry. This can be used to supplement debugging; or the entries could be stored in a database instead of logged to System.out, etc.

This class defines EclipseLink logging levels (that are used throughout EclipseLink code) with the following integer values:

Logging levels
 ALL  = 0
 FINEST  = 1
 FINER  = 2
 FINE  = 3
 CONFIG  = 4
 INFO  = 5
 WARNING = 6
 SEVERE  = 7
 OFF  = 8

In addition, EclipseLink categories used for logging name space are defined with the following String values:

Logging categories
 CACHE  = "cache"
 CONNECTION  = "connection"
 DMS  = "dms"
 EJB  = "ejb"
 EVENT  = "event"
 DBWS  = "dbws"
 JPARS  = "jpars"
 METADATA  = "metadata"
 METAMODEL  = "metamodel"
 MOXY  = "moxy"
 PROCESSOR  = "processor"
 PROPAGATION  = "propagation"
 PROPERTIES  = "properties"
 QUERY  = "query"
 SEQUENCING  = "sequencing"
 SERVER  = "server"
 SQL  = "sql"
 THREAD  = "thread"
 TRANSACTION  = "transaction"
 WEAVER  = "weaver"
Since:
TOPLink/Java 3.0
See Also:
  • Field Details

  • Method Details

    • log

      void log(SessionLogEntry entry)
      Log a message stored in SessionLogEntry. Write message content to a log writer, such as System.out or a file. EclipseLink will call this method whenever something.
      Parameters:
      entry - holds all the information to be written to the log
    • shouldLogExceptionStackTrace

      boolean shouldLogExceptionStackTrace()
      By default the stack trace is logged for SEVERE all the time and at FINER level for WARNING or less, this can be turned off.
    • shouldPrintDate

      boolean shouldPrintDate()
      By default the date is always printed, this can be turned off.
    • shouldPrintThread

      boolean shouldPrintThread()
      By default the thread is logged at FINE or less level, this can be turned off.
    • shouldDisplayData

      boolean shouldDisplayData()
      Return whether bind parameters should be displayed when logging SQL, default is true.
    • shouldPrintConnection

      boolean shouldPrintConnection()
      By default the connection is always printed whenever available, this can be turned off.
    • shouldPrintSession

      boolean shouldPrintSession()
      By default the Session is always printed whenever available, this can be turned off.
    • setShouldDisplayData

      void setShouldDisplayData(Boolean shouldDisplayData)
      Set whether bind parameters should be displayed when logging SQL.
    • setShouldLogExceptionStackTrace

      void setShouldLogExceptionStackTrace(boolean flag)
      By default stack trace is logged for SEVERE all the time and at FINER level for WARNING or less. This can be turned off.
    • setShouldPrintDate

      void setShouldPrintDate(boolean flag)
      By default date is printed, this can be turned off.
    • setShouldPrintThread

      void setShouldPrintThread(boolean flag)
      By default the thread is logged at FINE or less level, this can be turned off.
    • setShouldPrintConnection

      void setShouldPrintConnection(boolean flag)
      By default the connection is always printed whenever available, this can be turned off.
    • setShouldPrintSession

      void setShouldPrintSession(boolean flag)
      By default the Session is always printed whenever available, this can be turned off.
    • getWriter

      Writer getWriter()
      Returns the writer to which logged messages and SQL are written. If not set, this reference typically defaults to a writer on System.out. To enable logging, logMessages must be turned on in the session.
      Returns:
      the writer used for logging messages and SQL
    • setWriter

      void setWriter(Writer log)
      Sets the writer to which logged messages and SQL are written. If not set, this reference typically defaults to a writer on System.out. To enable logging, logMessages must be turned on in the session.
      Parameters:
      log - the writer to be used for logging messages and SQL
    • getLevel

      int getLevel()
      Returns the log level. Used when session is not available.
      Returns:
      the current log level
    • getLevelString

      String getLevelString()
      Returns the log level name.
      Returns:
      the current log level name
    • getLevel

      int getLevel(String category)
      Returns the log level for provided category. See class description for the list of available categories.
      Parameters:
      category - the log category
      Returns:
      the current log level
    • setLevel

      void setLevel(int level)
      Sets the log level. Used when session is not available. See class description for the list of available levels.
      Parameters:
      level - the log level
    • setLevel

      void setLevel(int level, String category)
      Sets the log level for provided category. See class description for the list of available levels and categories.
      Parameters:
      level - the log level
      category - the log category
    • shouldLog

      boolean shouldLog(int level)
      Whether a message of the given level would actually be logged. Used when session is not available. See class description for the list of available levels.
      Parameters:
      level - the log level
      Returns:
      value of true when message would be logged or false otherwise
    • shouldLog

      boolean shouldLog(int level, String category)
      Whether a message of the given level would actually be logged for provided category. See class description for the list of available levels and categories.
      Parameters:
      level - the log level
      category - the log category
      Returns:
      value of true when message would be logged or false otherwise
    • log

      void log(int level, Supplier<String> messageSupplier)
      Log a message with message content supplier. See class description for the list of available levels.
      Parameters:
      level - the log level
      messageSupplier - the message string supplier
    • log

      void log(int level, String category, Supplier<String> messageSupplier)
      Log a message with message content supplier for provided category. See class description for the list of available levels and categories.
      Parameters:
      level - the log level
      category - the log category
      messageSupplier - the message string supplier
    • log

      void log(int level, String message)
      Log a message.

      The message won't be translated. This method is intended for external use when logging messages are wanted within the EclipseLink output. See class description for the list of available levels.

      Parameters:
      level - the log level
      message - the message string
    • log

      void log(int level, String message, Object param)
      Log a message with one parameter. The message will be translated. See class description for the list of available levels.
      Parameters:
      level - the log level
      message - the message string
      param - the message parameter
    • log

      void log(int level, String category, String message, Object param)
      Log a message with one parameter for provided category. The message will be translated. See class description for the list of available levels and categories.
      Parameters:
      level - the log level
      category - the log category
      message - the message string
      param - the message parameter
    • log

      void log(int level, String message, Object param1, Object param2)
      Log a message with two parameters. The message will be translated. See class description for the list of available levels.
      Parameters:
      level - the log level
      message - the message string
      param1 - the 1st message parameter
      param2 - the 2nd message parameter
    • log

      void log(int level, String category, String message, Object param1, Object param2)
      Log a message with two parameters for provided category. The message will be translated. See class description for the list of available levels and categories.
      Parameters:
      level - the log level
      category - the log category
      message - the message string
      param1 - the 1st message parameter
      param2 - the 2nd message parameter
    • log

      void log(int level, String message, Object param1, Object param2, Object param3)
      Log a message with three parameters. The message will be translated. See class description for the list of available levels.
      Parameters:
      level - the log level
      message - the message string
      param1 - the 1st message parameter
      param2 - the 2nd message parameter
      param3 - the 3rd message parameter
    • log

      void log(int level, String category, String message, Object param1, Object param2, Object param3)
      Log a message with three parameters for provided category. The message will be translated. See class description for the list of available levels and categories.
      Parameters:
      level - the log level
      category - the log category
      message - the message string
      param1 - the 1st message parameter
      param2 - the 2nd message parameter
      param3 - the 3rd message parameter
    • log

      void log(int level, String message, Object param1, Object param2, Object param3, Object param4)
      Log a message with four parameters. The message will be translated. See class description for the list of available levels.
      Parameters:
      level - the log level
      message - the message string
      param1 - the 1st message parameter
      param2 - the 2nd message parameter
      param3 - the 3rd message parameter
      param4 - the 4th message parameter
    • log

      void log(int level, String category, String message, Object param1, Object param2, Object param3, Object param4)
      Log a message with four parameters for provided category. The message will be translated. See class description for the list of available levels and categories.
      Parameters:
      level - the log level
      category - the log category
      message - the message string
      param1 - the 1st message parameter
      param2 - the 2nd message parameter
      param3 - the 3rd message parameter
      param4 - the 4th message parameter
    • log

      void log(int level, String message, Object[] parameters)
      Log a message with parameters array. The message will be translated. See class description for the list of available levels.
      Parameters:
      level - the log level
      message - the message string
      parameters - array of the message parameters
    • log

      void log(int level, String category, String message, Object[] parameters)
      Log a message with parameters array for provided category. The message will be translated. See class description for the list of available levels and categories.
      Parameters:
      level - the log level
      category - the log category
      message - the message string
      parameters - array of the message parameters
    • log

      @Deprecated(forRemoval=true, since="4.0.9") void log(int level, String message, Object[] parameters, boolean shouldTranslate)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Log a message with parameters array and translation flag. The message will be translated when shouldTranslate is set to true. See class description for the list of available levels.
      Parameters:
      level - the log level
      message - the message string
      parameters - array of the message parameters
      shouldTranslate - value of true if the message needs to be translated or false otherwise
    • log

      @Deprecated(forRemoval=true, since="4.0.9") void log(int level, String category, String message, Object[] parameters, boolean shouldTranslate)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Log a message with parameters array and translation flag for provided category. The message will be translated when shouldTranslate is set to true. See class description for the list of available levels and categories.
      Parameters:
      level - the log level
      category - the log category
      message - the message string
      parameters - array of the message parameters
      shouldTranslate - value of true if the message needs to be translated or false otherwise
    • throwing

      void throwing(Throwable throwable)
      Log a Throwable at FINER level.
      Parameters:
      throwable - the Throwable
    • severe

      void severe(String message)
      Log a SEVERE level message. The message will be translated.
      Parameters:
      message - the message key
    • severe

      void severe(Supplier<String> messageSupplier)
      Log a SEVERE level message. Logs a message with message content supplier.
      Parameters:
      messageSupplier - the message string supplier
    • warning

      void warning(String message)
      Log a WARNING level message. The message will be translated.
      Parameters:
      message - the message key
    • warning

      void warning(Supplier<String> messageSupplier)
      Log a WARNING level message. Logs a message with message content supplier.
      Parameters:
      messageSupplier - the message string supplier
    • info

      void info(String message)
      Log an INFO level message. The message will be translated.
      Parameters:
      message - the message key
    • info

      void info(Supplier<String> messageSupplier)
      Log an INFO level message. Logs a message with message content supplier.
      Parameters:
      messageSupplier - the message string supplier
    • config

      void config(String message)
      Log a CONFIG level message. The message will be translated.
      Parameters:
      message - the message key
    • config

      void config(Supplier<String> messageSupplier)
      Log a CONFIG level message. Logs a message with message content supplier.
      Parameters:
      messageSupplier - the message string supplier
    • fine

      void fine(String message)
      Log a FINE level message. The message will be translated.
      Parameters:
      message - the message key
    • fine

      void fine(Supplier<String> messageSupplier)
      Log a FINE level message. Logs a message with message content supplier.
      Parameters:
      messageSupplier - the message string supplier
    • finer

      void finer(String message)
      Log a FINER level message. The message will be translated.
      Parameters:
      message - the message key
    • finer

      void finer(Supplier<String> messageSupplier)
      Log a FINER level message. Logs a message with message content supplier.
      Parameters:
      messageSupplier - the message string supplier
    • finest

      void finest(String message)
      Log a FINEST level message. The message will be translated.
      Parameters:
      message - the message key
    • finest

      void finest(Supplier<String> messageSupplier)
      Log a FINEST level message. Logs a message with message content supplier.
      Parameters:
      messageSupplier - the message string supplier
    • logThrowable

      void logThrowable(int level, Throwable throwable)
      Log a Throwable. See class description for the list of available levels.
      Parameters:
      level - the log level
      throwable - the Throwable
    • getSessionName

      String getSessionName()
      Return the name of the session.
      Returns:
      the name of the session
    • setSessionName

      void setSessionName(String sessionName)
      Set the name of the session.
      Parameters:
      sessionName - the name of the session
    • logThrowable

      void logThrowable(int level, String category, Throwable throwable)
      Log a Throwable for provided category. See class description for the list of available levels and categories.
      Parameters:
      level - the log level
      category - the log category
      throwable - the Throwable
    • clone

      Object clone()
      Clone the log.
      Returns:
      the cloned log