登录Spring批处理 [英] Logging in Spring batch

查看:68
本文介绍了登录Spring批处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是春季批处理的新手.我想知道在实现spring批处理读取器和写入器时如何放置日志记录语句.例如,如果我在Spring上下文XML中定义读取器和写入器,那么以后我将无法调试代码失败的地方. 如何在Spring批处理中实现日志记录. 我是否需要扩展Java中可用的阅读器类(例如flatFileReader),并将日志记录语句放入Java类中.

I am new to spring batch. I want to know how we can put logging statement while implementing spring batch readers and writers. For example if I define readers and writers in spring context XML then later on I can't debug where my code failed. How can I achieve logging in Spring batch. Do I need to extend the available reader classes in java for example flatFileReader and put logging statement in java class.

或者我可以在将代码保存在上下文文件中的同时实现这一目标吗?

Or can I achieve this while maintaining my code in context file?

如果我想抛出用户定义的异常,那我该怎么做.

And in case I want to throw my user defined exceptions then how can I do this.

推荐答案

根据要调试的内容,如果要调试现成的读取器和写入器,请设置log4j级别以进行调试春季批处理软件包.

Depending on what you want to debug, if you looking for debugging the out-of-the-box readers and writers, set up your log4j level to debug for the spring batch package.

###  debug your specific package or classes with the following example
#log4j.logger.org.springframework.jdbc=debug
#log4j.logger.org.springframework.batch=debug

大多数现成的读写器应该具有足够的调试功能.

Most of the out-of-box readers and writers should have sufficient debugging.

这篇关于登录Spring批处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆