How to Step By Step configure logging in jboss 6.x with Log4j in Java

删除回忆录丶 提交于 2019-12-23 10:25:54

问题


Hi all I am new to Jboss so I am get confused while setting up an logging in Jboss 6.1 what I does I have download and extract the Jboss (jboss-eap-6.1) on my machine then I follow the steps given in this article but still I not able to see the logging on console or in file

the I google it around and come to know that I have to write jboss-deployment-structure.xml file under /META-INF/ folder and have to add -Dorg.jboss.as.logging.per-deployment=false to the start-up of the server (which I dont know where I have to set this) from this link

so can any one give me steps to configure logging in jboss 6.x with Log4j or any logging like java.util.logging to log statements on console or in file thanks.


回答1:


You should find the standalone.bat file into the /bin folder of Jboss, then you should edit this file, finding the next line

rem Setup JBoss specific properties
set JAVA_OPTS=-Dprogram.‌​name=%PROGNAME% %JAVA_OPTS%

And replace for this

set "JAVA_OPTS= -Dorg.jboss.as.logging.per-deployment=false"




回答2:


  1. If you want logging

    a. you want to use your own "log4j.jar" place it in lib folder

    b. place jboss-deployment-structure.xml in META-INF folder

    c. Add log4j.xml in WEB-INF/classes

    of your application.

  2. Add this in jboss-deployment-structure.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <jboss-deployment-structure>
      <deployment>
        <exclusions>
        <module name="org.apache.log4j" />
        </exclusions>
      </deployment>
    </jboss-deployment-structure>
    
  3. Add this in log4j.xml

     <?xml version="1.0" encoding="UTF-8" ?>
       <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
         <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
           <appender name="appender" class="org.apache.log4j.FileAppender">
               <param name="File" value="${jboss.server.log.dir}/server.log"/>
               <param name="Append" value="true"/>
            <layout class="org.apache.log4j.PatternLayout">
               <param name="ConversionPattern" value="%d [%t] %p - %m%n"/>
            </layout>
           </appender>
         <root>
          <priority value ="trace"/>
        <appender-ref ref="appender"/>
         </root>
        </log4j:configuration>
    

    Then you can see logging on console....



来源:https://stackoverflow.com/questions/18863630/how-to-step-by-step-configure-logging-in-jboss-6-x-with-log4j-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!