- All Superinterfaces:
Cloneable
- All Known Implementing Classes:
AbstractSessionLog,DefaultSessionLog,JavaLog,ServerLog,SLF4JLogger
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:
| 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:
| 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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intALLlog level.static final StringALLlog level name.static final StringCache logging category.static final intCONFIGlog level.static final StringCONFIGlog level name.static final StringConnection logging category.static final StringDBWS logging category.static final StringDDL logging category.static final StringDMS profiler name space.static final StringEJB logging category.static final StringEvent logging category.static final intFINElog level.static final StringFINElog level name.static final intFINERlog level.static final StringFINERlog level name.static final intFINESTlog level.static final StringFINESTlog level name.static final intINFOlog level.static final StringINFOlog level name.static final StringJPA logging category.static final StringJPA RS logging category.static final String[]An array of all logging categories.static final StringMetadata logging category.static final StringMetamodel logging category.static final StringMiscellaneous logging category.static final StringMonitoring logging category.static final StringMOXY logging category.static final intOFFlog level.static final StringOFFlog level name.static final StringModelGen logging category.static final StringPropagation logging category.static final StringProperties logging category.static final StringQuery logging category.static final StringSequencing logging category.static final StringServer logging category.static final intSEVERElog level.static final StringSEVERElog level name.static final StringSQL logging category.static final StringThread logging category.static final StringTransaction logging category.static final intWARNINGlog level.static final StringWARNINGlog level name.static final StringWeaving logging category. -
Method Summary
Modifier and TypeMethodDescriptionclone()Clone the log.voidLog a CONFIG level message.voidLog a CONFIG level message.voidLog a FINE level message.voidLog a FINE level message.voidLog a FINER level message.voidLog a FINER level message.voidLog a FINEST level message.voidLog a FINEST level message.intgetLevel()Returns the log level.intReturns the log level for provided category.Returns the log level name.Return the name of the session.Returns the writer to which logged messages and SQL are written.voidLog an INFO level message.voidLog an INFO level message.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.voidlog(SessionLogEntry entry) Log a message stored in SessionLogEntry.voidlogThrowable(int level, String category, Throwable throwable) Log a Throwable for provided category.voidlogThrowable(int level, Throwable throwable) Log a Throwable.voidsetLevel(int level) Sets the log level.voidSets the log level for provided category.voidsetSessionName(String sessionName) Set the name of the session.voidsetShouldDisplayData(Boolean shouldDisplayData) Set whether bind parameters should be displayed when logging SQL.voidsetShouldLogExceptionStackTrace(boolean flag) By default stack trace is logged for SEVERE all the time and at FINER level for WARNING or less.voidsetShouldPrintConnection(boolean flag) By default the connection is always printed whenever available, this can be turned off.voidsetShouldPrintDate(boolean flag) By default date is printed, this can be turned off.voidsetShouldPrintSession(boolean flag) By default the Session is always printed whenever available, this can be turned off.voidsetShouldPrintThread(boolean flag) By default the thread is logged at FINE or less level, this can be turned off.voidSets the writer to which logged messages and SQL are written.voidLog a SEVERE level message.voidLog a SEVERE level message.booleanReturn whether bind parameters should be displayed when logging SQL, default is true.booleanshouldLog(int level) Whether a message of the given level would actually be logged.booleanWhether a message of the given level would actually be logged for provided category.booleanBy default the stack trace is logged for SEVERE all the time and at FINER level for WARNING or less, this can be turned off.booleanBy default the connection is always printed whenever available, this can be turned off.booleanBy default the date is always printed, this can be turned off.booleanBy default the Session is always printed whenever available, this can be turned off.booleanBy default the thread is logged at FINE or less level, this can be turned off.voidvoidLog a WARNING level message.voidLog a WARNING level message.
-
Field Details
-
OFF
static final int OFFOFFlog level.- See Also:
-
OFF_LABEL
OFFlog level name. -
SEVERE
static final int SEVERESEVERElog level.- See Also:
-
SEVERE_LABEL
SEVERElog level name. -
WARNING
static final int WARNINGWARNINGlog level.- See Also:
-
WARNING_LABEL
WARNINGlog level name. -
INFO
static final int INFOINFOlog level.- See Also:
-
INFO_LABEL
INFOlog level name. -
CONFIG
static final int CONFIGCONFIGlog level.- See Also:
-
CONFIG_LABEL
CONFIGlog level name. -
FINE
static final int FINEFINElog level.- See Also:
-
FINE_LABEL
FINElog level name. -
FINER
static final int FINERFINERlog level.- See Also:
-
FINER_LABEL
FINERlog level name. -
FINEST
static final int FINESTFINESTlog level.- See Also:
-
FINEST_LABEL
FINESTlog level name. -
ALL
static final int ALLALLlog level.- See Also:
-
ALL_LABEL
ALLlog level name. -
SQL
SQL logging category.- See Also:
-
TRANSACTION
Transaction logging category.- See Also:
-
EVENT
Event logging category.- See Also:
-
CONNECTION
Connection logging category.- See Also:
-
QUERY
Query logging category.- See Also:
-
CACHE
Cache logging category.- See Also:
-
PROPAGATION
Propagation logging category.- See Also:
-
SEQUENCING
Sequencing logging category.- See Also:
-
JPA
JPA logging category.- See Also:
-
EJB
EJB logging category.- See Also:
-
DMS
DMS profiler name space.- See Also:
-
METADATA
Metadata logging category.- See Also:
-
MONITORING
Monitoring logging category.- See Also:
-
MISC
Miscellaneous logging category.- See Also:
-
MOXY
MOXY logging category.- See Also:
-
METAMODEL
Metamodel logging category.- See Also:
-
WEAVER
Weaving logging category.- See Also:
-
PROPERTIES
Properties logging category.- See Also:
-
SERVER
Server logging category.- See Also:
-
DDL
DDL logging category.- See Also:
-
DBWS
DBWS logging category.- See Also:
-
JPARS
JPA RS logging category.- See Also:
-
PROCESSOR
ModelGen logging category.- See Also:
-
THREAD
Thread logging category.- See Also:
-
loggerCatagories
An array of all logging categories.
-
-
Method Details
-
log
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
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,logMessagesmust be turned on in the session.- Returns:
- the writer used for logging messages and SQL
-
setWriter
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,logMessagesmust 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
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
Sets the log level for provided category. See class description for the list of available levels and categories.- Parameters:
level- the log levelcategory- 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
truewhen message would be logged orfalseotherwise
-
shouldLog
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 levelcategory- the log category- Returns:
- value of
truewhen message would be logged orfalseotherwise
-
log
Log a message with message content supplier. See class description for the list of available levels.- Parameters:
level- the log levelmessageSupplier- the message string supplier
-
log
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 levelcategory- the log categorymessageSupplier- the message string supplier
-
log
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 levelmessage- the message string
-
log
Log a message with one parameter. The message will be translated. See class description for the list of available levels.- Parameters:
level- the log levelmessage- the message stringparam- the message parameter
-
log
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 levelcategory- the log categorymessage- the message stringparam- the message parameter
-
log
Log a message with two parameters. The message will be translated. See class description for the list of available levels.- Parameters:
level- the log levelmessage- the message stringparam1- the 1st message parameterparam2- the 2nd message parameter
-
log
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 levelcategory- the log categorymessage- the message stringparam1- the 1st message parameterparam2- the 2nd message parameter
-
log
Log a message with three parameters. The message will be translated. See class description for the list of available levels.- Parameters:
level- the log levelmessage- the message stringparam1- the 1st message parameterparam2- the 2nd message parameterparam3- the 3rd message parameter
-
log
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 levelcategory- the log categorymessage- the message stringparam1- the 1st message parameterparam2- the 2nd message parameterparam3- the 3rd message parameter
-
log
Log a message with four parameters. The message will be translated. See class description for the list of available levels.- 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
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 levelcategory- the log categorymessage- the message stringparam1- the 1st message parameterparam2- the 2nd message parameterparam3- the 3rd message parameterparam4- the 4th message parameter
-
log
Log a message with parameters array. The message will be translated. See class description for the list of available levels.- Parameters:
level- the log levelmessage- the message stringparameters- array of the message parameters
-
log
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 levelcategory- the log categorymessage- the message stringparameters- 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 whenshouldTranslateis set totrue. See class description for the list of available levels.- Parameters:
level- the log levelmessage- the message stringparameters- array of the message parametersshouldTranslate- value oftrueif the message needs to be translated orfalseotherwise
-
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 whenshouldTranslateis set totrue. See class description for the list of available levels and categories.- Parameters:
level- the log levelcategory- the log categorymessage- the message stringparameters- array of the message parametersshouldTranslate- value oftrueif the message needs to be translated orfalseotherwise
-
throwing
- Parameters:
throwable- the Throwable
-
severe
Log a SEVERE level message. The message will be translated.- Parameters:
message- the message key
-
severe
Log a SEVERE level message. Logs a message with message content supplier.- Parameters:
messageSupplier- the message string supplier
-
warning
Log a WARNING level message. The message will be translated.- Parameters:
message- the message key
-
warning
Log a WARNING level message. Logs a message with message content supplier.- Parameters:
messageSupplier- the message string supplier
-
info
Log an INFO level message. The message will be translated.- Parameters:
message- the message key
-
info
Log an INFO level message. Logs a message with message content supplier.- Parameters:
messageSupplier- the message string supplier
-
config
Log a CONFIG level message. The message will be translated.- Parameters:
message- the message key
-
config
Log a CONFIG level message. Logs a message with message content supplier.- Parameters:
messageSupplier- the message string supplier
-
fine
Log a FINE level message. The message will be translated.- Parameters:
message- the message key
-
fine
Log a FINE level message. Logs a message with message content supplier.- Parameters:
messageSupplier- the message string supplier
-
finer
Log a FINER level message. The message will be translated.- Parameters:
message- the message key
-
finer
Log a FINER level message. Logs a message with message content supplier.- Parameters:
messageSupplier- the message string supplier
-
finest
Log a FINEST level message. The message will be translated.- Parameters:
message- the message key
-
finest
Log a FINEST level message. Logs a message with message content supplier.- Parameters:
messageSupplier- the message string supplier
-
logThrowable
Log a Throwable. See class description for the list of available levels.- Parameters:
level- the log levelthrowable- the Throwable
-
getSessionName
String getSessionName()Return the name of the session.- Returns:
- the name of the session
-
setSessionName
Set the name of the session.- Parameters:
sessionName- the name of the session
-
logThrowable
Log a Throwable for provided category. See class description for the list of available levels and categories.- Parameters:
level- the log levelcategory- the log categorythrowable- the Throwable
-
clone
Object clone()Clone the log.- Returns:
- the cloned log
-