开发者

Modifying the level of a log message in a library

开发者 https://www.devze.com 2023-01-05 05:55 出处:网络
Our application is made up o开发者_开发百科f tons of libraries, all of which use log4j for logging. The developer of the libraries chose levels for the log messages that are output, but they don\'t ne

Our application is made up o开发者_开发百科f tons of libraries, all of which use log4j for logging. The developer of the libraries chose levels for the log messages that are output, but they don't necessarily match with our needs. For example, an error message for the library developer is perhaps for our application just an informational message.

Is it possible to create a mapping from one level to another for a certain appender?


The only way I can think of is to implement a custom layout which changes the log level of incoming messages according to your needs. The layout is not meant for this, so it is a hack to use it this way, but it works. I published an example of a custom layout in this earlier post of mine. It is made for a different purpose, but is easy to adapt it to your needs.

0

精彩评论

暂无评论...
验证码 换一张
取 消