---
title: "解决jboss和log4j的冲突问题"
author: "benbenming"
date: "2009-03-11T19:53:25Z"
tags: []
slug: "jboss-log4j"
draft: false
lastmod: "2009-03-11T19:53:25Z"
id: 347609
url: "https://benbenming.iteye.com/blog/347609"
---

刚刚在CSDN上看到的文章，这一段用JBoss也遇到过这样的问题，解决方式是把自已应用程序的log4j屏蔽掉使用JBoss的，感觉很是不爽，这篇文章还提供了一种方式，准备试一下！先贴过来共享一下！

方案1：

你先將你程式內部的 log4j.properties or log4j.xml 全部拿掉，再 deploy  
看看。如果沒問題再逐一將 自己的 config 一項一項放進  
\\jboss\\server\\default\\conf\\log4j.xml 測試。

方案2：

去\[JBOSS\_HOME]\\server\\default\\conf\\log4j.xml 改或加自己的設定這不太make sense，最好還是要針對個別application有自己的log4j設定檔比較合理。其實application若有自己的log4j war及設定檔，而導致JBoss啟動時出現 "ERROR: invalid console appender config detected, console stream is looping." 錯誤訊息時，只要去JBoss server層的conf資料夾中的jboss-service.xml中的org.jboss.logging.Log4jService的設定區段中加個參數：&lt;attribute name="CatchSystemOut"&gt;false&lt;/attribute&gt;即可，如：

&lt;mbean code="org.jboss.logging.Log4jService" name="jboss.system:type=Log4jService,service=Logging"&gt;&lt;attribute name="ConfigurationURL"&gt;resource:log4j.xml&lt;/attribute&gt;&lt;attribute name="CatchSystemOut"&gt;false&lt;/attribute&gt;&lt;attribute name="Log4jQuietMode"&gt;true&lt;/attribute&gt;&lt;/mbean&gt;