I have two appenders: console and Kibana appender. When running on dev environment I want to have possibility to disable Kibana appender.
I've tried multiple way to achieve it, but nothing works:
How to remove appender from logger in log4j2 programmatically? - even if I remove appender it still sends logs
How do I conditionally add log4j2 appender depending on java system property?
<AppenderRef ref="elasticsearchAsyncBatch" level="${sys:logLevel:-all}"/>
- appender ignore variables passed from command line via: export LOG_LEVEL=off and always use default value, all in this example. Script solutions has the same problem<ThresholdFilter level="${sys:logLevel}" onMatch="ACCEPT" onMismatch="DENY"/>
- level attribute doesn't accept dynamic values and throws error that it cannot cast "${sys:logLevel}" to Level enum
Log4j ver 2.11.2