Logging

Gentics Mesh uses logback as the main logging facility. Logging can be configured using the config/logback.xml file.

Log Levels

Log levels can be configured per package/class

<logger name="io.vertx" level="INFO"/>
<logger name="com.gentics" level="INFO"/>

For all remaining loggers the root level will be used:

<root level="ERROR">

Possible values: ERROR, WARN, INFO, TRACE, DEBUG

Logging levels TRACE and DEBUG should only turned on for specific classes. Those levels will cause excessive log output.

Format

For the detailed pattern format description please refer to the Logback documentation. Below are some basic formatting tips:

Formatter Description Input Result

%logger{4}

Logger name, with the topmost 4 path names abbreviated

com.gentics.mesh.server.Server

c.g.m.s.Server

%date{dd MMM yyyy;HH:mm:ss.SSS}

Date formatter

2025-01-23 00:45:11,812

23 jan. 2025;00:45:11.812

%meshName

Mesh instance name

<Generated by Mesh or set through Mesh Options>

Gentics Mesh

%thread

Thread name

Thread-1

Thread-1

Examples

Stdout/Errout (default)

By default Gentics Mesh will log errors to errout and other messages to stdout.

logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">
	<conversionRule conversionWord="meshName" converterClass="com.gentics.mesh.log.MeshLogNameConverter"/>
	<statusListener class="ch.qos.logback.core.status.NopStatusListener" />

	<appender name="STDERR" class="ch.qos.logback.core.ConsoleAppender">
		<target>System.err</target>
		<encoder>
			<pattern>%d{HH:mm:ss.SSS} [%meshName] %-5level [%thread] - %msg%n</pattern>
		</encoder>
		<filter class="ch.qos.logback.classic.filter.LevelFilter">
			<level>ERROR</level>
			<onMatch>ACCEPT</onMatch>
			<onMismatch>DENY</onMismatch>
		</filter>
	</appender>

	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
		<encoder>
			<pattern>%d{HH:mm:ss.SSS} [%meshName] %-5level [%thread] - %msg%n</pattern>
		</encoder>
	</appender>

	<logger name="io.vertx" level="INFO"/>
	<logger name="com.gentics" level="INFO"/>

	<root level="ERROR">
		<appender-ref ref="STDOUT"/>
	</root>
</configuration>

Syslog

Syslog logging can be configured using the SyslogAppender. In this example messages will be logged to syslog and console out via the ConsoleAppender.

logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">
    <conversionRule conversionWord="meshName" converterClass="com.gentics.mesh.log.MeshLogNameConverter"/>
	<statusListener class="ch.qos.logback.core.status.NopStatusListener"/>

	<appender name="STDERR" class="ch.qos.logback.core.ConsoleAppender">
		<target>System.err</target>
		<encoder>
			<pattern> %d{HH:mm:ss.SSS} [%meshName] %-5level [%thread] - %msg%n</pattern>
		</encoder>
		<filter class="ch.qos.logback.classic.filter.LevelFilter">
			<level>ERROR</level>
			<onMatch>ACCEPT</onMatch>
			<onMismatch>DENY</onMismatch>
		</filter>
	</appender>

	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
		<encoder>
			<pattern>%d{HH:mm:ss.SSS} [%meshName] %-5level [%thread] - %msg%n</pattern>
		</encoder>
	</appender>

	<appender name="SYSLOG" class="ch.qos.logback.classic.net.SyslogAppender">
		<syslogHost>localhost</syslogHost>
		<facility>DAEMON</facility>
		<suffixPattern>[%thread] %logger %msg</suffixPattern>
	</appender>

	<logger name="io.vertx" level="INFO"/>
	<logger name="com.gentics" level="INFO"/>

	<root level="ERROR">
		<appender-ref ref="SYSLOG"/>
		<appender-ref ref="STDOUT"/>
	</root>
</configuration>

File logging

The following example uses the RollingFileAppender to log into the log/mesh.log file. The TimeBasedRollingPolicy will automatically create rotated log and compress old logs.

The INFO lines will be logged to the file and to stdout.

logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">
        <conversionRule conversionWord="meshName" converterClass="com.gentics.mesh.log.MeshLogNameConverter"/>

        <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
                <file>log/mesh.log</file>
                <target>System.err</target>
                <append>true</append>
                <encoder>
                        <pattern>%d [%meshName] %-5level [%file:%line] - %msg%n</pattern>
                </encoder>
                <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                        <fileNamePattern>log/mesh-%d{yyyy-MM}.log.gz</fileNamePattern>
                        <maxHistory>12</maxHistory>
                </rollingPolicy>
        </appender>
        <appender name="STDOUT-out" class="ch.qos.logback.core.ConsoleAppender">
                <target>System.err</target>
                <encoder>
                        <pattern>%d [%meshName] %-5level [%file:%line] - %msg%n</pattern>
                </encoder>
        </appender>

        <logger name="io.vertx" level="INFO"/>
        <logger name="com.gentics" level="INFO"/>

        <root level="ERROR">
                <appender-ref ref="FILE"/>
                <appender-ref ref="STDOUT-out"/>
        </root>
</configuration>
The TimeBasedRollingPolicy will control the rotation of logfiles based on the defined fileNamePattern.

ORM

Gentics Mesh uses Hibernate 6.5.x as an object relation mapping solution. There are a couple of Hibernate-related configurations available at Mesh Options, namely showSql for logging the actual SQL queries passed to the RDBMS, and formatSql for having these queries human-readable in the console.

More detailed information can be found in the Hibernate documentation.