Log4j Appender for sending slack messages
For now, depends on both gson and okhttp.
compile 'be.olsson:slack-appender:0.99.7'
<dependency>
<groupId>be.olsson</groupId>
<artifactId>slack-appender</artifactId>
<version>0.99.7</version>
</dependency>
Example with both Console and Slack
log4j.appender.Foo=org.apache.log4j.ConsoleAppender
log4j.appender.Foo.layout=org.apache.log4j.PatternLayout
log4j.appender.Foo.layout.conversionPattern=%-5p - [%t] %-26.26c{1} - %m\n
log4j.appender.Bar=be.olsson.slackappender.SlackAppender
log4j.appender.Bar.layout=org.apache.log4j.PatternLayout
log4j.appender.Bar.layout.conversionPattern=%-5p - [%t] %-26.26c{1} - %n
log4j.rootLogger=INFO,Foo,Bar
Minimal:
log4j.appender.Slack=be.olsson.slackappender.SlackAppender
log4j.rootLogger=INFO,Slack
compile 'be.olsson:slack-appender:*'
<dependency>
<groupId>be.olsson</groupId>
<artifactId>slack-appender</artifactId>
<version>*TBD*</version>
</dependency>
Example with both Console and Slack (but only error logging goes on slack)
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="StdOut" target="SYSTEM_OUT">
<PatternLayout pattern="%-5p - [%t] %-26.26c{1} - %X{tag} - %m\n"/>
</Console>
<Slack name="Slack" channel="log4jslackchannel">
<PatternLayout pattern="%-5p - [%t]"/>
</Slack>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="StdOut"/>
<AppenderRef ref="Slack" level="error"/>
</Root>
</Loggers>
</Configuration>
Minimal:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Slack name="Slack" channel="log4jslackchannel">
<PatternLayout pattern="%-5p - [%t]"/>
</Slack>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Slack" level="info"/>
</Root>
</Loggers>
</Configuration>
./gradlew build
Please note that the tests will NOT work unless SLACK_WEBHOOK
is set as an environment variables (or java property or ~/.gradle/gradle.properties).
SLACK_WEBHOOK=https://hooks.slack.com/services/xxxxxx/yyyyyyy/zzzzzzz ./gradlew release