简体   繁体   English

Spring hibernate 事务记录

[英]Spring hibernate Transaction Logging

how can we log spring Transaction mechanism.我们如何记录 spring 事务机制。 i am showing below example shown in Spring Doc sec 10.5.2 .if i want to logging upto this level how to do that我在下面显示Spring Doc sec 10.5.2中显示的示例。如果我想登录到这个级别怎么做

i am using Spring,Hibernate and Log4j.我正在使用 Spring、Hibernate 和 Log4j。

<!-- the Spring container is starting up... -->
[AspectJInvocationContextExposingAdvisorAutoProxyCreator] - Creating implicit proxy
for bean 'fooService' with 0 common interceptors and 1 specific interceptors
<!-- the DefaultFooService is actually proxied -->
[JdkDynamicAopProxy] - Creating JDK dynamic proxy for [x.y.service.DefaultFooService]
<!-- ... the insertFoo(..) method is now being invoked on the proxy -->
[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 transaction is rolled back (by default, RuntimeException instances cause rollback) -->
[DataSourceTransactionManager] - Rolling back JDBC transaction on Connection
[org.apache.commons.dbcp.PoolableConnection@a53de4]
[DataSourceTransactionManager] - Releasing JDBC Connection after transaction
[DataSourceUtils] - Returning JDBC Connection to DataSource

Exception in thread "main" java.lang.UnsupportedOperationException
at x.y.service.DefaultFooService.insertFoo(DefaultFooService.java:14)
<!-- AOP infrastructure stack trace elements removed for clarity -->
at $Proxy0.insertFoo(Unknown Source)

Logging File..记录文件..

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=info, stdout
log4j.category.org.springframework.transactions=DEBUG  

There's a section about Logging in the Spring Reference. Spring 参考中有一个关于日志的部分

It shows how to configure different logging frameworks, among them log4j它展示了如何配置不同的日志框架,其中包括log4j

In your case the last line of the config would be:在您的情况下,配置的最后一行是:

log4j.logger.org.springframework.transaction=DEBUG

If you're just willing to set the log level of spring transaction support, try adding the following logger to your log4j.xml:如果您只想设置 spring 事务支持的日志级别,请尝试将以下记录器添加到您的 log4j.xml:

<logger name="org.springframework.transaction">
        <level value="DEBUG" />
</logger>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM