是否可以配置log4j以在每次运行应用程序时创建新文件? [英] Is it possible to configure log4j to create a new file with every run of the application?

查看:98
本文介绍了是否可以配置log4j以在每次运行应用程序时创建新文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我第一次运行应用程序时(或者在我清除/ logs目录后立即执行),我希望log4j将应用程序的日志写入名为log.0的文件中。然后,我退出应用程序并重新启动它,我希望将日志写入log.1。等等。

For example, the first time I run an application (or immediately after I clear out the /logs directory), I want log4j to write the application's logs to a file called log.0. Then, I exit the application and restart it, I want the logs to be written to log.1. And so on.

我想将此保留在配置文件中,但如果我不能,我想我总能在我的应用程序中执行此操作,当log4j已设置。

I would like to keep this in the configuration file, although if I can't, I guess I could always do it in my application, when log4j is set up.

这可能吗?如果是这样,怎么样?

Is this possible? If so, how?

推荐答案

可能这就是你要找的东西

May be this is what you are looking for

http://veerasundar.com/blog/2009/08/how-to-create-a-new-log-file-for-each-time-the-application-runs/

**编辑:**我还有一个解决方案!
但不知道它是否有效,但你可以尝试
http://www.mail-archive.com/log4cxx-user@logging.apache.org/msg02132.html

****I got one more solution! But no idea whether it works or not,but you can try http://www.mail-archive.com/log4cxx-user@logging.apache.org/msg02132.html

这篇关于是否可以配置log4j以在每次运行应用程序时创建新文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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