Ashish Jagtap
Ashish Jagtap

Reputation: 2819

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

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.

Upvotes: 5

Views: 20155

Answers (2)

havelino
havelino

Reputation: 390

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"

Upvotes: 3

Nazia
Nazia

Reputation: 166

  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....

Upvotes: 0

Related Questions