Spring-Logback: How to separate between unnames loggers and lib-loggers?

14 views Asked by At

I am having a Spring-Boot app that uses multipe libs (Kafka, Hibernate, HTTP-Tomcat, ...).

I use logging with Logback.

If I create a special logger and use it in the app, then all logs will get there.

<logger name="MYLOG" level="INFO">
   <appender-ref ref="MYAPPENDER" />
</logger>


Logger logger = LoggerFactory.getLogger ("MYLOG");
logger.info ("blabla");

So far, so good.

All logging that does not find a configured logger is put into the root-logger.

<root level="info">
     <appender-ref ref="MYROOTAPPENDER"/>
 </root>

Logger logger = LoggerFactory.getLogger ("lkjlkjlkjlkj");  // no config for that name available
logger.info ("foobar");     // goes into root-logger

And so far I see thats also the case for all the logging of used libs, e.g. Tomcat, ...

Is it possible to define a logger that takes all my custom loggings that do not have a logger configured and a separate logger that takes all the stuff that is not logged by myself but from libs?

Or is it possible by parameter in application.properties to disable all libs-logging but keep my custom loggers alive?

0

There are 0 answers