Limit Logback Email to Enrivonment

59 Views Asked by At

Although the Java project I'm working with contains different jconfig XML files per environment, it has one logback XML file for the entire project.

Inside, there is an SMTPAppender like:

    <appender name="ERROR_EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>ERROR</level>
        </filter>
        <SMTPHost>${logs.smtp.host}</SMTPHost>
        <To>@abc.com</To>
        <From>[email protected]</From>
        <Subject>[Error occurred in ${environment}</Subject>
    </appender>

As you see, access to the environment variable is available so can this be utilized to only send this ERROR_EMAIL in certain environments?

Thank you very much for your time!

0

There are 0 best solutions below