propertyconfigurator

Log4j Properties in a Custom Place

*爱你&永不变心* 提交于 2019-12-18 02:45:50
问题 I'm using Apache Commons Logging and SLF4J with log4j, but I also want to use the log4j.properties in a custom place like conf/log4.properties. Here is the problem: If i use PropertyConfigurator.configure("conf/log4j.properties"); then my app is tied to log4j and defeats the purpose of having ACL and SLF4J. What is the best way to configure it without the app ever knowing what the logging implementation is? 回答1: I think the easiest thing to do is specify the location of the file using the

Spring System Property Resolver Customization:

若如初见. 提交于 2019-12-13 04:42:22
问题 I am working on a project that requires me to take environment variables or system properties within a java spring application and modify them before they are injected into beans. The modification step is key for this application to work. My current approach to this is to set the variables as system environment variables and then use a custom placeholder configurer to access the aforementioned variables and create new properties from them that the beans can access. There is a perfect tutorial

Override log4j.properties

有些话、适合烂在心里 提交于 2019-11-29 03:22:01
My java application references a 3rd-party jar file which uses log4j logging. The problem is that this jar contains its own log4j.properties file which causes access denied exceptions on my machine, but I don't have control over the jar file to change its contents. I have tried adding my own log4j.properties file in my application's classpath, but it doesn't seem to have an effect. If I try to use PropertyConfigurator to import my own settings programmatically, log4j seems to load the jar file's properties file first (causing an exception). How can I short-circuit log4j to ignore a 3rd-party

Log4j Properties in a Custom Place

蹲街弑〆低调 提交于 2019-11-28 23:25:41
I'm using Apache Commons Logging and SLF4J with log4j, but I also want to use the log4j.properties in a custom place like conf/log4.properties. Here is the problem: If i use PropertyConfigurator.configure("conf/log4j.properties"); then my app is tied to log4j and defeats the purpose of having ACL and SLF4J. What is the best way to configure it without the app ever knowing what the logging implementation is? I think the easiest thing to do is specify the location of the file using the log4j.configuration system property. Adopting the example in the Log4J manual : java -Dlog4j.configuration=conf

Override log4j.properties

白昼怎懂夜的黑 提交于 2019-11-27 17:31:07
问题 My java application references a 3rd-party jar file which uses log4j logging. The problem is that this jar contains its own log4j.properties file which causes access denied exceptions on my machine, but I don't have control over the jar file to change its contents. I have tried adding my own log4j.properties file in my application's classpath, but it doesn't seem to have an effect. If I try to use PropertyConfigurator to import my own settings programmatically, log4j seems to load the jar