Donald
Donald

Reputation: 339

Logging different level for a specific class using logback?

Can I override a logging level for a specific class only using logback.xml? i.e everything remains in INFO, except for one class which will log in DEBUG.

I appended this after the default one, but does not seem to work

<logger name="com.pack1.pack2.paack3.ClassName" additivity="false" level="debug">
    <appender-ref ref="file1"/>
</logger>

Thanks, Donald

Upvotes: 24

Views: 21693

Answers (3)

F. P. Freely
F. P. Freely

Reputation: 1124

Doing it exactly like this works for me:

<logger name="org.apache.zookeeper" level="WARN" />

Upvotes: 9

Mr.Q
Mr.Q

Reputation: 4524

(In case you set the name of logger explicitly) check if the name of the logger matches the name you set for your logger in your source code.

Use the upper case letters for level keywords (DEBUG, INFO ....) and I am not sure but maybe you should use Level instead of level.

Upvotes: 5

David Roussel
David Roussel

Reputation: 5916

I'm pretty sure I've done that before and it's worked. Try uppercase DEBUG.

Upvotes: 1

Related Questions