is there a way to choose if I want to have a logback appender or not, via environment variable?
I have a dockerized spring boot Microservice and added now the ELK stack.
That works fine so far.
But now if I want to start my service without ELK stack, the application throws an error, that it doesn't know the host of Logstash:
app | 10:09:23,537 |-ERROR in ch.qos.logback.classic.net.SyslogAppender[SYSLOG] - Could not create SyslogWriter java.net.UnknownHostException: logstash: Name or service not known
app | at java.net.UnknownHostException: logstash: Name or service not known
Here is my logback.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="SYSLOG" class="ch.qos.logback.classic.net.SyslogAppender">
<syslogHost>logstash</syslogHost>
<port>5000</port>
<facility>LOCAL1</facility>
<suffixPattern>[%thread] %logger %msg</suffixPattern>
</appender>
<root level="INFO">
<appender-ref ref="SYSLOG"/>
</root>
</configuration>
I know this is a very simple version, but I am new in logging with logback/ELK stack.
So is there a way to inject something with an environment variable like in yaml files e.g. active=${LOGBACK_ACTIVE:false}
like I can do it with my prometheus metrics?