简体   繁体   English

我需要与log4j v2等效的log4j v4 PropertyConfigurator.configure

[英]I need log4j v4 equivalent of log4j v2 PropertyConfigurator.configure

I am switching from log4j version 1 to log4j version 2. I need to duplicate the functionality of the method with this signature: 我正在从log4j版本1切换到log4j版本2。我需要使用以下签名来复制方法的功能:

org.apache.log4j.ProperyConfigurator.configure(InputStream s);

That is, I need to programmatically set the log4j properties from an InputStream. 也就是说,我需要以编程方式从InputStream设置log4j属性。 Using an explicit log4j.properties file is not an option in my environment. 在我的环境中,不能使用显式的log4j.properties文件。

Also note that this is for a client, not a server/servlet. 另请注意,这是针对客户端的,而不是针对服务器/ servlet的。

How do I do the equivalent in log4j version 2? 在log4j版本2中,我该如何做?

外观上看,没有简单的方法,您可能必须扩展log4j并定义自己的ConfigurationFactory实现

Before you write any custom code, I'd recommend asking your question on the log4j user mailing list. 在编写任何自定义代码之前,建议您在log4j用户邮件列表中询问您的问题。 That may save you some effort. 这样可以节省您一些精力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM