Module org.eclipse.persistence.core
Package org.eclipse.persistence.logging
Class AbstractSessionLog
java.lang.Object
org.eclipse.persistence.logging.AbstractSessionLog
- All Implemented Interfaces:
Cloneable,SessionLog
- Direct Known Subclasses:
DefaultSessionLog,JavaLog,ServerLog,SLF4JLogger
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. By default, a singleton DefaultSessionLog is created.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static StringRepresents prefix to logged configprotected static final StringConnection stringprotected static StringThe pattern for formatting date-time in the log entries.protected static SessionLogRepresents the singleton SessionLogprotected static StringRepresents prefix to logged fineprotected static StringRepresents prefix to logged finerprotected static StringRepresents prefix to logged finestprotected static StringRepresents prefix to logged infoprotected intRepresents the log levelprotected static StringRepresents prefix to logged severeprotected static final StringThread stringprotected DateTimeFormatterFormatter used to print the current date/time.protected static StringCached TopLink prefix string.protected static StringRepresents prefix to logged warningprotected WriterRepresents the writer that will receive the formatted log entriesFields inherited from interface org.eclipse.persistence.logging.SessionLog
ALL, ALL_LABEL, CACHE, CONFIG, CONFIG_LABEL, CONNECTION, DBWS, DDL, DMS, EJB, EVENT, FINE, FINE_LABEL, FINER, FINER_LABEL, FINEST, FINEST_LABEL, INFO, INFO_LABEL, JPA, JPARS, loggerCatagories, METADATA, METAMODEL, MISC, MONITORING, MOXY, OFF, OFF_LABEL, PROCESSOR, PROPAGATION, PROPERTIES, QUERY, SEQUENCING, SERVER, SEVERE, SEVERE_LABEL, SQL, THREAD, TRANSACTION, WARNING, WARNING_LABEL, WEAVER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()INTERNAL: Each session owns its own session log because session is stored in the session logvoidLog a SessionLog.CONFIG level message.voidLog a SessionLog.CONFIG level message.voidLog a SessionLog.FINE level message.voidLog a SessionLog.FINE level message.voidLog a SessionLog.FINER level message.voidLog a SessionLog.FINER level message.voidLog a SessionLog.FINEST level message.voidLog a SessionLog.FINEST level message.protected StringformatMessage(SessionLogEntry entry) Return the formatted message based on the information from the given SessionLogEntry.protected StringgetConnectionString(int connectionId) Return the specified connection information.static intReturn the system default log level.intgetLevel()Return the log level.intReturn the log level for the category name space.Return the log level as a string value.static SessionLoggetLog()Return the singleton SessionLog.protected StringgetPrefixString(int level, String category) Get the prefix string for the EclipseLink loggingReturn the name of the session.protected StringReturn the supplement detail information including date, session, thread, connection, source class name and source method name.protected StringgetThreadString(Thread thread) Return the specified thread information.Return the specified date and/or time information in string.protected StringgetTimeStampString(TemporalAccessor temporalAccessor) Return the writer that will receive the formatted log entries.voidLog an SessionLog.INFO level message.voidLog an SessionLog.INFO level message.booleanisOff()INTERNAL: Check if the log level is set to off.voidLog a message.voidLog a message with one parameter.voidLog a message with parameters array.voidDeprecated, for removal: This API element is subject to removal in a future version.voidLog a message with two parameters.voidLog a message with three parameters.voidLog a message with four parameters.voidLog a message with one parameter for provided category.voidLog a message with parameters array for provided category.voidDeprecated, for removal: This API element is subject to removal in a future version.voidLog a message with two parameters for provided category.voidLog a message with three parameters for provided category.voidlog(int level, String category, String message, Object param1, Object param2, Object param3, Object param4) Log a message with four parameters for provided category.voidLog a message with message content supplier for provided category.voidLog a message with message content supplier.voidlogThrowable(int level, String category, Throwable throwable) Log a throwable with level.voidlogThrowable(int level, Throwable throwable) Log a throwable with level.protected voidprintPrefixString(int level, String category) Print the prefix string representing EclipseLink loggingvoidsetLevel(int level) Set the log level.voidSet the log level for the category name space.static voidsetLog(SessionLog sessionLog) Set the singleton SessionLog.voidsetSessionName(String sessionName) Set the name of the session.voidsetShouldDisplayData(Boolean shouldDisplayData) Turn printing of the bind parameters as part of the SQL log messages on or off explicitly.voidsetShouldLogExceptionStackTrace(boolean shouldLogExceptionStackTrace) Turn Exception stack trace logging on or off explicitly.voidsetShouldPrintConnection(boolean shouldPrintConnection) Turn printing of the connection as part of the log messages on or off explicitly.voidsetShouldPrintDate(boolean shouldPrintDate) Turn printing of the date as part of the log messages on or off explicitly.voidsetShouldPrintSession(boolean shouldPrintSession) Turn printing of the session as part of the log messages on or off explicitly.voidsetShouldPrintThread(boolean shouldPrintThread) Turn printing of the thread as part of the log messages on or off explicitly.voidsetTimeStampFormatter(DateTimeFormatter timeStampFormatter) Set the date-time format to be used when printing a log entry date.voidsetWriter(OutputStream outputstream) Set the writer that will receive the formatted log entries.voidSet the writer that will receive the formatted log entries.voidLog a SessionLog.SEVERE level message.voidLog a SessionLog.SEVERE level message.booleanWhether the SQL logging should log visible the bind parameters.booleanshouldLog(int level) Check if a message of the given level would actually be logged.booleanCheck if a message of the given level would actually be logged for the category name space.booleanWhether the Exception stack trace should be logged.booleanWhether the connection should be printed as part of the log messages.booleanWhether the date should be printed as part of the log messages.booleanWhether the session should be printed as part of the log messages.booleanWhether the thread should be printed as part of the log messages.voidLog a throwable at FINER level.static inttranslateStringToLoggingLevel(String loggingLevel) Translate the string value of the log level to the constant value.voidLog a SessionLog.WARNING level message.voidLog a SessionLog.WARNING level message.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.persistence.logging.SessionLog
log
-
Field Details
-
level
protected int levelRepresents the log level -
defaultLog
Represents the singleton SessionLog -
SEVERE_PREFIX
Represents prefix to logged severe -
WARNING_PREFIX
Represents prefix to logged warning -
INFO_PREFIX
Represents prefix to logged info -
CONFIG_PREFIX
Represents prefix to logged config -
FINE_PREFIX
Represents prefix to logged fine -
FINER_PREFIX
Represents prefix to logged finer -
FINEST_PREFIX
Represents prefix to logged finest -
TOPLINK_PREFIX
Cached TopLink prefix string. -
CONNECTION_STRING
Connection string- See Also:
-
THREAD_STRING
Thread string- See Also:
-
writer
Represents the writer that will receive the formatted log entries -
DATE_FORMAT_STR
The pattern for formatting date-time in the log entries. By default, set to"yyyy.MM.dd HH:mm:ss.SSS". -
timeStampFormatter
Formatter used to print the current date/time.
-
-
Constructor Details
-
AbstractSessionLog
protected AbstractSessionLog()Creates a new instance of AbstractSessionLog class.
-
-
Method Details
-
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.- Returns:
- the system default log level
-
getLevel
public int getLevel()Return the log level. It is used when session is not available.- Specified by:
getLevelin interfaceSessionLog- Returns:
- the log level
-
getLevelString
Return the log level as a string value.- Specified by:
getLevelStringin interfaceSessionLog- Returns:
- the current log level name
-
getLevel
Return the log level for the category name space.- Specified by:
getLevelin interfaceSessionLog- Parameters:
category- the string representation of a EclipseLink category, e.g. "sql", "transaction" ...- Returns:
- the log level
-
setLevel
public void setLevel(int level) Set the log level. It is used when session is not available.- Specified by:
setLevelin interfaceSessionLog- Parameters:
level- the new log level
-
setLevel
Set the log level for the category name space.- Specified by:
setLevelin interfaceSessionLog- Parameters:
level- the new log levelcategory- the string representation of an EclipseLink category, e.g. "sql", "transaction" ...
-
shouldLog
public boolean shouldLog(int level) Check if a message of the given level would actually be logged. It is used when session is not available.- Specified by:
shouldLogin interfaceSessionLog- Parameters:
level- the log request level- Returns:
- true if the given message level will be logged
-
shouldLog
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:
shouldLogin interfaceSessionLog- Parameters:
level- the log request levelcategory- the string representation of an EclipseLink category, e.g. "sql", "transaction" ...*- Returns:
- true if the given message level will be logged
-
getLog
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
Set the singleton SessionLog.- Parameters:
sessionLog- a SessionLog
-
getSessionName
Description copied from interface:SessionLogReturn the name of the session.- Specified by:
getSessionNamein interfaceSessionLog- Returns:
- the name of the session
-
setSessionName
Description copied from interface:SessionLogSet the name of the session.- Specified by:
setSessionNamein interfaceSessionLog- Parameters:
sessionName- the name of the session
-
log
Description copied from interface:SessionLogLog a message with message content supplier. See class description for the list of available levels.- Specified by:
login interfaceSessionLog- Parameters:
level- the log levelmessageSupplier- the message string supplier
-
log
Description copied from interface:SessionLogLog a message with message content supplier for provided category. See class description for the list of available levels and categories.- Specified by:
login interfaceSessionLog- Parameters:
level- the log levelcategory- the log categorymessageSupplier- the message string supplier
-
log
Description copied from interface:SessionLogLog 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.
- Specified by:
login interfaceSessionLog- Parameters:
level- the log levelmessage- the message string
-
log
Description copied from interface:SessionLogLog a message with one parameter. The message will be translated. See class description for the list of available levels.- Specified by:
login interfaceSessionLog- Parameters:
level- the log levelmessage- the message stringparam- the message parameter
-
log
Description copied from interface:SessionLogLog a message with one parameter for provided category. The message will be translated. See class description for the list of available levels and categories.- Specified by:
login interfaceSessionLog- Parameters:
level- the log levelcategory- the log categorymessage- the message stringparam- the message parameter
-
log
Description copied from interface:SessionLogLog a message with two parameters. The message will be translated. See class description for the list of available levels.- Specified by:
login interfaceSessionLog- Parameters:
level- the log levelmessage- the message stringparam1- the 1st message parameterparam2- the 2nd message parameter
-
log
Description copied from interface:SessionLogLog a message with two parameters for provided category. The message will be translated. See class description for the list of available levels and categories.- Specified by:
login interfaceSessionLog- Parameters:
level- the log levelcategory- the log categorymessage- the message stringparam1- the 1st message parameterparam2- the 2nd message parameter
-
log
Description copied from interface:SessionLogLog a message with three parameters. The message will be translated. See class description for the list of available levels.- Specified by:
login interfaceSessionLog- Parameters:
level- the log levelmessage- the message stringparam1- the 1st message parameterparam2- the 2nd message parameterparam3- the 3rd message parameter
-
log
public void log(int level, String category, String message, Object param1, Object param2, Object param3) Description copied from interface:SessionLogLog a message with three parameters for provided category. The message will be translated. See class description for the list of available levels and categories.- Specified by:
login interfaceSessionLog- Parameters:
level- the log levelcategory- the log categorymessage- the message stringparam1- the 1st message parameterparam2- the 2nd message parameterparam3- the 3rd message parameter
-
log
public void log(int level, String message, Object param1, Object param2, Object param3, Object param4) Description copied from interface:SessionLogLog a message with four parameters. The message will be translated. See class description for the list of available levels.- Specified by:
login interfaceSessionLog- Parameters:
level- the log levelmessage- the message stringparam1- the 1st message parameterparam2- the 2nd message parameterparam3- the 3rd message parameterparam4- the 4th message parameter
-
log
public void log(int level, String category, String message, Object param1, Object param2, Object param3, Object param4) Description copied from interface:SessionLogLog a message with four parameters for provided category. The message will be translated. See class description for the list of available levels and categories.- Specified by:
login interfaceSessionLog- Parameters:
level- the log levelcategory- the log categorymessage- the message stringparam1- the 1st message parameterparam2- the 2nd message parameterparam3- the 3rd message parameterparam4- the 4th message parameter
-
log
Description copied from interface:SessionLogLog a message with parameters array. The message will be translated. See class description for the list of available levels.- Specified by:
login interfaceSessionLog- Parameters:
level- the log levelmessage- the message stringparams- array of the message parameters
-
log
Description copied from interface:SessionLogLog a message with parameters array for provided category. The message will be translated. See class description for the list of available levels and categories.- Specified by:
login interfaceSessionLog- Parameters:
level- the log levelcategory- the log categorymessage- the message stringparams- array of the message parameters
-
log
@Deprecated(forRemoval=true, since="4.0.9") public void log(int level, String message, Object[] params, boolean shouldTranslate) Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:SessionLogLog a message with parameters array and translation flag. The message will be translated whenshouldTranslateis set totrue. See class description for the list of available levels.- Specified by:
login interfaceSessionLog- Parameters:
level- the log levelmessage- the message stringparams- array of the message parametersshouldTranslate- value oftrueif the message needs to be translated orfalseotherwise
-
log
@Deprecated(forRemoval=true, since="4.0.9") public void log(int level, String category, String message, Object[] params, boolean shouldTranslate) Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:SessionLogLog a message with parameters array and translation flag for provided category. The message will be translated whenshouldTranslateis set totrue. See class description for the list of available levels and categories.- Specified by:
login interfaceSessionLog- Parameters:
level- the log levelcategory- the log categorymessage- the message stringparams- array of the message parametersshouldTranslate- value oftrueif the message needs to be translated orfalseotherwise
-
shouldPrintSession
public boolean shouldPrintSession()Whether the session should be printed as part of the log messages. By default, the session is always printed, but can be explicitly turned off or on.- Specified by:
shouldPrintSessionin interfaceSessionLog- Returns:
- value of
truewhen the session should be printed as part of the log messages orfalseotherwise
-
setShouldPrintSession
public void setShouldPrintSession(boolean shouldPrintSession) Turn printing of the session as part of the log messages on or off explicitly.- Specified by:
setShouldPrintSessionin interfaceSessionLog- Parameters:
shouldPrintSession- value oftruewhen the session should be printed as part of the log messages orfalseotherwise
-
shouldPrintConnection
public boolean shouldPrintConnection()Whether the connection should be printed as part of the log messages. By default, the connection is always printed when available, but can be explicitly turned off or on.- Specified by:
shouldPrintConnectionin interfaceSessionLog- Returns:
- value of
truewhen the connection should be printed as part of the log messages orfalseotherwise
-
setShouldPrintConnection
public void setShouldPrintConnection(boolean shouldPrintConnection) Turn printing of the connection as part of the log messages on or off explicitly.- Specified by:
setShouldPrintConnectionin interfaceSessionLog- Parameters:
shouldPrintConnection- value oftruewhen the connection should be printed as part of the log messages orfalseotherwise
-
shouldLogExceptionStackTrace
public boolean shouldLogExceptionStackTrace()Whether the Exception stack trace should be logged. By default, the stack is logged for FINER or less (finest). The logging of the stack can be explicitly turned on or off.- Specified by:
shouldLogExceptionStackTracein interfaceSessionLog- Returns:
- value of
truewhen the Exception stack trace should be logged orfalseotherwise
-
setShouldLogExceptionStackTrace
public void setShouldLogExceptionStackTrace(boolean shouldLogExceptionStackTrace) Turn Exception stack trace logging on or off explicitly.- Specified by:
setShouldLogExceptionStackTracein interfaceSessionLog- Parameters:
shouldLogExceptionStackTrace- value oftruewhen the Exception stack trace should be logged orfalseotherwise
-
shouldDisplayData
public boolean shouldDisplayData()Whether the SQL logging should log visible the bind parameters. By default, the bind parameters are printed for FINE or less (finer, etc.). The printing of the bind parameters can be explicitly turned on or off.- Specified by:
shouldDisplayDatain interfaceSessionLog- Returns:
- value of
truewhen the bind parameters should be printed as part of the SQL log messages orfalseotherwise
-
setShouldDisplayData
Turn printing of the bind parameters as part of the SQL log messages on or off explicitly.- Specified by:
setShouldDisplayDatain interfaceSessionLog- Parameters:
shouldDisplayData- value oftruewhen the bind parameters should be printed as part of the SQL log messages orfalseotherwise
-
shouldPrintDate
public boolean shouldPrintDate()Whether the date should be printed as part of the log messages. By default, the date is always printed, but can be explicitly turned off or on.- Specified by:
shouldPrintDatein interfaceSessionLog- Returns:
- value of
truewhen the date should be printed as part of the log messages orfalseotherwise
-
setShouldPrintDate
public void setShouldPrintDate(boolean shouldPrintDate) Turn printing of the date as part of the log messages on or off explicitly.- Specified by:
setShouldPrintDatein interfaceSessionLog- Parameters:
shouldPrintDate- value oftruewhen the date should be printed as part of the log messages orfalseotherwise
-
shouldPrintThread
public boolean shouldPrintThread()Whether the thread should be printed as part of the log messages. By default, the thread is printed for FINE or less (finer, etc.). The printing of the thread can be explicitly turned on or off.- Specified by:
shouldPrintThreadin interfaceSessionLog- Returns:
- value of
truewhen the thread should be printed as part of the log messages orfalseotherwise
-
setShouldPrintThread
public void setShouldPrintThread(boolean shouldPrintThread) Turn printing of the thread as part of the log messages on or off explicitly.- Specified by:
setShouldPrintThreadin interfaceSessionLog- Parameters:
shouldPrintThread- value oftruewhen the thread should be printed as part of the log messages orfalseotherwise
-
getWriter
Return the writer that will receive the formatted log entries.- Specified by:
getWriterin interfaceSessionLog- Returns:
- the log writer
-
setWriter
Set the writer that will receive the formatted log entries.- Specified by:
setWriterin interfaceSessionLog- Parameters:
writer- the log writer
-
setWriter
Set the writer that will receive the formatted log entries.- Parameters:
outputstream- the log writer
-
getTimeStampFormatter
Return the specified date and/or time information in string. The format will be determined by the DateTimeFormatter settings. By default, the value of the DATE_FORMAT_STR pattern is used. -
getTimeStampString
-
getSupplementDetailString
Return the supplement detail information including date, session, thread, connection, source class name and source method name. -
getConnectionString
Return the specified connection information.- Parameters:
connectionId- the identifier of the datasource connection- Returns:
- connection string to be printed to the logs
-
getThreadString
Return the specified thread information. -
printPrefixString
Print the prefix string representing EclipseLink logging -
getPrefixString
Get the prefix string for the EclipseLink logging -
setTimeStampFormatter
Set the date-time format to be used when printing a log entry date.- Parameters:
timeStampFormatter- Formatter for printing time stamp in the log entry.
-
formatMessage
Return the formatted message based on the information from the given SessionLogEntry. The message will either be translated and formatted or formatted only depending on if the shouldTranslate flag is set to true of false. -
translateStringToLoggingLevel
Translate the string value of the log level to the constant value. If value isnullor invalid use the default.- Returns:
- the constant value of the provided log level String
-
throwing
Log a throwable at FINER level.- Specified by:
throwingin interfaceSessionLog- Parameters:
throwable- a Throwable
-
severe
Description copied from interface:SessionLogLog a SessionLog.SEVERE level message. The message will be translated.- Specified by:
severein interfaceSessionLog- Parameters:
message- the message key
-
severe
Description copied from interface:SessionLogLog a SessionLog.SEVERE level message. Logs a message with message content supplier.- Specified by:
severein interfaceSessionLog- Parameters:
messageSupplier- the message string supplier
-
warning
Description copied from interface:SessionLogLog a SessionLog.WARNING level message. The message will be translated.- Specified by:
warningin interfaceSessionLog- Parameters:
message- the message key
-
warning
Description copied from interface:SessionLogLog a SessionLog.WARNING level message. Logs a message with message content supplier.- Specified by:
warningin interfaceSessionLog- Parameters:
messageSupplier- the message string supplier
-
info
Description copied from interface:SessionLogLog an SessionLog.INFO level message. The message will be translated.- Specified by:
infoin interfaceSessionLog- Parameters:
message- the message key
-
info
Description copied from interface:SessionLogLog an SessionLog.INFO level message. Logs a message with message content supplier.- Specified by:
infoin interfaceSessionLog- Parameters:
messageSupplier- the message string supplier
-
config
Description copied from interface:SessionLogLog a SessionLog.CONFIG level message. The message will be translated.- Specified by:
configin interfaceSessionLog- Parameters:
message- the message key
-
config
Description copied from interface:SessionLogLog a SessionLog.CONFIG level message. Logs a message with message content supplier.- Specified by:
configin interfaceSessionLog- Parameters:
messageSupplier- the message string supplier
-
fine
Description copied from interface:SessionLogLog a SessionLog.FINE level message. The message will be translated.- Specified by:
finein interfaceSessionLog- Parameters:
message- the message key
-
fine
Description copied from interface:SessionLogLog a SessionLog.FINE level message. Logs a message with message content supplier.- Specified by:
finein interfaceSessionLog- Parameters:
messageSupplier- the message string supplier
-
finer
Description copied from interface:SessionLogLog a SessionLog.FINER level message. The message will be translated.- Specified by:
finerin interfaceSessionLog- Parameters:
message- the message key
-
finer
Description copied from interface:SessionLogLog a SessionLog.FINER level message. Logs a message with message content supplier.- Specified by:
finerin interfaceSessionLog- Parameters:
messageSupplier- the message string supplier
-
finest
Description copied from interface:SessionLogLog a SessionLog.FINEST level message. The message will be translated.- Specified by:
finestin interfaceSessionLog- Parameters:
message- the message key
-
finest
Description copied from interface:SessionLogLog a SessionLog.FINEST level message. Logs a message with message content supplier.- Specified by:
finestin interfaceSessionLog- Parameters:
messageSupplier- the message string supplier
-
logThrowable
Log a throwable with level.- Specified by:
logThrowablein interfaceSessionLog- Parameters:
level- the log request level valuethrowable- a Throwable
-
logThrowable
Log a throwable with level.- Specified by:
logThrowablein interfaceSessionLog- Parameters:
level- the log request level valuecategory- the log categorythrowable- a Throwable
-
isOff
public boolean isOff()INTERNAL: Check if the log level is set to off. -
clone
INTERNAL: Each session owns its own session log because session is stored in the session log- Specified by:
clonein interfaceSessionLog- Overrides:
clonein classObject- Returns:
- the cloned log
-