Property Substitution - lookup default value?

2018-03-01 Thread Michael Heinen
I would like to use a system var in the file name. If it is not 
specified an environment var should be used as fallback.


I tried
1) fileName="${sys:valueA:-env:valueB}/foo.log"
2) fileName="${sys:valueA:-${env:valueB}}/foo.log"
3) 
    ${env:valueB}
    
    fileName="${sys:valueA}foo.log"

None of them worked.
Is there any way to achieve this?

Thanks,
Michael



-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: Programmatically added loggers lost due to automatic reconfiguration

2017-10-10 Thread Michael Heinen

Thanks Gary!
That was exactly what I was looking for.

Michael

Am 06.10.2017 um 17:09 schrieb Gary Gregory:

Hi Michael,

How about
using 
org.apache.logging.log4j.core.config.Configuration.addListener(ConfigurationListener)
?

Gary



On Fri, Sep 29, 2017 at 6:30 AM, Michael Heinen <mhn4...@googlemail.com>
wrote:


I use Log4j 2.9.1 with the XML configuration. A monitorInterval is
specified in the XML config in order to reconfigure log4j, e.g. for
debugging.
Besides the XML configuration some loggers and appendes are created
dynamically in Java.

Problem:
The dynamically added loggers and appenders are lost after the XML
configuration has been reloaded.


LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();

Appender appender = RollingFileAppender.newBuilder()...
config.addAppender(appender);

LoggerConfig loggerConfig = LoggerConfig.createLogger(...)
loggerConfig.addAppender(appender, null, null);
config.addLogger(loggerName, loggerConfig);
ctx.updateLoggers();


Could the dynamically added loggers/appenders be isolated from the
automatic reconfiguration?
Is there another way to add them programamtically?

Thanks,
Michael


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org





-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Programmatically added loggers lost due to automatic reconfiguration

2017-09-29 Thread Michael Heinen
I use Log4j 2.9.1 with the XML configuration. A monitorInterval is 
specified in the XML config in order to reconfigure log4j, e.g. for 
debugging.
Besides the XML configuration some loggers and appendes are created 
dynamically in Java.


Problem:
The dynamically added loggers and appenders are lost after the XML 
configuration has been reloaded.



LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();

Appender appender = RollingFileAppender.newBuilder()...
config.addAppender(appender);

LoggerConfig loggerConfig = LoggerConfig.createLogger(...)
loggerConfig.addAppender(appender, null, null);
config.addLogger(loggerName, loggerConfig);
ctx.updateLoggers();


Could the dynamically added loggers/appenders be isolated from the 
automatic reconfiguration?

Is there another way to add them programamtically?

Thanks,
Michael


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org