JBoss AS 7:记录 [英] JBoss AS 7: Logging
问题描述
我在JBoss AS7和日志记录方面有些挣扎.尽管我的问题很笼统,但我在网上找不到任何相关内容.
I struggle a bit with JBoss AS7 and the logging. I cannot find anything related on the web despite the fact that my issue is a very general one.
默认日志当前如下所示:
The default log looks currently like this:
11:57:29,950 INFO [stdout] (http--0.0.0.0-8081-78) 248408930 [http--0.0.0.0-8081-78] INFO org.apache.http.impl.client.DefaultHttpClient - I/O exception (java.net.SocketException) caught when processing request: Connection reset
11:57:29,950 INFO [stdout] (http--0.0.0.0-8081-78) 248408930 [http--0.0.0.0-8081-78] INFO org.apache.http.impl.client.DefaultHttpClient - Retrying request
请注意[stdout],这些行是由某些日志记录库写入stout的,这些日志库由某些库使用并由JBoss提取并写入日志文件.这就是我要解决的问题.
notice the [stdout], those lines where written to stout by some logging library which is used by some library and picked up by JBoss and written to the log file. This is what i want to fix.
我想必须有一种方法可以让适配器告诉log4j(或任何其他日志记录框架)登录到jboss日志记录子系统?
I guess there must be a way to have an adapter which tells log4j (or any other logging framework) to log to the jboss logging subsystem?
我的第一个想法是从项目的类路径中删除所有log4j配置.我在我使用的库中找到了一个,它确实记录到了stdout.但这并不能解决任何问题.
My first idea was to remove all log4j configuration from the classpath of my project. I found one in a library i use which did log to stdout. But this does not fix anything.
11:21:01,648 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardServletEnvironment).
11:21:01,648 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) log4j:WARN Please initialize the log4j system properly.
11:21:01,648 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
未配置附加程序时的常见错误消息.至少我可以确定类路径中不再有任何配置.
The usual error message when no appender is configured. At least i can be sure that no configuration is in the classpath anymore.
JBoss AS文档甚至没有提到这种情况,当我无法获得正确的日志记录时,我应该如何使用第三方库?
The JBoss AS documentation does not even mention this kind of scenario, how i am supposed to use 3rd party libraries when i am not able to get proper logging?
我真的希望有人能帮助我,任何提示都值得赞赏!
I really hope someone can help me out, any hint is appreciated!
Malax
推荐答案
虽然不是问题所在,但我确实假设您正在尝试将log4j与JBoss AS7一起使用.如果是这样,并且确实需要使用附加程序,那么您需要排除服务器随附的log4j,并且将您自己的版本与当前的部署打包在一起.解决 AS7-514 后,这种情况应该会很快改变.添加该功能后,您无需进行任何操作.
While it's not in the question, I do assume you are attempting to use log4j with JBoss AS7. If that is true and you do need to use appenders, then you need to exclude the log4j that comes with the server and package your own version with your deployment currently. This should be changing soon once AS7-514 is resolved. Once that feature is added, nothing will need to be done on your side.
要立即解决此问题,您首先需要创建一个 jboss-deployment-structure.xml
如下所示:
To resolve the issue for now you first need to create a jboss-deployment-structure.xml
that should look like the following:
<jboss-deployment-structure>
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>
然后将您自己的log4j版本添加到您的WEB-INF/lib
目录或部署可以找到该库的任何其他位置.
Then add your own version of log4j to your WEB-INF/lib
directory or any other place where the deployment would be able to find the library.
之后,它应该会按您期望的那样工作.
After that it should work just as you would expect.
这篇关于JBoss AS 7:记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!