日志文件每天跟踪JPA/休眠更新/插入 [英] Log file to track JPA/Hibernate updates/Insert every day

查看:107
本文介绍了日志文件每天跟踪JPA/休眠更新/插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用JPA/Hibernate的Spring应用程序.我想跟踪数据库中的每个插入和更新语句.是否有可能每天将数据更新记录到文件并输出新文件.基本上,如果数据库中发生某些更改,我想在日志文件中对其进行跟踪.每天需要一个日志文件.我的应用程序中确实有log4.xml.除此之外,我不知道从哪里开始.有什么建议.提示解决方案和指向好的参考文献的指针.

I have a Spring Application which is using JPA/Hibernate. I want to track every insert and update statement in the DB. Is it possible to log the data update to a file and output a new file everyday. Basically if something changes in the database I want to track it in a log file. And there needs to be one log file everyday. I do have log4.xml in my application. Besides this I dont know where to begin. Any suggestions. tips solutions and pointers to good references are greatly appreciated.

推荐答案

在休眠配置中,将show sql属性设置为true,然后使用某些日志记录API将休眠日志重定向到文件

In the hibernate configuration, set show sql property to true and then redirect hibernate logs to a file using some logging API

<property name="show_sql">true</property>


log4j.logger.org.hibernate.SQL=DEBUG
log4j.logger.org.hibernate.type=TRACE

参考文献: Hibernate显示真实的SQL

这篇关于日志文件每天跟踪JPA/休眠更新/插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆