-
1. Re: Logback in EAP 6.1
jamezp Oct 7, 2013 7:31 PM (in response to klind)1 of 1 people found this helpfulYes. 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
-
2. Re: Re: Logback in EAP 6.1
klind Oct 8, 2013 2:02 PM (in response to jamezp)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 Oct 8, 2013 2:08 PM (in response to klind)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 Oct 8, 2013 2:58 PM (in response to jamezp)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 Oct 8, 2013 4:14 PM (in response to klind)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 Oct 8, 2013 4:31 PM (in response to jamezp)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 Oct 8, 2013 5:35 PM (in response to klind)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
-
logging-handler-flow.png 16.7 KB
-
-
8. Re: Logback in EAP 6.1
klind Oct 8, 2013 6:08 PM (in response to jamezp)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 )