0

I have various modules logging information using various levels. I would like to implement a controller that would log the information only if the message follows certain pattern.

For example - Module A logger.info("log this message - A");

Module B logger.info("log this message - B");

Module C logger.info("don't log this message - C");

I cannot make changes to A and B to change their level as the number of modules talking to each other is huge.

I would like to have a logging.properties that would log all messages not having "don't log this messages*" pattern.

Can you assist me?

4

1 回答 1

1

There is no regex filter included with the logging package in the JDK. However, you can create your own Filter to throw out messages that match your regex then install it on the handler you want to filter. If you want to install a custom filter on a specific logger then you have to use the config property to programmatically install the filter.

于 2013-08-08T21:26:27.633 回答