8 Replies Latest reply on Aug 17, 2015 4:09 AM by sridharthiyagarajan

    How to prevent application logs getting logged in server.log in Wildfly 8.2.0 Final AS

    sridharthiyagarajan

      Hello,

       

      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:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <jboss-deployment-structure>

          <deployment>

               <exclude-subsystems>

              <subsystem name="logging" />

           </exclude-subsystems>

          </deployment>   

      </jboss-deployment-structure>

       

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

       

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

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

       

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

        • 1. Re: How to prevent application logs getting logged in server.log in Wildfly 8.2.0 Final AS
          jaikiran

          What does your log4j.xml file look like?

          1 of 1 people found this helpful
          • 2. Re: How to prevent application logs getting logged in server.log in Wildfly 8.2.0 Final AS
            mayerw01

            I am not sure having understood your question. But you should be able to suppress the application log entries by adding a <logger category= > entry to your standalone-full-ha.xml

            1 of 1 people found this helpful
            • 3. Re: How to prevent application logs getting logged in server.log in Wildfly 8.2.0 Final AS
              sridharthiyagarajan

              Many thanks for the response.. Jaikiran and Wolfgang Mayer. I followed the below steps provided in the link https://docs.jboss.org/author/display/WFLY8/How+To#HowTo-HowdoIusemyownversionoflog4j%3F and

               

              1. Added the below lines under <subsystem xmlns="urn:jboss:domain:logging:2.0"> in standalone-full-ha.xml.

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

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

               

              2. Added a lib folder containing log4j.jar in an EAR.

               

              After doing the above steps, I could see application logs are not getting appended with server.log. But, I am observing below errors:

               

              1. Getting the below in server.log.

               

              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.

               

              In the link Apache log4j 1.2 - Frequently Asked Technical Questions, log4j.properties or log4j.xml is mandatory for log4j initialization. But, below line of code is used to create logs.

               

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


              I am migrating EAR application from JBoss 6 AS to Wildfly 8.2.0 AS and while observing JBoss 6 AS boot.log, log4j.defaultInitOverride: true is found. So, I tried the same setting in Wildfly 8.2.0 AS as well but still the mentioned error appears.

               

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

               

              Please help. Many thanks.

              • 4. Re: How to prevent application logs getting logged in server.log in Wildfly 8.2.0 Final AS
                sridharthiyagarajan

                Hello,

                 

                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. <log4j:configuration threshold="warn"> 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 ?

                 

                 

                Please help me in resolving the concerns. Many thanks in advance.

                • 5. Re: How to prevent application logs getting logged in server.log in Wildfly 8.2.0 Final AS
                  jamezp

                  I don't know if you sorted out your first question or not, but if not could you define what you mean by "application logs"?

                   

                  There's no need to add the MANIFEST.MF dependency. It should be automatically added unless you exclude the logging subsystem in a jboss-deployment-structure.xml or change the add-logging-api-dependencies to false.

                   

                  1. <log4j:configuration threshold="warn"> 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).

                  I'm not sure why that would be without seeing the full log4j.xml.

                   

                  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 ?

                  That is the correct place to put the configuration file in an EAR. During deployment the configureAndWatch is not used only the DOMConfigurator.doConfigure() is used. If you need to make runtime configuration changes I'd suggest not using a configuration file. The logging subsystem will allow you to configure logging for an application with logging-profiles.

                   

                  --

                  James R. Perkins

                  • 6. Re: How to prevent application logs getting logged in server.log in Wildfly 8.2.0 Final AS
                    gurusathish

                    Hi Sridhar,

                     

                    I had the same goal set for managing the logs in WildFly 8.2.0. Finally  I achieved the goal for segregating the logs into different file. I think this may help you.

                    Following configuration is to achieve this goal

                    INFO -> server_info.log

                    WARN & ERROR -> server_error.log

                    JBOSS logs goes to ->  server.log

                     

                    Step 1:

                            Dependencies: org.apache.log4j

                          Please place the above text in the MANIFEST.MF file which is in  standalone/deployments/application.war/META-INF/MANIFEST.MF 

                    Step 2

                          Place the attached log4j.xml file in the classpath WEB-INF/classes/log4j.xml

                    1 of 1 people found this helpful
                    • 7. Re: How to prevent application logs getting logged in server.log in Wildfly 8.2.0 Final AS
                      gurusathish

                      Hi Sridhar,

                       

                      Set the priority level to WARN .

                       

                      set priority to min and max to WARN then you will only get WARN logs in the log file.

                       

                      <!-- TO PREVENT LOGGING THE LOWER PRIORITY OF WARN. AND TO LOG ONLY WARN-->

                        <filter class="org.apache.log4j.varia.LevelRangeFilter">

                                  <param name="levelMin" value="WARN" />

                                  <param name="levelMax" value="WARN" />

                              </filter>

                      1 of 1 people found this helpful
                      • 8. Re: How to prevent application logs getting logged in server.log in Wildfly 8.2.0 Final AS
                        sridharthiyagarajan

                        Many thanks for the response.. Sathish. There is a watchdog feature in log4j which I have to retain and sure..  I will try this option and comment out. Thanks again.