如何在命令行上设置log4j级别? [英] How do I set log4j level on the command line?

查看:74
本文介绍了如何在命令行上设置log4j级别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我正在处理的类中添加一些log.debug语句,并且我希望在运行测试时在输出中看到它。我想在命令行上覆盖log4j属性,如下所示:

I want to add some log.debug statements to a class I'm working on, and I'd like to see that in output when running the test. I'd like to override the log4j properties on the command line, with something like this:

-Dlog4j.logger.com.mypackage.Thingie=DEBUG

我经常这样做。我特别感兴趣的是在命令行上传递它的方法。我知道怎么用配置文件来做,这不适合我的工作流程。

I do this kind of thing frequently. I am specifically only interested in a way to pass this on the command line. I know how to do it with a config file, and that doesn't suit my workflow.

推荐答案

log4j不支持这个直接。

log4j does not support this directly.

由于您不需要配置文件,因此您很可能使用编程配置。我建议您研究扫描所有系统属性,并根据此显式编程您想要的内容。

As you do not want a configuration file, you most likely use programmatic configuration. I would suggest that you look into scanning all the system properties, and explicitly program what you want based on this.

这篇关于如何在命令行上设置log4j级别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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