通过 JVM 参数进行 log4j 配置? [英] log4j configuration via JVM argument(s)?

查看:30
本文介绍了通过 JVM 参数进行 log4j 配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须设置/传递哪些变量作为 JVM 的参数才能使 log4j 正常运行?正确地我的意思是不要抱怨并打印到控制台.能不能看个典型的例子?

What variables do I have to set/pass as arguments to the JVM to get log4j to run properly? And by properly I mean not complain and print to the console. Can I see a typical example?

注意:我需要避免在应用程序中创建 log4j.properties 文件.

Note: I need to avoid creating a log4j.properties file in the application.

推荐答案

你有 log4j 配置文件吗?只需使用

Do you have a log4j configuration file ? Just reference it using

-Dlog4j.configuration={path to file}

其中 {path to file} 应该以 file:

where {path to file} should be prefixed with file:

如果您使用的是 log4j2,则需要使用

If you are working with log4j2, you need to use

-Dlog4j.configurationFile={path to file}

摘自答案 https://stackoverflow.com/a/34001970/552525

这篇关于通过 JVM 参数进行 log4j 配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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