You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Nandan S <na...@hp.com> on 2014/02/21 04:19:57 UTC
how to retain values using configureAndWatch()
Hi,
i use DOMConfigurator::configureAndWatch(configFile,delay) method to
check for any configuration changes and reload the configuration. But facing
the following issue
after calling configurationAndWatch(), i use the
appender->setFile(logFileNameL); appender->activateOptions(p); to change the
file name to which the log messages will be appended. Later, if i change
anything in configFile, configuration file is reloaded and messages will be
logged to file specified in configuration file where in i want to log
messages to be logged to logFileNameL set programtically.
Is there anyway the values set in program can be retained after
reloading the configuration file by configureAndWatch() method.
to make it more specific
in configuration file
in application, i set
appender->setFile("c:\temp\testApp_logFile.log");
later in configuration file, i change the threshold level, so
configureAndWatch() method will reload the configuration file and starts
logging to "c:\temp\logFile.log". wherein i want to continue logging to
"c:\temp\testApp_logFile.log" with changed logging level.
Is it possible to achieve this ? if yes, do let me know more details.
Thanks in advance.
Regards,
Nandan
--
View this message in context: http://apache-logging.6191.n7.nabble.com/how-to-retain-values-using-configureAndWatch-tp44700.html
Sent from the Log4cxx - Users mailing list archive at Nabble.com.
Re: how to retain values using configureAndWatch()
Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Nandan S,
am Freitag, 21. Februar 2014 um 04:19 schrieben Sie:
> Is there anyway the values set in program can be retained after
> reloading the configuration file by configureAndWatch() method.
Doesn't look like, what you could do is overriding
DOMConfigurator::configureAndWatch from domconfigurator.cpp with an
own implementation, which doesn't use the default XMLWatchdog, but
again another subclass of those from your which overrides the method
doOnChange. Both implementations seem fairly easy and you only need to
call the base of doOnChange and afterwards your code to change the
configuration.
If you don't want to take this effort your best bet would be to not
use hard coded filenames, but simply something like environment
variables which can be set differently in the rpogram using your log
configuration. In the following example ${mandant} is coming from the
env set by the application:
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="FileNamePattern"
value="..\..\..\Datenserver\Logdateien\dbxml\dbxml\${mandant}\%d{yyyy-MM}.log"
/>
</rollingPolicy>
Mit freundlichen Grüßen,
Thorsten Schöning
--
Thorsten Schöning E-Mail:Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme http://www.AM-SoFT.de/
Telefon...........05151- 9468- 55
Fax...............05151- 9468- 88
Mobil..............0178-8 9468- 04
AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow