logback gelf
v6.1.0
Logback 附加程序用于发送具有零附加依赖性的 GELF(Graylog 扩展日志格式)消息。
简单的UDP配置:
< configuration >
< appender name = " GELF " class = " de.siegmar.logbackgelf.GelfUdpAppender " >
< graylogHost >localhost</ graylogHost >
< graylogPort >12201</ graylogPort >
</ appender >
< root level = " debug " >
< appender-ref ref = " GELF " />
</ root >
</ configuration >
简单的TCP配置:
< configuration >
< appender name = " GELF " class = " de.siegmar.logbackgelf.GelfTcpAppender " >
< graylogHost >localhost</ graylogHost >
< graylogPort >12201</ graylogPort >
</ appender >
<!-- Use AsyncAppender to prevent slowdowns -->
< appender name = " ASYNC GELF " class = " ch.qos.logback.classic.AsyncAppender " >
< appender-ref ref = " GELF " />
< neverBlock >true</ neverBlock >
</ appender >
< root level = " debug " >
< appender-ref ref = " ASYNC GELF " />
</ root >
</ configuration >
带有 TLS 配置的简单 TCP:
< configuration >
< appender name = " GELF " class = " de.siegmar.logbackgelf.GelfTcpTlsAppender " >
< graylogHost >localhost</ graylogHost >
< graylogPort >12201</ graylogPort >
</ appender >
<!-- Use AsyncAppender to prevent slowdowns -->
< appender name = " ASYNC GELF " class = " ch.qos.logback.classic.AsyncAppender " >
< appender-ref ref = " GELF " />
< neverBlock >true</ neverBlock >
</ appender >
< root level = " debug " >
< appender-ref ref = " ASYNC GELF " />
</ root >
</ configuration >
简单的HTTP配置:
< configuration >
< appender name = " GELF " class = " de.siegmar.logbackgelf.GelfHttpAppender " >
< uri >https://my.server:12201/gelf</ uri >
</ appender >
<!-- Use AsyncAppender to prevent slowdowns -->
< appender name = " ASYNC GELF " class = " ch.qos.logback.classic.AsyncAppender " >
< appender-ref ref = " GELF " />
< neverBlock >true</ neverBlock >
</ appender >
< root level = " debug " >
< appender-ref ref = " ASYNC GELF " />
</ root >
</ configuration >
在示例目录中查找更多高级示例。
de.siegmar.logbackgelf.GelfUdpAppender
de.siegmar.logbackgelf.MessageIdSupplier
。 de.siegmar.logbackgelf.GelfTcpAppender
de.siegmar.logbackgelf.GelfTcpTlsAppender
de.siegmar.logbackgelf.GelfHttpAppender
de.siegmar.logbackgelf.GelfEncoder
"%m%nopex"
。"%m%n"
。如果有任何问题,请启用调试模式并检查日志。
< configuration debug = " true " >
...
</ configuration >