如何从非src文件夹强制log4j加载xml配置? [英] How to force log4j load xml config from non src folder?

查看:192
本文介绍了如何从非src文件夹强制log4j加载xml配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从源根目录中加载不同目录的log4j.xml以及如何加载? (以编程方式?)意味着它在FS中的某个地方而不仅仅是在类路径中。

Is it possible to have log4j.xml loaded from a different dir than source root and how? (programmatically?) Meaning that it's somewhere in FS not just in classpath.

推荐答案

使用DOMConfigurator 您可以指定用于配置log4j的XML文件。

Using DOMConfigurator you can specify the the XML file used to configure log4j.

DOMConfigurator.configure("/path/to/log4j.xml");

对于log4j.properties,您可以使用 PropertyConfigurator

For log4j.properties you can do the same thing with PropertyConfigurator.

PropertyConfigurator.configure("/path/to/log4j.properties");

这篇关于如何从非src文件夹强制log4j加载xml配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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