Class ProcessDetailLogger
java.lang.Object
org.broadleafcommerce.common.logging.ProcessDetailLogger
Extra logging facility whose design intent is to handle detailed production logging for complex interactions.
Generally, the target of this logging is a rolling log file. This is intentionally separate from the standard system
logging, since this logging would likely be noisy in that context. Review of this log is useful to recreate complex
user scenarios, replicate error conditions and fix otherwise difficult to find bugs.
Configuration should be made in your implementation's logback.xml file (or other logging system config file,
if applicable). A sample logback configuration would be the following, which sets up a daily rolling log.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}spring.log}"/>
<property name="WORKFLOW_LOG_FILE" value="${WORKFLOW_LOG_FILE:-${java.io.tmpdir:-/tmp}/blc-logs/workflow.log}"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
<appender name="rollingDailyEnterpriseWorkflow" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${WORKFLOW_LOG_FILE}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${WORKFLOW_LOG_FILE}.%d{yyyy-MM-dd-HH-mm}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>[%-5level] %d{MM-dd-yyyy HH:mm:ss} %logger{35} - %message%n</pattern>
</encoder>
</appender>
<logger name="com.broadleafcommerce.enterprise.workflow.process.detail" level="DEBUG">
<appender-ref ref="rollingDailyEnterpriseWorkflow"/>
</logger>
</configuration>
If you duplicated the sample configuration exactly, you would provide the logger name "com.broadleafcommerce.enterprise.workflow.process.detail"
to the ProcessDetailLogger(String)
constructor.
- Author:
- Jeff Fischer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected boolean
protected int
Max number of members that will output in the log for a collection or array member passed as a template variableprotected static final SupportLogger
protected String
protected org.apache.commons.logging.Log
protected int
Max length of any String passed as a template variable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
int
void
init()
protected boolean
void
logProcessDetail
(String logContext, String message) Log a message to the configured log filevoid
logProcessDetail
(String logContext, String messageTemplate, Object... templateVariables) Log a message to the configured log filevoid
logProcessDetail
(String logContext, Throwable e, String message) Log a message to the configured log filevoid
logProcessDetail
(String logContext, Throwable e, String messageTemplate, Object... templateVariables) Log a message to the configured log fileprotected void
logProcessDetailMessage
(String logContext, Throwable e, String message) protected Object[]
processVariables
(Object[] variables) If an array or collection is passed in as part of the template variables, shorten the output if the length exceeds a threshold.void
setListTemplateVariableMaxMemberCount
(int listTemplateVariableMaxMemberCount) void
setStringTemplateVariableMaxLength
(int stringTemplateVariableMaxLength)
-
Field Details
-
LOGGER
-
processDetailLog
protected org.apache.commons.logging.Log processDetailLog -
logIdentifier
-
listTemplateVariableMaxMemberCount
protected int listTemplateVariableMaxMemberCountMax number of members that will output in the log for a collection or array member passed as a template variable -
stringTemplateVariableMaxLength
protected int stringTemplateVariableMaxLengthMax length of any String passed as a template variable -
ignoreNoProcessDetailLoggerConfiguration
@Value("${ignore.no.process.detail.logger.configuration:false}") protected boolean ignoreNoProcessDetailLoggerConfiguration -
disableAllProcessDetailLogging
@Value("${disable.all.process.detail.logging:false}") protected boolean disableAllProcessDetailLogging
-
-
Constructor Details
-
ProcessDetailLogger
Construct a logger- Parameters:
logIdentifier
- the logger name that should be used from the backing logging system configuration
-
-
Method Details
-
init
@PostConstruct public void init() -
isProperLogLevelEnabled
protected boolean isProperLogLevelEnabled() -
logProcessDetail
public void logProcessDetail(String logContext, String messageTemplate, Object... templateVariables) Log a message to the configured log file- Parameters:
logContext
- a fragment describing the context of this log message - will be prepended in the log. Can be null.messageTemplate
- A template string using the same approach employed byString.format(String, Object...)
templateVariables
- the variable used to replace the %s values in the template string
-
logProcessDetail
Log a message to the configured log file- Parameters:
logContext
- a fragment describing the context of this log message - will be prepended in the log. Can be null.message
- a message to log
-
logProcessDetail
public void logProcessDetail(String logContext, Throwable e, String messageTemplate, Object... templateVariables) Log a message to the configured log file- Parameters:
logContext
- a fragment describing the context of this log message - will be prepended in the log. Can be null.e
- an exception to include with the log message as a stack tracemessageTemplate
- A template string using the same approach employed byString.format(String, Object...)
templateVariables
- the variable used to replace the %s values in the template string
-
logProcessDetail
Log a message to the configured log file- Parameters:
logContext
- a fragment describing the context of this log message - will be prepended in the log. Can be null.e
- an exception to include with the log message as a stack tracemessage
- a message to log
-
logProcessDetailMessage
-
processVariables
If an array or collection is passed in as part of the template variables, shorten the output if the length exceeds a threshold. Also shorten long strings.- Parameters:
variables
- the template variables to process for the log- Returns:
- the processed list
-
getListTemplateVariableMaxMemberCount
public int getListTemplateVariableMaxMemberCount() -
setListTemplateVariableMaxMemberCount
public void setListTemplateVariableMaxMemberCount(int listTemplateVariableMaxMemberCount) -
getStringTemplateVariableMaxLength
public int getStringTemplateVariableMaxLength() -
setStringTemplateVariableMaxLength
public void setStringTemplateVariableMaxLength(int stringTemplateVariableMaxLength)
-