将log4j.properties转换为log4j.xml [英] Converting log4j.properties to log4j.xml
问题描述
我在任何地方都找不到如何在log4j.xml中指定常量的方法.例如,我的log4j.properties中有此常量:
I couldn't find anywhere how to specify constants in log4j.xml. For example, I have this constant in my log4j.properties:
#Log directory
dal.log.dir=/var/log/pojodal/
# Log filename
dal.log.file=pojodal.log
在属性文件的其他部分中,我按如下方式使用这些常量:
And I use these constants as follows, in other parts of the properties file:
log4j.appender.DRFA1.File=${dal.log.dir}/${dal.log.file}
如何在log4j.xml中实现相同的行为?
How to achieve the same behavior in log4j.xml?
推荐答案
您可以使用此在线服务转换完整的 log4j.properties
,在其中可以粘贴log4j.properties
,按转换"并复制新的log4j.xml
:
You can convert your complete log4j.properties
using this online service, where you can paste your log4j.properties
, press convert and copy your new log4j.xml
:
http://log4j-props2xml.appspot.com/
如果该Web应用程序处于脱机状态,也可以在自己的servlet容器中启动该应用程序……您可以在此处找到下载和源代码:
If that webapp is offline ... you can also start it in your own servlet container ... you find downloads and sources here:
https://github.com/jroyals/log4j-properties-converter/
This is explained in an answer to another question ... using XML internal entities here and using Java System Properties here.
这篇关于将log4j.properties转换为log4j.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!