4

我想看看Spring中的事务活动,比如:

TransactionInterceptor] - Getting transaction for x.y.service.FooService.insertFoo
  <!-- the transactional advice kicks in here... -->
[DataSourceTransactionManager] - Creating new transaction with name [x.y.service.FooService.insertFoo]
[DataSourceTransactionManager] - Acquired Connection
    [org.apache.commons.dbcp.PoolableConnection@a53de4] for JDBC transaction

  <!-- the insertFoo(..) method from DefaultFooService throws an exception... -->
[RuleBasedTransactionAttribute] - Applying rules to determine whether transaction should
    rollback on java.lang.UnsupportedOperationException
[TransactionInterceptor] - Invoking rollback for transaction on x.y.service.FooService.insertFoo
    due to throwable [java.lang.UnsupportedOperationException]

而我配置的log4j.properties如下:

log4j.rootCategory=INFO, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n

log4j.logger.org.springframework.transactions=DEBUG

但是它不会产生上述输出。为了显示交易活动,我缺少哪个属性?

4

2 回答 2

5

利用

 log4j.logger.org.springframework.jdbc.datasource.DataSourceTransactionManager=DEBUG  

参考 事务 log4j

于 2013-05-31T01:58:41.983 回答
0

尝试:

log4j.logger.org.springframework.transaction=DEBUG

本答案中所述。

请注意与您的记录器名称相同但没有最后一个字符的记录器。

于 2013-05-30T15:49:33.353 回答