Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Development/296391"

(Design)
(Design)
Line 27: Line 27:
 
; <tt>public boolean shouldLog(int level, String categoryName)</tt> : Check if a message of the given log level would actually be logged under logging level for specified logging category.
 
; <tt>public boolean shouldLog(int level, String categoryName)</tt> : Check if a message of the given log level would actually be logged under logging level for specified logging category.
  
Unfortunately SLF4J API does not allow to set logging level to the SLF4J backend so log levels are stored in <tt>SLF4JLogger</tt> instance only. SLF4J backend logging level configuration is independent on <tt>setLevel</tt> methods and should be configutred to pass required logging levels.
+
Unfortunately SLF4J API does not allow to set logging level to the SLF4J backend so log levels are stored in <tt>SLF4JLogger</tt> instance only. Current logging level of the <tt>SLF4JLogger</tt> instance controls if SLF4J backend is called for provided <tt>SessionLogEntry</tt> instance or not. SLF4J backend logging level configuration is independent on <tt>setLevel</tt> methods and should be configutred to pass required logging levels.
  
 
EclipseLink and SLF4J log levels are mapped according to following table:
 
EclipseLink and SLF4J log levels are mapped according to following table:

Revision as of 06:29, 31 July 2015

EclipseLink Logger bridge over SLF4J

Document History

Date Author Version Description & Notes
20150730 Tomas Kraus 1.0 Initial draft started

Problem Statement

EclipseLink is missing Simple Logging Facade for Java (SLF4J) API support. SLF4J logging frameworks became quite popular and Bug# 296391 got many votes.

Design

SLF4J logger bridge is implemented as org.eclipse.persistence.logging.SLF4JLogger class. SLF4J logger bridge implements SessionLog interface to support EclipseLink logging API. Most of the code is already available in AbstractSessionLog so this class is extended to add bridge from SessionLog methods to SLF4J API. SLF4J logger class overwrites following methods:

public void log(SessionLogEntry logEntry) 
Calls SLF4J API logging method corresponding to message log level.
public int getLevel() 
Retrieve current log level for default EclipseLink logging category.
public int getLevel(String categoryName) 
Retrieve current log level for specified EclipseLink logging category.
public void setLevel(int level) 
Set the log level for default EclipseLink logging category.
public void setLevel(int level, String categoryName) 
Set the log level for specified EclipseLink logging category.
public boolean shouldLog(int level) 
Check if a message of the given log level would actually be logged under logging level for default logging category.
public boolean shouldLog(int level, String categoryName) 
Check if a message of the given log level would actually be logged under logging level for specified logging category.

Unfortunately SLF4J API does not allow to set logging level to the SLF4J backend so log levels are stored in SLF4JLogger instance only. Current logging level of the SLF4JLogger instance controls if SLF4J backend is called for provided SessionLogEntry instance or not. SLF4J backend logging level configuration is independent on setLevel methods and should be configutred to pass required logging levels.

EclipseLink and SLF4J log levels are mapped according to following table:

EclipseLink SLF4J
OFF N/A
SEVERE ERROR
WARNING WARN
INFO INFO
CONFIG
FINE DEBUG
FINER
FINEST TRACE
ALL

EclipseLink logging categories are mapped to SLF4J API name spaces as eclipselink.logging.<category_name>, e.g. eclipselink.logging.sql. This mapping is implemented in static Logger getLogger(LogCategory category) method of SLF4JLogger class.

Back to the top