Logging
Format
The log entries are structured as follows:
[DATE, format: JJJJ-MM-TT][Time, format: HH-MM-SS][Log level]{Process}[Component][Log message]
The following log levels are available:
| Log Level | What? | Criticality | Action? |
|---|---|---|---|
| DEBUG | For debugging only | None | None |
| INFO | Information | None | None |
| WARNING | Warning | Low | Check recommended |
| ERROR | Error | High | Check required |
| FATAL | Error which caused a process outage | Very high | Check urgently required |
Example:
2020-04-02 09:21:36.653 INFO {http-nio-0.0.0.0-8080-exec-49} [N.A] [GLOBAL] [ComponentContainerImpl] Starting component 'events-aggregator
If an error occurs, additional hints are displayed in the form of runtime exceptions which must be checked by the development partner, e.g.:
2020-04-02 04:40:31.685 ERROR {http-nio-0.0.0.0-8080-exec-2} [N.A] [GLOBAL] [ComponentContainerImpl] Can't start component [id=kafka-events-consumer, descriptor=[metadata=[metadata={Manifest-Version=1.0, Implementation-Title=Event Service - Kafka Connector, Implementation-Vendor=GK Software SE, GK-Package-Revision=8e603b31782fc89b70cc19de172f61cf075519a7, Specification-Version=5.15, Specification-Title=Event Service - Kafka Connector, Implementation-Vendor-Id=com.gk-software.gkr.event-service.server, Created-By=Apache Maven 3.3.9, X-Compile-Source-JDK=1.8, Implementation-Version=5.15.0-b04-SNAPSHOT, Specification-Vendor=GK Software SE, Built-By=hagent, Build-Jdk=1.8.0_111, X-Compile-Target-JDK=1.8, Implementation-URL=scm:git:ssh://git@gitlab.gk.gk-software.com/retail-services/event-service.git/event-service-server-parent/mod-kafka-connector}]], config=[configEntries=[[fileName=event-service], [fileName=event-service-firmware], [fileName=kafka-firmware], [key=event-service.kafka.consumer.topics, value=${event-service.kafka.consumer.topics.events},${event-service.kafka.consumer.topics.commands},${event-service.kafka.consumer.topics.states}], [key=event-service.kafka.consumer.id, value=${event-service.kafka.consumer.id}]]], mapping=[importBeanAliases={stompMessageDelegator=messageDelegator, deviceStatusRegistry=deviceStatusRegistry, eventsAggregator=eventsAggregator, deviceStatusProcessor=deviceStatusProcessor}], if=${event-service.broker.type}, containsToken=kafka]
org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.kafka.config.internalKafkaListenerEndpointRegistry'; nested exception is org.apache.kafka.common.KafkaException: Failed to construct kafka consumer
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185) ~[org.springframework.spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) ~[org.springframework.spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) ~[org.springframework.spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) ~[org.springframework.spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) ~[org.springframework.spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:894) ~[org.springframework.spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) ~[org.springframework.spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
Log files are permanently written. As soon as a defined file size is reached, the log files are packed and later deleted.
Activation
Configuration file:
<EVENT_SERVICE_ROOT>/config/parameter/log4j-logging.properties:
appender.root-local.enabled=true
appender.root-error-local.enabled=true
appender.root-info-local.enabled=true
appender.cloud.enabled=false
Location for Outputs
An application directory will be defined during installation. This application directory includes a /log directory which is used to store the log files.
In Apache Tomcat environments, it is possible to view or change this directory:
<GKRETAIL_ROOT_FOLDER>/tomcat/conf/Catalina/localhost/event-service.xmlThe default value for the storage location of the log file is, for example, on Linux:
/usr/local/gkretail/event-service/logConfiguration File Name, Max. File Size, etc.
The following log file is written:
- /log/ event-service-[node.id].log
File name:
- An unpacked log file has the following format: event-service-[node.id].log
- Packed log files have the following format: event-service-[node.id].log-[JJJJMMDD].zip
There are several parameters to influence the storage duration, file size, etc.:
- size: Max. file size. If it is exceeded, the file is packed and a new file is created.
- max, exceeds: Max. number of files. If it is exceeded, the files are deleted.
- age: Max. age of files. If it is exceeded, the corresponding files are deleted.
Configuration file
<EVENT_SERVICE_ROOT>/config/parameter/log4j2.xml:
<Policies>
<SizeBasedTriggeringPolicy size="20MB" />
</Policies>
<DefaultRolloverStrategy max="100">
<Delete basePath="${log.dir}">
<IfFileName glob="event-service-${node.id}*.log.zip">
<IfAny>
<IfLastModified age="10d" />
<IfAccumulatedFileCount exceeds="100" />
</IfAny>
</IfFileName>
</Delete>
</DefaultRolloverStrategy
Configuration of Outputted Log Levels
The log level can be set differently for the individual components. Therefore, it can be defined whether outputs of a particular category (=level) are written or not.
The following log levels are available:
- TRACE
- DEBUG
- INFO
- WARNING
- ERROR
- FATAL
If INFO is set, all messages of the level INFO and higher are outputted.
OFF disables the logging completely.
Configuration file
<EVENT_SERVICE_ROOT>/config/parameter/log4j-logging.properties, e.g.:
# Base log level definition
log.level.com.gk_software=DEBUG
# Data source tracer
log.level.com.gk_software.core.server.datasource.internal.tracing.PrintConnectionsOnErrorDataSourceExtension=TRACE
# ClassLoader cleanup TRACE for better memory leak detection
log.level.com.gk_software.core.server.resource.internal.cleaners=TRACE
# Too noisy with load-balancer (health check)
log.level.com.gk_software.core.common.security.server.internal.spring_security.common.filter.wrapper.SpringSecurityFilterWrapper=INFO
# Filter ERROR in TenantContextSwitchSetupFilter (when used with single tenant context)
log.level.com.gk_software.core.common.security.server.internal.spring_security.common.filter.TenantContextSwitchSetupFilter=FATAL
log.level.gk=DEBUG
# Spring AbstractBeanFactory is too noisy on default DEBUG level
log.level.gk.spring_ext.component.internal.ComponentBeanFactoryImpl=WARN
Log Output on the Console
In the configuration file <EVENT_SERVICE_ROOT>/config/parameter/log4j-logging.properties, it is possible to set which messages are displayed on the console.
In Tomcat, these messages are written to the Tomcat log. Messages are not redirected to this log, by default. The values for the setting are:
- false = Output suppressed
- true = Output allowed
Configuration file
<EVENT_SERVICE_ROOT>/config/parameter/log4j-logging.properties:
appender.system-out.enabled=false
appender.system-err.enabled=false