How to setup logging in jboss 6.x step by step using Log4j in Java

Hi everyone, I'm new to Jboss, so I get confused when setting up registration in Jboss 6.1, what I do I have to load and extract Jboss ( jboss-eap-6.1 ) on my machine, after which I follow the steps in this , but that's it I can’t see the logging on the console or in the file

I google and find out that I need to write the jboss-deployment-structure.xml file in the / META-INF / folder and add -Dorg.jboss.as.logging.per-deployment = false to start the server (which I don't know where I have to install this) from this link

so can anyone give me steps to configure logging in jboss 6.x using Log4j or any logging like java.util.logging, for registering statements on the console or in a file.

+4
source share
2 answers

You should find the standalone.bat file in the / bin Jboss folder, then you should edit this file by finding the following 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"

+3
source
  • If you want to keep a journal

    a. you want to use your own "log4j.jar", put it in the lib folder

    b. put jboss-deployment-structure.xml in the META-INF folder

    from. Add log4j.xml to WEB-INF / classes

    your application.

  • Add this to 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> 
  • Add this to 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 the entry on the console ....

0
source

Source: https://habr.com/ru/post/1502720/


All Articles