tobias- / slack-appender

Slack Appender for Log4j
MIT License
8 stars 1 forks source link

Webhook URL from environment variable? #8

Closed mangatmodi closed 4 years ago

mangatmodi commented 4 years ago

Currently the library take webhook url from the log4j2.xml configuration. However webhook url is a secret, hence I could not expose it in the source code. Is there a way I can inject the url from the environment?

If not, then I would be happy to create the PR for it.

mangatmodi commented 4 years ago

My bad. I didn't realize that we can always access environment variables in the configuration file. Here is an example working for me

        <Slack name="Slack"
               channel="channel-name"
               webhookUrl="${env:SLACK_WEBHOOK:-default_url}"
        >
            <PatternLayout pattern="%-5p - [%t]"/>
        </Slack>