Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logback logger name

Is there a way to create a logger name using regular expressions or wild card. The reason I am asking this is; my application uses a lot of third part libraries which I don't want to append to the same log. I want a seperate appender for them. What I wanted to know was if there is a way to create a logger name by defining a wildcard of package name and then all logs from that package go to that logger E.g.

<logger name="org.zookeeper.* additivity=false>
   <appender ref="aaa"/>
</logger>

This should make all logs from package name which starts with org.zookeeper.* to go to the above specific logger.

Does logback support this facility?

like image 783
code-ninja-77 Avatar asked Jul 10 '14 09:07

code-ninja-77


People also ask

What is logger name in Logback xml?

Loggers. Loggers are the third main component of Logback, which developers can use to log messages at a certain level. The library defines 5 log levels: TRACE, DEBUG, INFO, WARN, ERROR; each of these has a corresponding logging method: trace(), debug(), info(), warn(), error().

Is Logback using Log4j?

Logback uses the same concepts as Log4j. So it's no surprise that even if they are using different file formats, their configurations are very similar. The following code snippet shows the same configuration as I used with Log4j.

Does Logback use SLF4J?

Logback natively implements the SLF4J API.

What is totalSizeCap in Logback?

The lastest version of logback.qos.ch (1.1. 7) supports the property "totalSizeCap". This property can be used to limit the total size of archived log files. Currently, the top level nifi pom. xml specifies version 1.1.


1 Answers

To log all org.zookeeper subpackages to "aaa" appender, you should omit the .* at the end of logger definition:

<logger name="org.zookeeper" additivity=false>
    <appender ref="aaa"/>
</logger>
like image 191
Tomasz Zabłocki Avatar answered Sep 25 '22 23:09

Tomasz Zabłocki