最近在學習JBoss下配置Log4j,JBoss的各個版本的目錄、JBoss和Log4j集成的文件名每次都有變化,在JBoss5.x下配置了log4j.xml文件,但是配置沒有生效。如果你在項目中沒有指定使用的log4j的配置文件,最好使用JBoss自帶的配置文件,文件名為jboss-log4j.xml。該文件在Jboss容器的目錄為:${JBOSS_HOME}\server\default\conf下。下面就是基于log4j默認配置的一些基本修改和注釋:
專注于為中小企業提供做網站、網站設計服務,電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業煙臺免費做網站提供優質的服務。我們立足成都,凝聚了一批互聯網行業人才,有力地推動了上千企業的穩健成長,幫助中小企業通過網站建設實現規模擴充和轉變。<span ><?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"> <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender"> <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler" /> <param name="File" value="${jboss.server.log.dir}/server.log" /> <param name="Append" value="true" /> <!-- Rollover at midnight each day --> <param name="DatePattern" value="'.'yyyy-MM-dd" /> <!-- Rollover at the top of each hour <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/> --> <layout class="org.apache.log4j.PatternLayout"> <!-- The default pattern: Date Priority [Category] Message\n --> <param name="ConversionPattern" value="%d %-5p [%c] %m%n" /> <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/> --> </layout> </appender> <appender name="ErrorFile" class="org.jboss.logging.appender.DailyRollingFileAppender"> <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler" /> <param name="File" value="${jboss.server.log.dir}/error.log" /> <param name="Threshold" value="ERROR" /> <param name="Append" value="true" /> <!-- Rollover at midnight each day --> <param name="DatePattern" value="'.'yyyy-MM-dd" /> <layout class="org.apache.log4j.PatternLayout"> <!-- The default pattern: Date Priority [Category] Message\n --> <param name="ConversionPattern" value="%d %-5p [%c] %m%n" /> <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/> --> </layout> </appender> <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler" /> <param name="Target" value="System.out" /> <param name="Threshold" value="INFO" /> <layout class="org.apache.log4j.PatternLayout"> <!-- The default pattern: Date Priority [Category] Message\n --> <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n" /> </layout> </appender> <!-- ================ --> <!-- Limit categories --> <!-- ================ --> <category name="org.hibernate"> <priority value="WARN" /> </category> <category name="org.hibernate.engine.loading.LoadContexts"> <priority value="ERROR" /> </category> <category name="org.jboss"> <priority value="INFO" /> </category> <!-- Limit the org.apache category to INFO as its DEBUG is verbose --> <category name="org.apache"> <priority value="WARN" /> </category> <!-- Limit the jacorb category to WARN as its INFO is verbose --> <category name="jacorb"> <priority value="WARN" /> </category> <!-- Limit the org.jgroups category to WARN as its INFO is verbose --> <category name="org.jgroups"> <priority value="WARN" /> </category> <!-- Limit the org.quartz category to INFO as its DEBUG is verbose --> <category name="org.quartz"> <priority value="INFO" /> </category> <!-- Limit the JSR77 categories --> <category name="org.jboss.management"> <priority value="INFO" /> </category> <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose --> <category name="org.jboss.serial"> <priority value="INFO" /> </category> <category name="com.liang"> <priority value="DEBUG" /> </category> <!-- ======================= --> <!-- Setup the Root category --> <!-- ======================= --> <root> <appender-ref ref="CONSOLE" /> <appender-ref ref="FILE" /> <appender-ref ref="ErrorFile" /> </root> </log4j:configuration></span>
文章題目:JBoss5.x下配置Log4j方法介紹-創新互聯
文章網址:http://vcdvsql.cn/article26/dgoicg.html
成都網站建設公司_創新互聯,為您提供響應式網站、網站制作、搜索引擎優化、動態網站、關鍵詞優化、企業建站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯