Edward Dale
Edward Dale

Reputation: 30133

Modifying the level of a log message in a library

Our application is made up of 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?

Upvotes: 3

Views: 168

Answers (1)

Péter Török
Péter Török

Reputation: 116266

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.

Upvotes: 2

Related Questions