2 Replies Latest reply on Dec 30, 2015 8:30 AM by arkadyz

    Logs are written twice in Wildfly 8

    arkadyz

      Hello,

       

      My version in Wildfly 8.2.0

       

      I have the following logging definition:

       

                  <logger category="a.b.c.d">

                      <level name="DEBUG"/>

                      <handlers>

                          <handler name="LogFile"/>

                      </handlers>

                  </logger>

       

                  <root-logger>

                      <level name="DEBUG"/>

                      <handlers>

                          <handler name="LogFile"/>

                      </handlers>

                  </root-logger>

       

      Suppose my message is from "a.b.c.d" category. I expect the handler "LogFile" will be applied only once, but I see it is applied twice, so log file contains the same message twice.

      Is there a way to configure Wildfly to not to apply the same handler twice ?

       

      Thank you in advance.

        • 1. Re: Logs are written twice in Wildfly 8
          jaysensharma

          Did you try setting   [ use-parent-handlers="false" ] to see how it goes:


                      <logger category="a.b.c.d"  use-parent-handlers="false">    <!-- Notice -->
                          <level name="DEBUG"/>
                          <handlers>
                              <handler name="LogFile"/>
                          </handlers>
                      </logger>
          


          The use-parent-handlers attribute is a boolean attribute to determine whether or not parent loggers should also process the log message.

          https://docs.jboss.org/author/display/WFLY8/Loggers#Loggers-useparenthandlers


          Regards

          Jay SenSharma

          • 2. Re: Logs are written twice in Wildfly 8
            arkadyz

            Hello Jay,

             

            Thanks for quick reply. This is a really good idea. But I have a concern here. Suppose we have following situation:

             

                        <logger category="a.b.c.d">

                            <level name="DEBUG"/>

                            <handlers>

                                <handler name="LogFile"/>

                            </handlers>

                        </logger>

             

                        <logger category="a.b.c">

                            <level name="DEBUG"/>

                            <handlers>

                                <handler name="LogFile"/>

                                <handler name="LogFile1"/>

                            </handlers>

                        </logger>

             

            If the message is from category "a.b.c.d" we would like it is treated also by LogFile1, we just not want this message is treated twice by LogFile. If I am not mistaken, it is supported by log4j. Is there a way to do it in Wildfly logging framework ?

             

            Thanks,

            Arkady