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?

1 Answer 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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.