I have a spring based webapp using Hibernate to query mysql. When I enable trace logging by using log4j.logger.org.hibernate.type=TRACE, all queries with their parameters are logged to the console. This makes the webapp slow for search queries.
I need to log only modifications to the database. Preferably the insert/update query issued to the mysql server. What is the simplest and most reliable way of doing this?
Can I just ask log4j to log only insert queries?
P6SPY seems overkill for my purpose.
http://sourceforge.net/projects/p6spy/
log4j 2 extended filter support. You may want to give the
RegexFiltera try.For log4j 1.2.x there’s
StringMatchFilterwhich is part of the “extras” package.Here is a quick example found online:
However, AFAIU it does not allow you to match wildcards which means dead end in your case I guess. If you dig into the filters source code it should be pretty easy to write your own.