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 >