Search code examples
javatomcatlogginglog4jverbosity

Tomcat: Filter log4j by logger name


I am working with an external package which uses a log4j quite verbosely. I've looked at the code and found the expected log4j lines:

private Logger log = Logger.getLogger("SomeLoggerName");
...
log.info("Trivial message");
log.info("More trivial data");

Since I can't change the code, I've tried to change log4j.xml:

<category name="SomeLoggerName">
  <level value="${log4j_level:-WARN}"/>
  <appender-ref ref="FileLogger"/>
</category>

I guessed thatcategory name property is equivalent to the logger name. Is it true? If not, how can I filter by logger name?


Solution

  • You are right, logger == category. Do you have problems with your configuration? Generally it looks OK and should work.