Reputation: 31
I read some posts here about similar problems but none was able to help me. I'm using Wildfly 9.0.2 and want to configure it to log like this:
my.project.category = INFO
my.especial.project.category = DEBUG
the rest = WARN
What I'm trying, with no success:
<subsystem xmlns="urn:jboss:domain:logging:3.0">
<console-handler name="MY_DEBUGGER_HANDLER">
<level name="DEBUG"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<console-handler name="MY_INFO_HANDLER">
<level name="INFO"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<console-handler name="CONSOLE">
<level name="WARN"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<logger category="my.project.category" use-parent-handlers="false">
<level name="INFO"/>
<handlers>
<handler name="MY_INFO_HANDLER"/>
</handlers>
</logger>
<logger category="my.especial.project.category" use-parent-handlers="false">
<level name="DEBUG"/>
<handlers>
<handler name="MY_DEBUGGER_HANDLER"/>
</handlers>
</logger>
<root-logger>
<level name="DEBUG"/>
<handlers>
<handler name="CONSOLE"/>
</handlers>
</root-logger>
<formatter name="PATTERN">
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
<formatter name="COLOR-PATTERN">
<pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
</subsystem>
The problem is that Wildfly refuses to log my categories, unless I change the CONSOLE handler level or add my handles to root-logger, which starts to logs all categories with that level.
Can you please, cast a light here and help me out?
Thank you!
Upvotes: 1
Views: 2615
Reputation: 17780
The handler itself should be set to the lowest level you want logged. For example on the default CONSOLE
handler if you want to see DEBUG
messages you'd need to set the handler level to at least DEBUG
.
In your above configuration you've got the root-logger
to DEBUG
which means any undefined category will log debug messages. Usually you wouldn't want the root logger level set this low as it will have a performance impact.
Given you're requirements and assuming the default configuration, not your configuration above, the following CLI commands should get you the configuration you're looking for. Note it's not necessary, and not really suggested, to create multiple console handlers. It's best to allow the logger to control the level.
my.project.category = INFO my.especial.project.category = DEBUG the rest = WARN
/subsystem=logging/console-handler=CONSOLE:write-attribute(name=level, value=DEBUG)
/subsystem=logging/logger=my.project.category:add(level=INFO)
/subsystem=logging/logger=my.especial.project.category:add(level=DEBUG)
/subsystem=logging/root-logger=ROOT:write-attribute(name=level, value=WARN)
What the above would do is allow the console handler to log any messages DEBUG
or higher. Your my.project.category
will log at INFO
and your my.especial.project.category
will log at DEBUG
. All other undefined loggers will only log WARN
or higher.
Upvotes: 1