Java log4j:ERROR 尝试附加到名为的已关闭附加程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24066299/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
log4j:ERROR Attempted to append to closed appender named
提问by Zeus
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.
我们的 weblogic 8.1 服务器中有大约 19 个应用程序。每个应用程序都是一个带有一些 ejb、mdb 等的 .Ear 应用程序,每个应用程序都有一个 log4j 属性,定义在文件系统某处的 .properties 文件中。
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
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.jar 文件。如果您需要,我可以发布 .properties 文件。
EDIT: Including a couple of log4j properties. These property files are same for all the other applications as well.
编辑:包括几个 log4j 属性。这些属性文件对于所有其他应用程序也是相同的。
1st LOG file.
第一个日志文件。
# 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
2nd Log file
第二个日志文件
# 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
Update:
更新:
I've not seen duplicate log4j.jars in the class path. I've ran the following code and verified.
我没有在类路径中看到重复的 log4j.jars。我已经运行了以下代码并进行了验证。
String classpath = System.getProperty("java.class.path");
I've not seen any two log4j.properties files have the same Appender defined. Verified it by search the whole weblogic deploy directory.
我没有看到任何两个 log4j.properties 文件定义了相同的 Appender。通过搜索整个 weblogic 部署目录来验证它。
采纳答案by Zeus
It was a tough find for me as I have multiple applications in the VM. As per the articlelog4j 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.
这对我来说是一个艰难的发现,因为我在 VM 中有多个应用程序。根据文章log4j jar 文件需要单独添加到每个应用程序。log4j 中的大多数类都是单例的,因此根记录器被创建为所有应用程序(EAR 应用程序)的单例。我已经将我的应用程序修改为每个应用程序一个 jar,到目前为止没有问题。