4

I'd like to see the transaction activity in Spring, such as:

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]

and the log4j.properties I have configured are as follows:

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

However it doesn't produce the above output. Which property am I missing in order to display the transaction activity?

moffeltje
  • 4,521
  • 4
  • 33
  • 57
user2431562
  • 53
  • 1
  • 5

2 Answers2

5

use

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

reference Transaction log4j

王奕然
  • 3,891
  • 6
  • 41
  • 62
0

Try:

log4j.logger.org.springframework.transaction=DEBUG

as specified in this answer.

Pay attention at the name of the logger that is same as yours without the last character.

Community
  • 1
  • 1
dimitrisli
  • 20,895
  • 12
  • 59
  • 63