In Log4j2, how to avoid logging messages that contain a certain text?

Viewed 1186

How can I filter out Log4j2 messages according to their message content?

For example, I don't want to log Hibernate messages that contain the text: HHH90000022: Hibernate's legacy org.hibernate.Criteria API is deprecated; use the JPA javax.persistence.criteria.CriteriaQuery instead. Of course, I can disable all Hibernate deprecation warnings, like this:

<Logger name="org.hibernate.orm.deprecation" additivity="false" level="ERROR">
    …
</Logger>

But then I will get no deprecation warnings at all, and they are usually useful. I want to remove just that one (because there is nothing I can do to fix it, and they are issued by the thousands). Please note this is a Log4j2 question, not a Hibernate question.

1 Answers
Related