log4j日志文件名? [英] log4j log file names?

查看:116
本文介绍了log4j日志文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有几个并发运行的作业必须使用相同的log4j配置信息。他们都使用相同的appender将日志转储到一个文件中。有没有办法让每个作业动态命名其日志文件,以便它们保持独立?

We have several jobs that run concurrently that have to use the same config info for log4j. They are all dumping the logs into one file using the same appender. Is there a way to have each job dynamically name its log file so they stay seperate?

谢谢

Tom

Thanks
Tom

推荐答案

您可以为每个作业传递Java系统属性吗?如果是这样,你可以这样参数化:

Can you pass a Java system property for each job? If so, you can parameterize like this:

java -Dmy_var=somevalue my.job.Classname

然后在你的log4j.properties中:

And then in your log4j.properties:

log4j.appender.A.File=${my_var}/A.log

你可以使用来自主机环境(例如)的值来填充Java系统属性,该值将唯一地标识作业的实例。

You could populate the Java system property with a value from the host's environment (for example) that would uniquely identify the instance of the job.

这篇关于log4j日志文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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