更改log4j.properties的位置 [英] Change location of log4j.properties

查看:167
本文介绍了更改log4j.properties的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将所有配置文件放在我的应用程序目录的 / config 子文件夹中。 Log4j期待我的应用程序的根文件夹中的log4j.properties文件。有没有办法告诉log4j在哪里寻找属性文件?

I want to put all my config files in a /config subfolder of my application directory. Log4j is expecting the log4j.properties file in the root folder of my application. Is there a way to tell log4j where to look for the properties file?

推荐答案

是的,定义 log4j.configuration property

Yes, define log4j.configuration property

java -Dlog4j.configuration=file:/path/to/log4j.properties myApp

注意,该属性值必须是一个URL。

Note, that property value must be a URL.

有关更多阅读部分的默认初始化过程,请参阅 Log4j手册

For more read section 'Default Initialization Procedure' in Log4j manual.

这篇关于更改log4j.properties的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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