8 Replies Latest reply on Oct 8, 2013 6:08 PM by klind

    Logback in EAP 6.1

    klind

      Hi. I have been trying to get logback to work in several JBoss instances.

       

      logback in JBoss 7.2.0

      Logback JBoss 7 classpath problem !!!

      Re: Logback JBoss 7

       

      Now we are using EAP 6.1, and I don't even wanna try to get it to work here.

       

      It seems that a lot of us would like this to get fixed, but nothing is happening.

       

      One thing we need to be able to do is changing the log level for the application on the fly... is that possible with the standard jboss log setup ???

        • 1. Re: Logback in EAP 6.1
          jamezp

          Yes. With a management interface, like CLI or the web console, you can definitely change the levels at runtime. As well as adding/removing handlers and/or loggers. For just a few examples https://docs.jboss.org/author/display/AS72/How+To.

           

          --

          James R. Perkins

          1 of 1 people found this helpful
          • 2. Re: Re: Logback in EAP 6.1
            klind

            Ok, so I am using the console to create handlers, categories etc.

             

            But I am a little confused. I want to be able to enable / disable log levels on class level on the fly.

             

            I created a

             

            <size-rotating-file-handler name="jsi" autoflush="true">

                            <level name="ERROR"/>

                            <file relative-to="jboss.server.log.dir" path="jsi.log"/>

                            <rotate-size value="100m"/>

                            <max-backup-index value="20"/>

                            <append value="true"/>

            </size-rotating-file-handler>

             

            So basic I only wanna see error here... unless I turn on debug or info in a class... so I wanna see debug on a class in the file and the console...

             

            <logger category="com.farheap.jsi.order.OrderProcessing" use-parent-handlers="false">

                            <level name="DEBUG"/>

                            <handlers>

                                <handler name="CONSOLE"/>

                                <handler name="jsi"/>

                            </handlers>

            </logger>

             

            But I dont get any debug in the file... I only get the debug in the console.. but that because the console it set to ALL

             

            <console-handler name="CONSOLE">

                            <level name="ALL"/>

                            <formatter>

                                <pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>

                            </formatter>

            </console-handler>

             

            So how am I supposed to do this ? Thanks

            • 3. Re: Logback in EAP 6.1
              jamezp

              You don't see debug messages in the file because you have the file handler level set to ERROR. You would have to set it to DEBUG or lower to see DEBUG messages in it.

               

              --

              James R. Perkins

              • 4. Re: Re: Logback in EAP 6.1
                klind

                So if I set log level to ALL

                 

                <size-rotating-file-handler name="jsi" autoflush="true">

                                <level name="ALL"/>

                                <file relative-to="jboss.server.log.dir" path="jsi.log"/>

                                <rotate-size value="100m"/>

                                <max-backup-index value="20"/>

                                <append value="true"/>

                </size-rotating-file-handler>

                 

                I see debug on the com.farheap.jsi.order.OrderProcessing class.

                 

                So do I get this right... I set the log level on the handler to the lowest level I want in that handler. Nothing will be logged to that handler unless I create a category that uses that handler ??

                And then create a category, with the log level on a package or class, that uses a handler... then something will get logged. ?

                • 5. Re: Logback in EAP 6.1
                  jamezp

                  klind wrote:

                   

                  So if I set log level to ALL

                   

                  <size-rotating-file-handler name="jsi" autoflush="true">

                                  <level name="ALL"/>

                                  <file relative-to="jboss.server.log.dir" path="jsi.log"/>

                                  <rotate-size value="100m"/>

                                  <max-backup-index value="20"/>

                                  <append value="true"/>

                  </size-rotating-file-handler>

                   

                  I see debug on the com.farheap.jsi.order.OrderProcessing class.

                   

                  So do I get this right... I set the log level on the handler to the lowest level I want in that handler. Nothing will be logged to that handler unless I create a category that uses that handler ??

                  And then create a category, with the log level on a package or class, that uses a handler... then something will get logged. ?

                  Almost got it. Yes you create use the level on the handler to the lowest level you want to see in the handler. If the handler is only assigned to a specific category, then only that category and/or it's child categories will be sent to the handler. If the level on the logger (category) is loggable, then it will be sent to any attached handlers. Since if you have set to use-parent-handlers=false, it stops there.

                   

                  The basic flow is this; logger checks to see if it's loggable by checking the level and then any filters that might be attached. If loggable the record is then passed to any directly attached handlers. If the attach handler finds the record to be loggable it will be processed by the handler. If the logger is set to use parent handlers, the next category segment is checked and the process continues until it hits a defined logger category that is set to use-parent-handlers=false or the root logger is found.

                   

                  --
                  James R. Perkins

                  • 6. Re: Logback in EAP 6.1
                    klind

                    Ok. The only thing I don't get is the parent handler... a logger ( category )  can be set to use parent handler... ?? when is a handler a parent ?

                    • 7. Re: Re: Logback in EAP 6.1
                      jamezp

                      In most cases there is no parent handler. I say most because some handler can have a collection of handlers they hand-off to, but I'm probably just making this more confusing now .

                       

                      A logger category is just a string which uses . (dot) delimiters to segment it self. In a logger category of org.jboss.example the parent is org.jboss whose parent is org, whose parent is the root logger. Each logger/category can have handlers attached to it. If the logger is defined with attribute use-parent-handlers=false, then org.jboss, org and the root logger do not receive the log record set to org.jboss.example.*.

                       

                      I'm not really a chart wizard, but I attempted to draw out the flow in the attachment.

                       

                      --

                      James R. Perkins

                      • 8. Re: Logback in EAP 6.1
                        klind

                        ah ok... so the text "use parent handlers" could actually be "use parent categories"  Makes more sense to me.   ( a parent category would then have a handler )