maricn / logback-slack-appender

Logback appender for Slack messenger

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Messages not showing up in slack

vogelito opened this issue · comments

Hi,

I'm trying to get the appender to work without success. Any help would be greatly appreciated.

I'm currently running version 1.3.0.

This is my logback.xml:

<configuration debug="true">
  <appender name="SLACK" class="com.github.maricn.logback.SlackAppender">
    <!-- Slack API token -->
    <token>REMOVED</token>
    <!-- Channel that you want to post - default is #general -->
    <channel>#general</channel>
    <!-- Formatting (you can use Slack formatting - URL links, code formatting, etc.) -->
    <layout class="ch.qos.logback.classic.PatternLayout">
      <pattern>%-4relative [%thread] %-5level %class - %msg%n</pattern>
    </layout>
    <!-- Username of the messages sender -->
    <username>bot</username>
    <!-- Emoji to be used for messages -->
    <iconEmoji>:stuck_out_tongue_winking_eye:</iconEmoji>
  </appender>

  <!-- Currently recommended way of using 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>ERROR</level>
    </filter>
  </appender>

  <root>
    <level value="ALL" />
    <appender-ref ref="ASYNC_SLACK" />
  </root>
</configuration>

When I run I see:

11:13:35,228 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
11:13:35,228 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
11:13:35,229 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/home/ubuntu/logback/logback.xml]
11:13:35,441 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [com.github.maricn.logback.SlackAppender]
11:13:35,444 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [SLACK]
11:13:35,564 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.AsyncAppender]
11:13:35,569 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [ASYNC_SLACK]
11:13:35,569 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [SLACK] to ch.qos.logback.classic.AsyncAppender[ASYNC_SLACK]
11:13:35,569 |-INFO in ch.qos.logback.classic.AsyncAppender[ASYNC_SLACK] - Attaching appender named [SLACK] to AsyncAppender.
11:13:35,587 |-INFO in ch.qos.logback.classic.AsyncAppender[ASYNC_SLACK] - Setting discardingThreshold to 51
11:13:35,588 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - ROOT level set to ALL
11:13:35,588 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [ASYNC_SLACK] to Logger[ROOT]
11:13:35,588 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
11:13:35,592 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@38cccef - Registering current configuration as safe fallback point

However, I don't see anything in slack. I have verified there's output by changing to a different appender type.

Any help would be greatly appreciated :)

In order to confirm my API token is correct, I'm doing this:
curl -X POST -d 'token=SAME_TOKEN_AS_ABOVE&channel=#general&text=Test&username=bot' https://slack.com/api/chat.postMessage

I was able to determine what was wrong - I wasn't flushing the asyncappender. Thanks! Great little tool :)