3
我想從服務器上的客戶端應用程序接收日誌。 我已經嘗試了logback-examples項目中提供的標準'receiver'配置。如何使用Logback正確配置ServerSocketReceiver
<configuration debug="true">
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="CONSOLE" />
</root>
<receiver class="ch.qos.logback.classic.net.server.ServerSocketReceiver">
<port>6000</port>
</receiver>
</configuration>
的logback時分析此文件,它提供了以下錯誤:
16:28:09,067 |-ERROR in [email protected]:76 - no applicable action for [receiver], current pattern is [[configuration][receiver]]
16:28:09,068 |-ERROR in [email protected]:11 - no applicable action for [port], current pattern is [[configuration][receiver][port]]
我很茫然,什麼是錯誤的配置。 我有:SLF4J-API-1.7.5,的logback經典-1.0.9,的logback核-1.0.9
不出所料客戶端登錄失敗發送到服務器:
16:30:39,052 |-INFO in ch.qos.logback.classic.net.SocketAppender[SERVER] - Could not connect to remote logback server at [MAGENTA.comrad.local]. We will try again later. java.net.ConnectException: Connection refused: connect
at java.net.ConnectException: Connection refused: connect
at at java.net.PlainSocketImpl.socketConnect(Native Method)
at at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
這個特定的服務器是做這一項任務嗎?即接收消息並記錄它們?如果是這樣,你是否運行SimpleSocketServer?如果是這樣,則不需要定義Receiver。 –
我設法讓SimpleSocketServer工作。不過,我不想要一個單獨的獨立程序。我寧願使用現有的服務器應用程序進行日誌記錄。因此需要在logback.xml中將其配置爲接收者。 (假設我已經正確理解了該手冊) – giorgio