Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9090807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:27:40+00:00 2026-06-16T22:27:40+00:00

I have a spring based webapp using Hibernate to query mysql. When I enable

  • 0

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/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:27:41+00:00Added an answer on June 16, 2026 at 10:27 pm

    log4j 2 extended filter support. You may want to give the RegexFilter a try.

    For log4j 1.2.x there’s StringMatchFilter which is part of the “extras” package.

    Here is a quick example found online:

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
      <appender name="CustomAppender" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="custom.log"/>
        <param name="Append" value="true"/>
        <param name="MaxFileSize" value="5000KB"/>
        <param name="maxBackupIndex" value="5"/> 
              <layout class="org.apache.log4j.PatternLayout">
                      <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p - %m%n" />
              </layout>
    
              <filter class="org.apache.log4j.varia.StringMatchFilter">
                      <param name="StringToMatch" value="Here is DEBUG" />
                      <param name="AcceptOnMatch" value="true" />
              </filter>
      </appender>
    
      <root>
        <appender-ref ref="CustomAppender"/>
      </root>
    </log4j:configuration>
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Spring based webapp. I am using several repository classes with annotations
i have written a small webapp using spring-security and spring-mvc with an annotation based
I have been using the new feature of Spring 3.1.1 the java based configuration.
I have a web application developed using Java (Java EE), spring & Hibernate. We
I'm building a webapp with role based access control using Acegi (Spring) security. So
I have a Spring MVC based Web Application with Hibernate. Following is the directory
I have a spring based web application MyWebapp built using maven and deployed on
I have a Spring-MVC based webapp with a JSP front end. It is your
I am using Spring 3 ,java based configuration, with BootStrap. I have downloaded the
I have a spring based webapp and I also have a background process. From

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.