java - How to change log path in log4j2 at execution time -


hi using slf4j on log4j2. how change log path dynamically?

my log4j2.xml looks like

   <properties>         <property name="home">/path/logs</property>     </properties>     <appenders>         <rollingfile name="default" filename="${home}/error.log"                      filepattern="...">                .......          </rollingfile>     </appenders> 

is there way can change path logs written @ runtime?

i tried having system property in path , setting in runtime log4j2 not consider updated value. system properties approach-

<rollingfile name="default" filename="${sys:home}/error.log"                      filepattern="...">  (in java class: system.setproperty("home","/newpath")) 

does require reconfiguration. don't see exposed service of slf4j reconfigure.

use domconfigurator.doconfigure(), second parameter logmanager.getloggerrepository(). way can change not logging path, else too, including levels specific loggers, example.

i don't think can reconfigure slf4j implementation using "implementation-agnostic" way. when switched our application log4j logback, changed way configuration file re-read in runtime. logback uses joranconfigurator.doconfigure().


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -