Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I override the log4j properties file in my jar at runtime [duplicate]

Tags:

java

unix

jar

log4j

Possible Duplicate:
Dynamically Changing log4j log level

I have a jar file with a log4j properties file included. I tried to use

-Dlog4j.configuration=file:[filename]

to change the properties file at runtime using java, and it didn't work. I need to do this in a sh file Can anyone please tell me how to this? I also tried adding

-Dlog4j.defaultInitOverride=true
like image 304
user1741202 Avatar asked Jan 25 '13 18:01

user1741202


1 Answers

It's possible to override the log4j properties file at runtime. You may fall into this situation if you cann't :

  1. In your jar or somewhere in the code, the log4j system is initialised manually, e.g.

     URL url=loader.getResource(LOGGER_CONFIG_FILE)
     DOMConfigurator.configure(url);
    
like image 105
Jintian DENG Avatar answered Sep 20 '22 06:09

Jintian DENG