Giter Site home page Giter Site logo

slacklogger's Introduction

Slack Logger

Download

Slack Logger is a custom log4j appender which logs directly to a Slack channel.

Slack Logger

Requirements

  • Slack account with Incoming WebHooks integration

Setup

Slack

  • Create an Incoming WebHooks integration
  • Select a channel to post messages to
    • NOTE: This can be overwritten in the config. This is helpful if multiple projects use the same webhook.
  • Add the WebHook url to the config as shown below

Dependency managment

Add this into your build.gradle:

repositories {
	maven { url "http://dl.bintray.com/theconnman/plugins" }
}
dependencies {
	compile "org.grails.plugins:slacklogger:2.0.2"
}

Config

All config items contain the prefix grails.plugin.slacklogger.

NOTE: Config items with * after them are secret information. It is highly reccommended to put this information in secret files and pull it into the Grails project at runtime.

  • webhook - The WebHook URL provided by Slack*
  • channel - The channel to post to [Optional]
  • botName - The name of the bot which the message will be posted as [Optional]
  • colors - Map of colors which log attachments will be posted with [Optional]
    • Default
       [
           INFO: '#5f9ea0',
           TRACE: '#6f6d6d',
           DEBUG: '#b5dae9',
           WARN: '#ff9122',
           ERROR: '#ff4444',
           FATAL: '#b03e3c'
       ]
      

Use

Slack Logger creates a new Logback appender which can be used like a normal appender in logback.groovy. Below is an example configuration of a new appender:

import com.theconnman.slacklogger.SlackAppender
...
appender('SLACK', SlackAppender) {
	encoder(PatternLayoutEncoder) {
		pattern = "%logger - %msg%n"
	}
}

The appender pattern above will produce messages which look like the image at the top of the readme. Removing the time and the level from the log pattern is recommended because the time and level will appear on the Slack message by default.

Development

To run the project in development clone the repository and run the following:

grails -Dgrails.SLACK_WEBHOOK=[your Slack webhook] run-app

Then go to http:/localhost:8080/test to receive a test message.

slacklogger's People

Contributors

magx2 avatar theconnman avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

magx2

slacklogger's Issues

How to use?

Hi,

Thanks a lot for this wonderful plugin. but unfortunately i am not understanding how to use the slack appender in my log4j file. Will be great if you could add more additional information about it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.