-
Notifications
You must be signed in to change notification settings - Fork 0
Logging
Rain Ramm edited this page Jan 7, 2025
·
3 revisions
Since version 3.2.0
Provides a custom implementation of de.siegmar.logbackgelf.GelfTcpAppender that silences all exceptions to allow the application to work regardless if logs can be sent to central server via GELF TCP.
Following dependencies have to be added as library does not provide transitive dependencies:
// https://mvnrepository.com/artifact/de.siegmar/logback-gelf
implementation group: 'de.siegmar', name: 'logback-gelf', version: '6.0.1'
Please note that using this appender means that log messages that cannot be sent to central server will be lost forever!
Recommended logback-spring.xml configuration
<configuration debug="true">
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
<springProfile name="local,development,development-test">
<root level="info">
<appender-ref ref="CONSOLE"/>
</root>
</springProfile>
<springProfile name="test,production">
<springProperty scope="context" name="environment" source="spring.profiles.active"/>
<springProperty scope="context" name="host" source="graylog.host"/>
<appender name="GRAYLOG_GELF_TCP" class="ee.bitweb.core.logging.SilencedGelfTcpAppender">
<graylogHost>\${host}</graylogHost>
<graylogPort>12201</graylogPort>
<maxRetries>2</maxRetries>
<retryDelay>0</retryDelay>
<connectTimeout>100</connectTimeout>
<socketTimeout>100</socketTimeout>
<encoder class="de.siegmar.logbackgelf.GelfEncoder">
<staticField>application:${rootProject.name}</staticField>
<staticField>environment:\${environment}</staticField>
<staticField>version:${rootProject.version}</staticField>
<staticField>build_number:${buildNumber}</staticField>
</encoder>
</appender>
<root level="info">
<appender-ref ref="GRAYLOG_GELF_TCP"/>
<appender-ref ref="CONSOLE"/>
</root>
</springProfile>
</configuration>