0

I am migrating an EAR application from JBoss 6.1.0 AS to Wildfly 8.2.0 AS. EAR contains log4j.xml and application logs are generated by using this logging configuration file by employing the below line of code:

org.apache.log4j.xml.DOMConfigurator.configureAndWatch(log4j file path)

Application logs are generated fine but in server.log, application logs are also getting appended. I am using standalone-full-ha.xml configuration file and tried the below steps:

  1. Added jboss-deployment-structure.xml with the following contents:

<deployment>

     <exclude-subsystems>

    <subsystem name="logging" />

 </exclude-subsystems>

</deployment>   

  1. Added below lines under <subsystem xmlns="urn:jboss:domain:logging:2.0"> section

in standalone-full-ha.xml.

<use-deployment-logging-config value="true"/>

<add-logging-api-dependencies value="false"/>

How can I prevent applications logs getting appended in server.log ? Please help.

Workaround tried

Just adding to my previous comments, I tried first option provided in the link http://www.mastertheboss.com/jboss-server/jboss-log/using-log4j-with-jboss-as-7-and-wildfly.

  1. Added log4j.xml under META-INF of EAR.

  2. Added org.apache.log4j module as one of the dependencies attribute in MANIFEST.MF.

  3. It was mentioned to add a VM argument -Dorg.jboss.as.logging.per-deployment=true but I did not add.

server.log is generated fine and application logs are getting generated fine but I have below concerns:

  1. is the starting tag in log4j.xml and it has "warn" as value of threshold attribute. But, I am getting all kind of logs (i.e. works as ALL or DEBUG threshold).

  2. I have placed log4j.xml in META-INF of EAR. So, will org.apache.log4j.xml.DOMConfigurator.configureAndWatch(log4j file path) work where path denotes log4j.xml in META-INF ? Default time out is 60 seconds and if I change threshold, will it reflect ?

sridhar
  • 1,117
  • 5
  • 31
  • 59

1 Answers1

1

I use following jboss-deployment-structure.xml:

<?xml version="1.0" encoding="UTF-8"?>
    <!--https://github.com/wildfly/wildfly-core/blob/master/server/src/main/resources/schema/jboss-deployment-structure-1_2.xsd-->
<jboss-deployment-structure>
   <deployment>
       <exclude-subsystems>
           <subsystem name="logging"/>
       </exclude-subsystems>
      <exclusions>
        <module name="org.apache.commons.logging"/>
        <module name="org.apache.log4j"/>
        <module name="org.jboss.logging"/>
        <module name="org.jboss.logging.jul-to-slf4j-stub"/>
        <module name="org.jboss.logmanager"/>
        <module name="org.jboss.logmanager.log4j"/>
        <module name="org.slf4j"/>
        <module name="org.slf4j.impl"/>
    </exclusions>
</deployment>

sibnick
  • 3,995
  • 20
  • 20
  • many thanks for the response .. sibnick. If log4j dependencies are excluded in jboss-deployment-structure.xml, then should log4j jar be added within EAR ? I was referring log4j module in dependencies classpath of EAR. – sridhar Aug 08 '15 at 07:44
  • Yes you should include it to your application (war or ear). – sibnick Aug 08 '15 at 15:55
  • many thanks.. sibnick. Adding 1. , and 2. log4j.jar under lib folder of EAR ensured application logs are not getting appended in server.log. But, am getting below error – sridhar Aug 10 '15 at 09:45
  • ERROR [stderr] (MSC service thread 1-6) log4j:WARN No appenders could be found for logger (com.test.util.logging.LogFactory). ERROR [stderr] (MSC service thread 1-6) log4j:WARN Please initialize the log4j system properly. ERROR [stderr] (MSC service thread 1-6) log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. – sridhar Aug 10 '15 at 09:46
  • I have @startup EJBs logging some information in application logs and following per-deployment logging stopped logging those startup information. Is this because of the first issue as log4j is not configured well initially. – sridhar Aug 10 '15 at 09:48
  • I have added a "workaround tried" section in my blog. Could you please check whether you have faced the same. Many thanks. – sridhar Aug 10 '15 at 16:21
  • You need redeploy application if you change log4j.xml inside ear. It is big disadvantage of putting log4j.xml to META-INF. Actually in my project I use log4j2 and totaly switch off log4j for my app. You can use "Logging Profiles" as described here: https://docs.jboss.org/author/display/WFLY8/Logging+Configuration#LoggingConfiguration-LoggingProfiles – sibnick Aug 10 '15 at 17:33