注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

清风幻影的博客

Where there is love, I will be there.

 
 
 

日志

 
 
关于我

同是天涯沦落人,相逢何必曾相识. 天生我材必有用,千金散尽还复来. 天若有情天亦老,人间正道是沧桑. 月影西斜人已去, 堤上梅花情依旧, 此情故已成追忆, 美人如玉夜留香

网易考拉推荐

jboss7 自定义log4j配置  

2013-12-19 16:46:37|  分类: jboss资料 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

http://kang36897.blog.163.com/blog/static/17047373201211262204229/


There will soon be a way that
 will just work for you, but currently you have to exclude the log4j dependency from your deployment. You will also have to manually invoke the PropertyConfigurator.configure() to load the properties file.

The following file (jboss-deployment-structure.xml) needs to contain the following:

<?xml version="1.0" encoding="UTF-8"?>
<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>

这个文件放哪里呢,jboss-deployment-structure.xml is a JBoss specific deployment descriptor that can be used to control class loading in a fine grained manner. It should be placed in the top level deployment, in META-INF (orWEB-INF for web deployments)(详情请看:https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7#ClassLoadinginAS7-JBossDeploymentStructureFile就是文件夹META-INF或者WEB-INF下面。

 怀着激动的心情我想说我成功了,输出结果(类似):

  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


为什么输出结果是这个样子:log4j输出的内容被包裹在了jboss服务的输出中。给出的解释之一:

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.就说这个BUG会解决的,现在先这样凑乎着。还有另外一个帖子也是这样说的:

In 7.1.1 in order for your own logging system to work (based on your provided log4j.xml) to work you most probably have excluded (via jboss-deployment-structure.xml) the logging system provided by JBoss hence your app has not got access to that. After 7.1.2 you don't have to exclude anything manually as the server does it automatically if it finds log4j.xml, jboss-log4j.xml, log4j.properties files in your distributable. Check for some discussions about it below:


  评论这张
 
阅读(1132)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018