在日志中显示 Spring 事务 [英] Showing a Spring transaction in log
问题描述
我为 spring 配置了事务支持.有没有办法记录交易以确保我正确设置所有内容?在日志中显示是查看正在发生的事情的好方法.
I configured spring with transactional support. Is there any way to log transactions just to ensure I set up everything correctly? Showing in the log is a good way to see what is happening.
推荐答案
在您的 log4j.properties
中(对于替代记录器,或 log4j 的 xml 格式,请查看文档)
in your log4j.properties
(for alternative loggers, or log4j's xml format, check the docs)
根据您的事务管理器,您可以设置 spring 框架的日志记录级别,以便它为您提供有关事务的更多信息.例如,在使用 JpaTransactionManager
的情况下,您设置
Depending on your transaction manager, you can set the logging level of the spring framework so that it gives you more info about transactions. For example, in case of using JpaTransactionManager
, you set
log4j.logger.org.springframework.orm.jpa=INFO
(这是你的事务管理器的包),还有
(this is the package of the your transaction manager), and also
log4j.logger.org.springframework.transaction=INFO
如果 INFO
不够用,使用 DEBUG
If INFO
isn't enough, use DEBUG
这篇关于在日志中显示 Spring 事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!