如何检查log4j2是否已配置 [英] How to check if log4j2 has been configured or not

查看:2065
本文介绍了如何检查log4j2是否已配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您不提供log4j2配置时,我们都熟悉此消息:

We're all familiar with this message when you don't provide a configuration for log4j2:

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

如何检查log4j2是否尚未配置,以便我可以使用默认配置进行初始化?

How can I check if log4j2 is not yet configured so that I can initialize with a default configuration if needed?

推荐答案

我最后创建了自己的ConfigurationFactory并注册

I ended up creating my own ConfigurationFactory and register it with

-Dlog4j.configurationFactory

这样你的ConfigurationFactory会知道是否已被调用。

That way your ConfigurationFactory will know whether it's been invoked yet or not.

这篇关于如何检查log4j2是否已配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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