Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jboss7 set logger level programmatically

 
Andy Iyerr
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic