Reputation: 30919
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.
Upvotes: 4
Views: 1699
Reputation: 30919
Oops, it seems I answered myself, I don't know how I missed this RegexFilter
:
<Logger name="org.hibernate.orm.deprecation" additivity="false" level="WARN">
<RegexFilter regex=".*HHH90000022.*" onMatch="DENY" onMismatch="NEUTRAL"/>
…
</Logger>
Upvotes: 5