log4j:ERROR尝试追加到名为的封闭式追加器 [英] log4j:ERROR Attempted to append to closed appender named

查看:72
本文介绍了log4j:ERROR尝试追加到名为的封闭式追加器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的weblogic 8.1服务器中大约有19个应用程序.每个应用程序都是一个.ear应用程序,其中包含几个ejbs,mdb等.每个应用程序都有一个log4j属性,该属性在文件系统中某个位置的.properties文件中定义.

We have about 19 applications in our weblogic 8.1 server. Each application is an .Ear application with a few ejbs, mdb etc., Each application has a log4j properties defined in a .properties file somewhere in the filesystem.

在所有应用程序的服务器日志中,我们都会不断出现此错误(如下).在应用程序中不会捕获此异常,应用程序的流也不会停止,但是当发生此异常时,我们会丢失一条或两条日志语句.

We keep getting this error(below) in the server logs for all the applications. This exception is not caught in the application, the flow of the application does not stop, but we miss a log statement or two when this exception occurs.

log4j:ERROR Attempted to append to closed appender named

注意:我已经在Internet上查询,没有在系统中的任何地方看到重复的log4j.jar文件.如果需要,我可以发布.properties文件.

Note: I've looked up in the internet, i've not seen duplicate log4j.jar files anywhere in the system. I can post the .properties files if you need.

包括几个log4j属性.这些属性文件对于所有其他应用程序也相同.

Including a couple of log4j properties. These property files are same for all the other applications as well.

第一个LOG文件.

 # Define the root logger with appender file
  log=.//SI_AppLogs
  log4j.rootLogger=WARN, SomeApp

  log4j.logger.SomeAppLoggers = INFO, SomeApp     

 # Define the file appender
  log4j.appender.SomeApp=org.apache.log4j.DailyRollingFileAppender
  log4j.appender.SomeApp.File=${log}/CPEPortBasedAuthorization.log
  log4j.appender.SomeApp.DatePattern='.'yyyy-MM-dd
  log4j.appender.SomeApp.Append=true

  # Define the layout for file appender
  log4j.appender.SomeApp.layout=org.apache.log4j.PatternLayout
  log4j.appender.SomeApp.layout.conversionPattern=%d %-5r %-5p [%c] (%t:%x) %m%n

  log4j.additivity.org.apache=false
  log4j.additivity.SomeAppLoggers = false 

第二个日志文件

 # Define the root logger with appender file


log=.//SI_AppLogs
  log4j.rootLogger=WARN, AnotherApp

  log4j.logger.AnotherAppLoggers = INFO, AnotherApp

  # Define the file appender
  log4j.appender.AnotherApp=org.apache.log4j.DailyRollingFileAppender
  log4j.appender.AnotherApp.File=${log}/CPEPortBasedAuthorization.log
  log4j.appender.AnotherApp.DatePattern='.'yyyy-MM-dd
  log4j.appender.AnotherApp.Append=true

  # Define the layout for file appender
  log4j.appender.AnotherApp.layout=org.apache.log4j.PatternLayout
  log4j.appender.AnotherApp.layout.conversionPattern=%d %-5r %-5p [%c] (%t:%x) %m%n

  log4j.additivity.org.apache=false
  log4j.additivity.AnotherAppLoggers = false 

更新:

我没有在类路径中看到重复的log4j.jars.我已经运行了以下代码并进行了验证.

I've not seen duplicate log4j.jars in the class path. I've ran the following code and verified.

String classpath = System.getProperty("java.class.path");

我还没有看到任何两个log4j.properties文件定义了相同的Appender.通过搜索整个weblogic部署目录进行验证.

I've not seen any two log4j.properties files have the same Appender defined. Verified it by search the whole weblogic deploy directory.

推荐答案

对我来说,这是一个艰难的发现,因为我在VM中有多个应用程序.根据文章 log4j jar文件,分别添加到每个应用程序. log4j中的大多数类都是单例的,因此对于所有应用程序(EAR应用程序),都将根记录器创建为单例.我已经修改了我的应用程序,使每个应用程序只有一个jar,到目前为止没有问题.

It was a tough find for me as I have multiple applications in the VM. As per the article log4j jar file needs to be added to each application individually. Most of the classes in the log4j are singleton, so the root logger is getting created as a singleton for all the applications.(EAR applications). I've modified my application to have one jar per application, so far no issues.

这篇关于log4j:ERROR尝试追加到名为的封闭式追加器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆