public abstract class BaseLogger extends Object
public class MyLogger extends BaseLogger {
public static MyLogger LOG = createLogger(MyLogger.class, "MYPROJ", "org.example", "01");
public void engineStarted(long currentTime) {
logInfo("100", "My super engine has started at '{}'", currentTime);
}
}
The logger can then be used in the following way:
LOG.engineStarted(System.currentTimeMilliseconds());This will print the following message:
INFO org.example - MYPROJ-01100 My super engine has started at '4234234523'
[PROJECT_CODE]-[COMPONENT_ID][MESSAGE_ID] messageExample:
MYPROJ-01100 My super engine has started at '4234234523'
| Modifier and Type | Field and Description |
|---|---|
protected String |
componentId
the component Id of the logger.
|
protected org.slf4j.Logger |
delegateLogger
the slf4j logger we delegate to
|
protected String |
projectCode
the project code of the logger
|
| Modifier | Constructor and Description |
|---|---|
protected |
BaseLogger() |
| Modifier and Type | Method and Description |
|---|---|
static <T extends BaseLogger> |
createLogger(Class<T> loggerClass,
String projectCode,
String name,
String componentId)
Creates a new instance of the
Logger. |
protected String |
exceptionMessage(String id,
String messageTemplate,
Object... parameters)
Prepares an exception message
|
protected String |
formatMessageTemplate(String id,
String messageTemplate)
Formats a message template
|
boolean |
isDebugEnabled() |
boolean |
isErrorEnabled() |
boolean |
isInfoEnabled() |
boolean |
isWarnEnabled() |
protected void |
logDebug(String id,
String messageTemplate,
Object... parameters)
Logs a 'DEBUG' message
|
protected void |
logError(String id,
String messageTemplate,
Object... parameters)
Logs an 'ERROR' message
|
protected void |
logInfo(String id,
String messageTemplate,
Object... parameters)
Logs an 'INFO' message
|
protected void |
logWarn(String id,
String messageTemplate,
Object... parameters)
Logs an 'WARN' message
|
protected org.slf4j.Logger delegateLogger
protected String projectCode
protected String componentId
public static <T extends BaseLogger> T createLogger(Class<T> loggerClass, String projectCode, String name, String componentId)
Logger.loggerClass - the type of the loggerprojectCode - the unique code for a complete project.name - the name of the slf4j logger to use.componentId - the unique id of the component.protected void logDebug(String id, String messageTemplate, Object... parameters)
id - the unique id of this log messagemessageTemplate - the message template to useparameters - a list of optional parametersprotected void logInfo(String id, String messageTemplate, Object... parameters)
id - the unique id of this log messagemessageTemplate - the message template to useparameters - a list of optional parametersprotected void logWarn(String id, String messageTemplate, Object... parameters)
id - the unique id of this log messagemessageTemplate - the message template to useparameters - a list of optional parametersprotected void logError(String id, String messageTemplate, Object... parameters)
id - the unique id of this log messagemessageTemplate - the message template to useparameters - a list of optional parameterspublic boolean isDebugEnabled()
public boolean isInfoEnabled()
public boolean isWarnEnabled()
public boolean isErrorEnabled()
protected String formatMessageTemplate(String id, String messageTemplate)
id - the id of the messagemessageTemplate - the message template to useprotected String exceptionMessage(String id, String messageTemplate, Object... parameters)
id - the id of the messagemessageTemplate - the message template to useparameters - the parameters for the message (optional)Copyright © 2014–2020 Camunda Services GmbH. All rights reserved.