由以下原因引起:java.io.IOException:长度1279873876超出限制:26

时间:2018-10-10 14:37:16

标签: java sockets socket.io mule log4j2

我正在尝试在log4j中实现套接字附加程序,以便将我的日志直接写入主机应用程序。

下面是我的log4j配置,

    <?xml version="1.0" encoding="UTF-8"?>
  <Configuration status="trace" monitorInterval="5">
    <Appenders>
      <Socket name="socket" host="localhost" port="8085" reconnectDelayMillis="30000" protocol="TCP" immediateFlush="true">
        <PatternLayout></PatternLayout>
      </Socket>
      <Async name="SplunkAsync">
        <AppenderRef ref="socket"/>
      </Async>
    </Appenders>
    <Loggers>
      <Root level="warn">
        <AppenderRef ref="SplunkAsync"/>
      </Root>
      <Logger name="org.mule.module.http.internal.HttpMessageLogger" level="debug" additivity="false">
        <AppenderRef ref="SplunkAsync"/>
      </Logger>
  </Loggers>
</Configuration>

我还尝试了从Java程序向此localhost 8085端口发送消息的方法,效果很好。

但是使用log4j追加器,我得到下面的异常,

  

原因:java.io.IOException:长度1279873876超出限制:26

ERROR 2018-10-10 19:55:52,897 [[tcplistner].connector.tcp.mule.default.receiver.02] org.mule.exception.DefaultSystemExceptionStrategy: Caught exception in Exception Strategy: An error occurred while verifying your connection.  You may not be using a consistent protocol on your TCP transport. Please read the documentation for the TCP transport, paying particular attention to the protocol parameter.
java.io.IOException: An error occurred while verifying your connection.  You may not be using a consistent protocol on your TCP transport. Please read the documentation for the TCP transport, paying particular attention to the protocol parameter.
    at org.mule.transport.tcp.protocols.SafeProtocol.helpUser(SafeProtocol.java:110) ~[mule-transport-tcp-3.8.5.jar:3.8.5]
    at org.mule.transport.tcp.protocols.SafeProtocol.assertSiblingSafe(SafeProtocol.java:83) ~[mule-transport-tcp-3.8.5.jar:3.8.5]
    at org.mule.transport.tcp.protocols.SafeProtocol.read(SafeProtocol.java:37) ~[mule-transport-tcp-3.8.5.jar:3.8.5]
    at org.mule.transport.tcp.TcpMessageReceiver$TcpWorker.getNextMessage(TcpMessageReceiver.java:367) ~[mule-transport-tcp-3.8.5.jar:3.8.5]
    at org.mule.transport.AbstractReceiverResourceWorker.doRun(AbstractReceiverResourceWorker.java:41) ~[mule-core-3.8.5.jar:3.8.5]
    at org.mule.transport.AbstractReceiverWorker.run(AbstractReceiverWorker.java:66) ~[mule-core-3.8.5.jar:3.8.5]
    at org.mule.transport.TrackingWorkManager$TrackeableWork.run(TrackingWorkManager.java:267) ~[mule-core-3.8.5.jar:3.8.5]
    at org.mule.work.WorkerContext.run(WorkerContext.java:301) ~[mule-core-3.8.5.jar:3.8.5]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_144]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_144]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_144]
Caused by: java.io.IOException: Length 1279873876 exceeds limit: 26
    at org.mule.transport.tcp.protocols.LengthProtocol.read(LengthProtocol.java:71) ~[mule-transport-tcp-3.8.5.jar:3.8.5]
    at org.mule.transport.tcp.protocols.SafeProtocol.assertSiblingSafe(SafeProtocol.java:79) ~[mule-transport-tcp-3.8.5.jar:3.8.5]

1 个答案:

答案 0 :(得分:0)

查看类名称org.mule.module.http.internal.HttpMessageLogger,您会看到一个.internal。包。这有力地暗示了您根本不应该使用该软件包。

正在发生的事情是,您正在使用内部Mule实现类作为为Splunk附加的Log4j2自定义。在任何情况下,这都不是该类的预期用法。

您应该做的是看Splunk documentation并按照那里的步骤进行操作。