5

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.

Community
  • 1
  • 1
Ashish Jagtap
  • 2,799
  • 3
  • 30
  • 45

2 Answers2

3

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"

havelino
  • 390
  • 4
  • 8
  • When running jboss inside eclipse, I actually put this setting into launch configuration of jboss server connector to make it work. – Mitja Gustin Jan 12 '18 at 18:46
0
  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....

Nazia
  • 166
  • 1
  • 4
  • thanks for reply one thing what do you mean by own "log4j.jar" I have downloaded and place log4j-1.2.15.jar jar in WEB-INF/lib folder – Ashish Jagtap Sep 24 '13 at 12:49
  • I mean that the log4j.jar you downloaded and not the one provided by JBoss. – Nazia Sep 25 '13 at 04:46
  • I have already done this steps but only INFO level logs are displayed on console and file not created on given path – Ashish Jagtap Sep 25 '13 at 05:58
  • can you pls tell me where I have to set -Dorg.jboss.as.logging.per-deployment=false this attribute I mean in which file ? – Ashish Jagtap Sep 25 '13 at 07:13
  • I tried it and its working fine, you may be doing something wrong there...try by changing your log level to TRACE – Nazia Sep 25 '13 at 07:24
  • -Dorg.jboss.as.logging.per-deployment=false --> this is a system property and you should set it when starting jboss – Nazia Sep 25 '13 at 07:25