Slack Appender for log4js-node
npm install @log4js-node/slackSends log events to a slack channel. This is an optional appender for use with log4js.
``bash`
npm install @log4js-node/slack
* type - @log4js-node/slacktoken
* - string - your Slack API token (see the slack and slack-node docs)channel_id
* - string - the channel to send log messagesicon_url
* - string (optional) - the icon to use for the messageusername
* - string - the username to display with the messagelayout
* - object (optional, defaults to basicLayout) - the layout to use for the message (see layouts).
`javascript`
log4js.configure({
appenders: {
alerts: {
type: '@log4js-node/slack',
token: 'abc123def',
channel_id: 'prod-alerts',
username: 'our_application'
}
},
categories: {
default: { appenders: ['alerts'], level: 'error' }
}
});prod-alerts
This configuration will send all error (and above) messages to the slack channel, with the username our_application`.