Class AbstractSessionLog

  • All Implemented Interfaces:
    java.lang.Cloneable, SessionLog
    Direct Known Subclasses:
    DefaultSessionLog, JavaLog, ServerLog

    public abstract class AbstractSessionLog
    extends java.lang.Object
    implements SessionLog, java.lang.Cloneable
    Represents the abstract log that implements all the generic logging functions. It contains a singleton SessionLog that logs messages from outside any EclipseLink session. The singleton SessionLog can also be passed to an EclipseLink session when messages are logged through that session. When JDK1.4 is used, a singleton JavaLog is created. Otherwise a singleton DefaultSessionLog is created.
    See Also:
    SessionLog, SessionLogEntry, DefaultSessionLog, JavaLog
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractSessionLog()
      PUBLIC: Create a new AbstractSessionLog
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()
      INTERNAL: Each session owns its own session log because session is stored in the session log
      void config​(java.lang.String message)
      PUBLIC:
      void fine​(java.lang.String message)
      PUBLIC:
      void finer​(java.lang.String message)
      PUBLIC:
      void finest​(java.lang.String message)
      PUBLIC:
      java.text.DateFormat getDateFormat()
      PUBLIC: Return the date format to be used when printing a log entry date.
      static int getDefaultLoggingLevel()
      Return the system default log level.
      int getLevel()
      PUBLIC:
      int getLevel​(java.lang.String category)
      PUBLIC:
      java.lang.String getLevelString()
      PUBLIC:
      static SessionLog getLog()
      PUBLIC:
      Session getSession()
      PUBLIC:
      java.io.Writer getWriter()
      PUBLIC:
      void info​(java.lang.String message)
      PUBLIC:
      boolean isOff()
      INTERNAL: Check if the log level is set to off.
      void log​(int level, java.lang.String message)
      PUBLIC:
      void log​(int level, java.lang.String message, java.lang.Object param)
      PUBLIC:
      void log​(int level, java.lang.String message, java.lang.Object[] params)
      PUBLIC:
      void log​(int level, java.lang.String message, java.lang.Object[] params, boolean shouldTranslate)
      PUBLIC:
      void log​(int level, java.lang.String message, java.lang.Object param1, java.lang.Object param2)
      PUBLIC:
      void log​(int level, java.lang.String message, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3)
      PUBLIC:
      void log​(int level, java.lang.String message, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3, java.lang.Object param4)
      PUBLIC:
      void log​(int level, java.lang.String category, java.lang.String message, java.lang.Object param)
      PUBLIC:
      void log​(int level, java.lang.String category, java.lang.String message, java.lang.Object[] params)
      PUBLIC:
      void log​(int level, java.lang.String category, java.lang.String message, java.lang.Object[] params, boolean shouldTranslate)
      PUBLIC:
      void log​(int level, java.lang.String category, java.lang.String message, java.lang.Object param1, java.lang.Object param2)
      PUBLIC:
      void log​(int level, java.lang.String category, java.lang.String message, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3)
      PUBLIC:
      void log​(int level, java.lang.String category, java.lang.String message, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3, java.lang.Object param4)
      PUBLIC:
      abstract void log​(SessionLogEntry sessionLogEntry)
      PUBLIC:
      void logThrowable​(int level, java.lang.String category, java.lang.Throwable throwable)
      PUBLIC:
      void logThrowable​(int level, java.lang.Throwable throwable)
      PUBLIC:
      void setDateFormat​(java.text.DateFormat dateFormat)
      PUBLIC: Set the date format to be used when printing a log entry date.
      void setLevel​(int level)
      PUBLIC:
      void setLevel​(int level, java.lang.String category)
      PUBLIC:
      static void setLog​(SessionLog sessionLog)
      PUBLIC:
      void setSession​(Session session)
      PUBLIC:
      void setShouldDisplayData​(java.lang.Boolean shouldDisplayData)
      PUBLIC: Set whether bind parameters should be displayed when logging SQL.
      void setShouldLogExceptionStackTrace​(boolean shouldLogExceptionStackTrace)
      By default the stack is logged for FINER or less (finest).
      void setShouldPrintConnection​(boolean shouldPrintConnection)
      By default the connection is printed, this can be turned off.
      void setShouldPrintDate​(boolean shouldPrintDate)
      By default the date is always printed, but can be turned off.
      void setShouldPrintSession​(boolean shouldPrintSession)
      By default the session (and its connection is available) are printed, this can be turned off.
      void setShouldPrintThread​(boolean shouldPrintThread)
      By default the thread is logged for FINE or less (finer,etc.).
      void setWriter​(java.io.OutputStream outputstream)
      PUBLIC:
      void setWriter​(java.io.Writer writer)
      PUBLIC:
      void severe​(java.lang.String message)
      PUBLIC:
      boolean shouldDisplayData()
      PUBLIC: Return true if SQL logging should log visible bind parameters.
      boolean shouldLog​(int level)
      PUBLIC:
      boolean shouldLog​(int level, java.lang.String category)
      PUBLIC:
      boolean shouldLogExceptionStackTrace()
      By default the stack is logged for FINER or less (finest).
      boolean shouldPrintConnection()
      By default the connection is printed, this can be turned off.
      boolean shouldPrintDate()
      By default the date is always printed, but can be turned off.
      boolean shouldPrintSession()
      By default the session (and its connection is available) are printed, this can be turned off.
      boolean shouldPrintThread()
      By default the thread is logged for FINE or less (finer,etc.).
      void throwing​(java.lang.Throwable throwable)
      PUBLIC:
      static java.lang.String translateLoggingLevelToString​(int loggingLevel)
      INTERNAL: Translate the string value of the log level to the constant value.
      static int translateStringToLoggingLevel​(java.lang.String loggingLevel)
      INTERNAL: Translate the string value of the log level to the constant value.
      void warning​(java.lang.String message)
      PUBLIC:
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractSessionLog

        public AbstractSessionLog()
        PUBLIC: Create a new AbstractSessionLog
    • Method Detail

      • getDefaultLoggingLevel

        public static int getDefaultLoggingLevel()
        Return the system default log level. This is based on the System property "eclipselink.logging.level", or INFO if not set.
      • getLevel

        public int getLevel()
        PUBLIC:

        Return the log level. It is used when session is not available.

        Specified by:
        getLevel in interface SessionLog
        Returns:
        the log level
      • getLevelString

        public java.lang.String getLevelString()
        PUBLIC:

        Return the log level as a string value.

        Specified by:
        getLevelString in interface SessionLog
      • getLevel

        public int getLevel​(java.lang.String category)
        PUBLIC:

        Return the log level for the category name space.

        Specified by:
        getLevel in interface SessionLog
        Parameters:
        category - the string representation of a EclipseLink category, e.g. "sql", "transaction" ...
        Returns:
        the log level
      • setLevel

        public void setLevel​(int level)
        PUBLIC:

        Set the log level. It is used when session is not available.

        Specified by:
        setLevel in interface SessionLog
        Parameters:
        level - the new log level
      • setLevel

        public void setLevel​(int level,
                             java.lang.String category)
        PUBLIC:

        Set the log level for the category name space.

        Specified by:
        setLevel in interface SessionLog
        Parameters:
        level - the new log level
        category - the string representation of an EclipseLink category, e.g. "sql", "transaction" ...
      • shouldDisplayData

        public boolean shouldDisplayData()
        PUBLIC: Return true if SQL logging should log visible bind parameters. If the shouldDisplayData is not set, check the session log level and return true for a level greater than CONFIG.
        Specified by:
        shouldDisplayData in interface SessionLog
      • shouldLog

        public boolean shouldLog​(int level)
        PUBLIC:

        Check if a message of the given level would actually be logged. It is used when session is not available.

        Specified by:
        shouldLog in interface SessionLog
        Parameters:
        level - the log request level
        Returns:
        true if the given message level will be logged
      • shouldLog

        public boolean shouldLog​(int level,
                                 java.lang.String category)
        PUBLIC:

        Check if a message of the given level would actually be logged for the category name space. !isOff() is checked to screen out the possibility when both log level and log request level are set to OFF.

        Specified by:
        shouldLog in interface SessionLog
        Parameters:
        level - the log request level
        category - the string representation of an EclipseLink category, e.g. "sql", "transaction" ...*
        Returns:
        true if the given message level will be logged
      • getLog

        public static SessionLog getLog()
        PUBLIC:

        Return the singleton SessionLog. If the singleton SessionLog does not exist, a new one is created based on the version of JDK being used from the Version class.

        Returns:
        the singleton SessionLog
      • setLog

        public static void setLog​(SessionLog sessionLog)
        PUBLIC:

        Set the singleton SessionLog.

        Parameters:
        sessionLog - a SessionLog
      • getSession

        public Session getSession()
        PUBLIC:

        Get the session.

        Specified by:
        getSession in interface SessionLog
        Returns:
        session
      • setSession

        public void setSession​(Session session)
        PUBLIC:

        Set the session.

        Specified by:
        setSession in interface SessionLog
        Parameters:
        session - a Session
      • log

        public void log​(int level,
                        java.lang.String message)
        PUBLIC:

        Log a message that does not need to be translated. This method is intended for external use when logging messages are required within the EclipseLink output.

        Specified by:
        log in interface SessionLog
        Parameters:
        level - the log request level value
        message - the string message - this should not be a bundle key
      • log

        public void log​(int level,
                        java.lang.String message,
                        java.lang.Object param)
        PUBLIC:

        Log a message with one parameter that needs to be translated.

        Specified by:
        log in interface SessionLog
        Parameters:
        level - the log request level value
        message - the string message
        param - a parameter of the message
      • log

        public void log​(int level,
                        java.lang.String category,
                        java.lang.String message,
                        java.lang.Object param)
        PUBLIC:

        Log a message with one parameter that needs to be translated.

        Specified by:
        log in interface SessionLog
        Parameters:
        level - the log request level value
        message - the string message
        param - a parameter of the message
      • log

        public void log​(int level,
                        java.lang.String message,
                        java.lang.Object param1,
                        java.lang.Object param2)
        PUBLIC:

        Log a message with two parameters that needs to be translated.

        Specified by:
        log in interface SessionLog
        Parameters:
        level - the log request level value
        message - the string message
        param1 - a parameter of the message
        param2 - second parameter of the message
      • log

        public void log​(int level,
                        java.lang.String category,
                        java.lang.String message,
                        java.lang.Object param1,
                        java.lang.Object param2)
        PUBLIC:

        Log a message with two parameters that needs to be translated.

        Specified by:
        log in interface SessionLog
        Parameters:
        level - the log request level value
        message - the string message
        param1 - a parameter of the message
        param2 - second parameter of the message
      • log

        public void log​(int level,
                        java.lang.String message,
                        java.lang.Object param1,
                        java.lang.Object param2,
                        java.lang.Object param3)
        PUBLIC:

        Log a message with three parameters that needs to be translated.

        Specified by:
        log in interface SessionLog
        Parameters:
        level - the log request level value
        message - the string message
        param1 - a parameter of the message
        param2 - second parameter of the message
        param3 - third parameter of the message
      • log

        public void log​(int level,
                        java.lang.String category,
                        java.lang.String message,
                        java.lang.Object param1,
                        java.lang.Object param2,
                        java.lang.Object param3)
        PUBLIC:

        Log a message with three parameters that needs to be translated.

        Specified by:
        log in interface SessionLog
        Parameters:
        level - the log request level value
        message - the string message
        param1 - a parameter of the message
        param2 - second parameter of the message
        param3 - third parameter of the message
      • log

        public void log​(int level,
                        java.lang.String message,
                        java.lang.Object param1,
                        java.lang.Object param2,
                        java.lang.Object param3,
                        java.lang.Object param4)
        PUBLIC:

        Log a message with four parameters that needs to be translated.

        Specified by:
        log in interface SessionLog
        Parameters:
        level - the log request level value
        message - the string message
        param1 - a parameter of the message
        param2 - second parameter of the message
        param3 - third parameter of the message
        param4 - third parameter of the message
      • log

        public void log​(int level,
                        java.lang.String category,
                        java.lang.String message,
                        java.lang.Object param1,
                        java.lang.Object param2,
                        java.lang.Object param3,
                        java.lang.Object param4)
        PUBLIC:

        Log a message with four parameters that needs to be translated.

        Specified by:
        log in interface SessionLog
        Parameters:
        level - the log request level value
        message - the string message
        param1 - a parameter of the message
        param2 - second parameter of the message
        param3 - third parameter of the message
        param4 - third parameter of the message
      • log

        public void log​(int level,
                        java.lang.String message,
                        java.lang.Object[] params)
        PUBLIC:

        Log a message with an array of parameters that needs to be translated.

        Specified by:
        log in interface SessionLog
        Parameters:
        level - the log request level value
        message - the string message
        params - array of parameters to the message
      • log

        public void log​(int level,
                        java.lang.String category,
                        java.lang.String message,
                        java.lang.Object[] params)
        PUBLIC:

        Log a message with an array of parameters that needs to be translated.

        Specified by:
        log in interface SessionLog
        Parameters:
        level - the log request level value
        message - the string message
        params - array of parameters to the message
      • log

        public void log​(int level,
                        java.lang.String message,
                        java.lang.Object[] params,
                        boolean shouldTranslate)
        PUBLIC:

        Log a message. shouldTranslate determines if the message needs to be translated.

        Specified by:
        log in interface SessionLog
        Parameters:
        level - the log request level
        message - the string message
        params - array of parameters to the message
        shouldTranslate - true if the message needs to be translated
      • log

        public void log​(int level,
                        java.lang.String category,
                        java.lang.String message,
                        java.lang.Object[] params,
                        boolean shouldTranslate)
        PUBLIC:

        Log a message. shouldTranslate determines if the message needs to be translated.

        Specified by:
        log in interface SessionLog
        Parameters:
        level - the log request level
        message - the string message
        category - the log category
        params - array of parameters to the message
        shouldTranslate - true if the message needs to be translated
      • log

        public abstract void log​(SessionLogEntry sessionLogEntry)
        PUBLIC:

        Log a SessionLogEntry

        Specified by:
        log in interface SessionLog
        Parameters:
        sessionLogEntry - SessionLogEntry that holds all the information for an EclipseLink logging event
      • shouldPrintSession

        public boolean shouldPrintSession()
        By default the session (and its connection is available) are printed, this can be turned off.
        Specified by:
        shouldPrintSession in interface SessionLog
      • setShouldPrintSession

        public void setShouldPrintSession​(boolean shouldPrintSession)
        By default the session (and its connection is available) are printed, this can be turned off.
        Specified by:
        setShouldPrintSession in interface SessionLog
      • shouldPrintConnection

        public boolean shouldPrintConnection()
        By default the connection is printed, this can be turned off.
        Specified by:
        shouldPrintConnection in interface SessionLog
      • setShouldPrintConnection

        public void setShouldPrintConnection​(boolean shouldPrintConnection)
        By default the connection is printed, this can be turned off.
        Specified by:
        setShouldPrintConnection in interface SessionLog
      • shouldLogExceptionStackTrace

        public boolean shouldLogExceptionStackTrace()
        By default the stack is logged for FINER or less (finest). The logging of the stack can also be explicitly turned on or off.
        Specified by:
        shouldLogExceptionStackTrace in interface SessionLog
      • setShouldDisplayData

        public void setShouldDisplayData​(java.lang.Boolean shouldDisplayData)
        PUBLIC: Set whether bind parameters should be displayed when logging SQL.
        Specified by:
        setShouldDisplayData in interface SessionLog
      • setShouldLogExceptionStackTrace

        public void setShouldLogExceptionStackTrace​(boolean shouldLogExceptionStackTrace)
        By default the stack is logged for FINER or less (finest). The logging of the stack can also be explicitly turned on or off.
        Specified by:
        setShouldLogExceptionStackTrace in interface SessionLog
      • shouldPrintDate

        public boolean shouldPrintDate()
        By default the date is always printed, but can be turned off.
        Specified by:
        shouldPrintDate in interface SessionLog
      • setShouldPrintDate

        public void setShouldPrintDate​(boolean shouldPrintDate)
        By default the date is always printed, but can be turned off.
        Specified by:
        setShouldPrintDate in interface SessionLog
      • shouldPrintThread

        public boolean shouldPrintThread()
        By default the thread is logged for FINE or less (finer,etc.). The logging of the thread can also be explicitly turned on or off.
        Specified by:
        shouldPrintThread in interface SessionLog
      • setShouldPrintThread

        public void setShouldPrintThread​(boolean shouldPrintThread)
        By default the thread is logged for FINE or less (finer,etc.). The logging of the thread can also be explicitly turned on or off.
        Specified by:
        setShouldPrintThread in interface SessionLog
      • getWriter

        public java.io.Writer getWriter()
        PUBLIC:

        Return the writer that will receive the formatted log entries.

        Specified by:
        getWriter in interface SessionLog
        Returns:
        the log writer
      • setWriter

        public void setWriter​(java.io.Writer writer)
        PUBLIC:

        Set the writer that will receive the formatted log entries.

        Specified by:
        setWriter in interface SessionLog
        Parameters:
        writer - the log writer
      • setWriter

        public void setWriter​(java.io.OutputStream outputstream)
        PUBLIC:

        Set the writer that will receive the formatted log entries.

        Parameters:
        outputstream - the log writer
      • getDateFormat

        public java.text.DateFormat getDateFormat()
        PUBLIC: Return the date format to be used when printing a log entry date.
        Returns:
        the date format
      • setDateFormat

        public void setDateFormat​(java.text.DateFormat dateFormat)
        PUBLIC: Set the date format to be used when printing a log entry date.

        Note: the JDK's java.text.SimpleDateFormat is NOT thread-safe.
        The user is strongly advised to consider using Apache Commons
        org.apache.commons.lang.time.FastDateFormat instead.

        Parameters:
        dateFormat - java.text.DateFormat
      • translateStringToLoggingLevel

        public static int translateStringToLoggingLevel​(java.lang.String loggingLevel)
        INTERNAL: Translate the string value of the log level to the constant value. If value is null or invalid use the default.
      • throwing

        public void throwing​(java.lang.Throwable throwable)
        PUBLIC:

        Log a throwable at FINER level.

        Specified by:
        throwing in interface SessionLog
        Parameters:
        throwable - a Throwable
      • severe

        public void severe​(java.lang.String message)
        PUBLIC:

        This method is called when a severe level message needs to be logged. The message will be translated

        Specified by:
        severe in interface SessionLog
        Parameters:
        message - the message key
      • warning

        public void warning​(java.lang.String message)
        PUBLIC:

        This method is called when a warning level message needs to be logged. The message will be translated

        Specified by:
        warning in interface SessionLog
        Parameters:
        message - the message key
      • info

        public void info​(java.lang.String message)
        PUBLIC:

        This method is called when a info level message needs to be logged. The message will be translated

        Specified by:
        info in interface SessionLog
        Parameters:
        message - the message key
      • config

        public void config​(java.lang.String message)
        PUBLIC:

        This method is called when a config level message needs to be logged. The message will be translated

        Specified by:
        config in interface SessionLog
        Parameters:
        message - the message key
      • fine

        public void fine​(java.lang.String message)
        PUBLIC:

        This method is called when a fine level message needs to be logged. The message will be translated

        Specified by:
        fine in interface SessionLog
        Parameters:
        message - the message key
      • finer

        public void finer​(java.lang.String message)
        PUBLIC:

        This method is called when a finer level message needs to be logged. The message will be translated

        Specified by:
        finer in interface SessionLog
        Parameters:
        message - the message key
      • finest

        public void finest​(java.lang.String message)
        PUBLIC:

        This method is called when a finest level message needs to be logged. The message will be translated

        Specified by:
        finest in interface SessionLog
        Parameters:
        message - the message key
      • logThrowable

        public void logThrowable​(int level,
                                 java.lang.Throwable throwable)
        PUBLIC:

        Log a throwable with level.

        Specified by:
        logThrowable in interface SessionLog
        Parameters:
        level - the log request level value
        throwable - a Throwable
      • logThrowable

        public void logThrowable​(int level,
                                 java.lang.String category,
                                 java.lang.Throwable throwable)
        PUBLIC:

        Log a throwable with level.

        Specified by:
        logThrowable in interface SessionLog
        Parameters:
        level - the log request level value
        throwable - a Throwable
      • isOff

        public boolean isOff()
        INTERNAL: Check if the log level is set to off.
      • clone

        public 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 SessionLog
      • translateLoggingLevelToString

        public static java.lang.String translateLoggingLevelToString​(int loggingLevel)
        INTERNAL: Translate the string value of the log level to the constant value. If value is null or invalid use the default.