3

我想从服务器上的客户端应用程序接收日志。我已经尝试了 logback-examples 项目中提供的标准“接收器”配置。

<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 ch.qos.logback.core.joran.spi.Interpreter@19:76 - no applicable action for [receiver], current pattern is [[configuration][receiver]]
16:28:09,068 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@20:11 - no applicable action for [port], current pattern is [[configuration][receiver][port]]

我不知道配置有什么问题。我有:slf4j-api-1.7.5、logback-classic-1.0.9、logback-core-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)
4

1 回答 1

1

我收到错误的原因是我正在链接到 logback 1.0.9。接收器功能仅在 1.012 和更新版本中。

于 2013-10-22T02:13:42.580 回答