本文介绍了Spring hibernate事务日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我们如何记录spring事务机制。我将在下面的示例中显示 Spring Doc sec 10.5.2 。如果我想记录到这个级别怎么做how can we log spring Transaction mechanism. 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,Hibernate和Log4j。i am using Spring,Hibernate and Log4j.<!-- the Spring container is starting up... -->[AspectJInvocationContextExposingAdvisorAutoProxyCreator] - Creating implicit proxyfor 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 shouldrollback on java.lang.UnsupportedOperationException[TransactionInterceptor] - Invoking rollback for transaction on x.y.service.FooService.insertFoodue 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 DataSourceException in thread "main" java.lang.UnsupportedOperationExceptionat x.y.service.DefaultFooService.insertFoo(DefaultFooService.java:14)<!-- AOP infrastructure stack trace elements removed for clarity -->at $Proxy0.insertFoo(Unknown Source)记录文件..log4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.Target=System.outlog4j.appender.stdout.layout=org.apache.log4j.PatternLayoutlog4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%nlog4j.rootLogger=info, stdoutlog4j.category.org.springframework.transactions=DEBUG推荐答案 Spring Reference中的一个关于日志记录的部分。There's a section about Logging in the Spring Reference.它显示了如何配置不同的日志框架,其中 log4jIt shows how to configure different logging frameworks, among them log4j在你的情况下,conf的最后一行ig将是:In your case the last line of the config would be:log4j.logger.org.springframework.transaction=DEBUG 这篇关于Spring hibernate事务日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-04 06:59