I want to put all my config files in a /config
subfolder of my application directory. Log4j is expecting the log4j.properties file in the root folder of my application. Is there a way to tell log4j where to look for the properties file?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
You can use
PropertyConfigurator
to load your log4j.properties wherever it is located in the disk.Example:
If you have an XML Log4J configuration, use DOMConfigurator instead.
Refer to this example taken from - http://www.dzone.com/tutorials/java/log4j/sample-log4j-properties-file-configuration-1.html
To change the logger levels -
Logger.getRootLogger().setLevel(Level.INFO);
Yes, define
log4j.configuration
propertyNote, that property value must be a URL.
For more read section 'Default Initialization Procedure' in Log4j manual.
This is my class : Path is fine and properties is loaded.
Use the PropertyConfigurator: PropertyConfigurator.configure(configFileUrl);
In Eclipse you can set a VM argument to: