log4j Caught java.net.SocketException closing conneciton

藍色的海 发布于 2016/02/15 17:45
阅读 215
收藏 0

log4j发送日志到远程机器,Appender是org.apache.log4j.net.SocketAppender,


配置的log4j-server.properties 是

#Define a narrow log category. A category like debug will produce some extra logs also from server itself
log4j.rootLogger=info, I


#Define how the socket server should store the log events




log4j.appender.I = org.apache.log4j.DailyRollingFileAppender
log4j.appender.I.File = application-error.log
log4j.appender.I.Append = true  
log4j.appender.I.Threshold = INFO   
log4j.appender.I.layout = org.apache.log4j.PatternLayout  
log4j.appender.I.layout.ConversionPattern = %d{yyyy-MM-dd HH🇲🇲ss} %m%n

客户端发送日志代码是

Logger logger = LoggerFactory.getLogger(this.getClass());
logger.error("Hello error");
logger.info("Hello info ");

第一次发送日志记录application-error.log

2016-02-15 17:40:17 Listening on port 4712
2016-02-15 17:40:17 Waiting to accept a new client.
2016-02-15 17:40:48 Connected to client at /124.108.11.104
2016-02-15 17:40:48 Starting new socket node.
2016-02-15 17:40:48 Waiting to accept a new client.
2016-02-15 17:40:52 Hello error
2016-02-15 17:40:52 Hello info 

第二次发送日志application-error.log

2016-02-15 17:40:17 Listening on port 4712
2016-02-15 17:40:17 Waiting to accept a new client.
2016-02-15 17:40:48 Connected to client at /124.108.11.104
2016-02-15 17:40:48 Starting new socket node.
2016-02-15 17:40:48 Waiting to accept a new client.
2016-02-15 17:40:52 Hello error
2016-02-15 17:40:52 Hello info 
2016-02-15 17:42:10 Caught java.io.EOFException closing conneciton.
2016-02-15 17:42:10 Connected to client at /124.108.11.104
2016-02-15 17:42:10 Starting new socket node.
2016-02-15 17:42:10 Waiting to accept a new client.
2016-02-15 17:42:13 Hello error
2016-02-15 17:42:13 Hello info 

请问如何避免Caught java.io.EOFException closing conneciton,即不输出

Caught java.io.EOFException closing conneciton


加载中
返回顶部
顶部