logback-slack-appender

Slack appender for Logback

License

License

Categories

Categories

Logback Application Layer Libs Logging
GroupId

GroupId

com.seoduct
ArtifactId

ArtifactId

logback-slack-appender
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

logback-slack-appender
Slack appender for Logback
Project URL

Project URL

https://github.com/bobvandenberge/logback-slack-appender
Source Code Management

Source Code Management

http://github.com/bobvandenberge/logback-slack-appender/tree/master

Download logback-slack-appender

How to add to project

<!-- https://jarcasting.com/artifacts/com.seoduct/logback-slack-appender/ -->
<dependency>
    <groupId>com.seoduct</groupId>
    <artifactId>logback-slack-appender</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.seoduct/logback-slack-appender/
implementation 'com.seoduct:logback-slack-appender:1.0.0'
// https://jarcasting.com/artifacts/com.seoduct/logback-slack-appender/
implementation ("com.seoduct:logback-slack-appender:1.0.0")
'com.seoduct:logback-slack-appender:jar:1.0.0'
<dependency org="com.seoduct" name="logback-slack-appender" rev="1.0.0">
  <artifact name="logback-slack-appender" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.seoduct', module='logback-slack-appender', version='1.0.0')
)
libraryDependencies += "com.seoduct" % "logback-slack-appender" % "1.0.0"
[com.seoduct/logback-slack-appender "1.0.0"]

Dependencies

compile (3)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.2.3
com.squareup.okhttp3 : okhttp jar 3.9.1
com.fasterxml.jackson.core : jackson-databind jar 2.9.4

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.16.20

test (3)

Group / Artifact Type Version
junit : junit jar RELEASE
org.hamcrest : hamcrest-all jar 1.3
com.squareup.okhttp3 : mockwebserver jar 3.9.1

Project Modules

There are no modules declared in this project.

CircleCI

Logback Slack Appender

This is a Slack appender for Logback, inspired on code of logback-slack-appender

Configuration

The minimum required configuration to get up and running is the following:


<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
    <!-- Create the Slack appender -->
    <appender name="SLACK" class="com.seoduct.logging.SlackAppender">
        <webhookUri>YOUR_SLACK_URL</webhookUri>
        <channel>#general</channel>
        <username>Slack Appender</username>
        <iconEmoji>:computer:</iconEmoji>
    </appender>

    <!-- Hook up the Slack appender --> 
    <root level="ALL">
        <appender-ref ref="SLACK"/>
    </root>

</configuration>

Running the appender asynchronous

By default the log appender will run synchronous. In most scenario's this is not what you want because now your process will have to wait on a Http call to finish. Therefore you should setup the log appender to run asynchronously. You can do this with the following configuration:

    <!-- Create an asynchronous appender for the SLACK appender. -->
    <appender name="ASYNC_SLACK" class="ch.qos.logback.classic.AsyncAppender">
        <appender-ref ref="SLACK" />
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>WARN</level>
        </filter>
    </appender>

    <!-- Hook up the asynchrounous Slack appender --> 
    <root level="WARN">
        <appender-ref ref="ASYNC_SLACK" />
    </root>

Changing the default format

It is possible to specify a different logging format by declaring a different layout:

    <appender name="SLACK" class="com.seoduct.logging.SlackAppender">
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>*%-8level* ` %-36logger{36} ` - %msg %n ``` Stack trace: %ex{3} ```</pattern>
        </layout>
        <!-- Other fields removed for readability... -->
    </appender>

Versions

Version
1.0.0