在日志中显示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
这篇关于在日志中显示Spring事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!