File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes Jboss7 set logger level programmatically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Jboss7 set logger level programmatically" Watch "Jboss7 set logger level programmatically" New topic
Author

Jboss7 set logger level programmatically

Andy Iyerr
Greenhorn

Joined: Sep 03, 2013
Posts: 2
Hi,

Can anyone please help as to how i can set the logger level programmatically.

This is how the logger is setup in standalone.xml:

<subsystem xmlns="urn:jboss:domain:logging:1.2">
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
</console-handler>
<size-rotating-file-handler name="FILE">
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<rotate-size value="20M"/>
<max-backup-index value="10"/>
<append value="true"/>
</size-rotating-file-handler>
<size-rotating-file-handler name="ABCD" autoflush="true">
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="abcd.log"/>
<rotate-size value="20M"/>
<max-backup-index value="10"/>
<append value="true"/>
</size-rotating-file-handler>
<logger category="ABCD_LOG">
<level name="DEBUG"/>
<handlers>
<handler name="ABCD"/>
</handlers>
</logger>
<root-logger>
<level name="ERROR"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
</subsystem>

And I want to set the logger level for handler=ABCD at runtime from my app programmatically. Any snippet of code or assistance is highly appreciated.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10068
    
163

What logging library are you using? Typically it involves getting hold of the Logger instance by passing the logger category name and then iterating over the appenders/handlers on the returned Logger instance to find the appender/handler you are interested in.

[My Blog] [JavaRanch Journal]
 
Don't get me started about those stupid light bulbs.
 
subject: Jboss7 set logger level programmatically