求高手解决log4j的问题!!看不懂了
LoggingEventevent;LoggerremoteLogger;event=(LoggingEvent)ois.readObject();level=event...
LoggingEvent event;
Logger remoteLogger;
event = (LoggingEvent) ois.readObject();
level = event.getLevel().toString();
message = event.getMessage();
remoteLogger = hierarchy.getLogger(event.getLoggerName());
remoteLogger.callAppenders(event);
以上代码都是什么意思啊?
java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at com.jp.hp.eprint.logserver.SocketNodeEx.run(SocketNodeEx.java:51)
at java.lang.Thread.run(Unknown Source)
有时候抛这个异常 展开
Logger remoteLogger;
event = (LoggingEvent) ois.readObject();
level = event.getLevel().toString();
message = event.getMessage();
remoteLogger = hierarchy.getLogger(event.getLoggerName());
remoteLogger.callAppenders(event);
以上代码都是什么意思啊?
java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at com.jp.hp.eprint.logserver.SocketNodeEx.run(SocketNodeEx.java:51)
at java.lang.Thread.run(Unknown Source)
有时候抛这个异常 展开
展开全部
event = (LoggingEvent) ois.readObject(); 从socket流中读取日志事件
level = event.getLevel().toString(); 日志级别字符串表示:DEBUG,INFO,WARN等
message = event.getMessage(); 日志事件消息
remoteLogger = hierarchy.getLogger(event.getLoggerName());根据Logger名称获得远程日志组件
remoteLogger.callAppenders(event);远程打印日志
level = event.getLevel().toString(); 日志级别字符串表示:DEBUG,INFO,WARN等
message = event.getMessage(); 日志事件消息
remoteLogger = hierarchy.getLogger(event.getLoggerName());根据Logger名称获得远程日志组件
remoteLogger.callAppenders(event);远程打印日志
更多追问追答
追问
try
{ while (LogServer.running_) {
// read an event from the wire
try {
event = (LoggingEvent) ois.readObject();
} catch (SocketTimeoutException e) {
continue;
}
为什么event = (LoggingEvent) ois.readObject();第一次会成功,第二次就进入catch(SocketTimeoutException e) {}里面了呢?
追答
你看代码 是不是有setSoTimeout的调用, 意思就是说有设置读取超时时间。。 这样对端长时间不发消息过来, 就会读取超时
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询