Code Monkey home page Code Monkey logo

logback-slack-appender's People

Contributors

dependabot[bot] avatar eungjun-yi avatar larry0ua avatar maricn avatar nesoy avatar petokal avatar romani avatar vetler avatar vogelito avatar xi-cholo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

logback-slack-appender's Issues

Messages not showing up in slack

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 :)

colorCoding setting is failing in Logback and doesn't get picked up

Following the example given, everything works but I get an error on colorCoding in Logback's setup:
-ERROR in ch.qos.logback.core.joran.spi.Interpreter@46:18 - no applicable action for [colorCoding], current ElementPath is [[configuration][appender][colorCoding]]

This makes colorCoding stay set to false and I don't get that red color for errors.

workaround for OSSRH-66257

if using JDK 16 or JDK 17, the release will fail with the current nexus-staging-maven-plugin.. known bug: https://issues.sonatype.org/browse/OSSRH-66257

workaround (from https://stackoverflow.com/questions/70153962/nexus-staging-maven-plugin-maven-deploy-failed-an-api-incompatibility-was-enco):

export MAVEN_OPTS="--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED"

the other workaround to force the plugin to use the xtream dependency causes problems because there are vulnerabilities in the old versions, and the newer versions fail on another error..

Acceptance criteria

  • no local workaround needs to be applied in order to release (export MAVEN_OPTS)

Release a new version due to Jackson update

Dependabot upgraded the jackson-databind version several times in this project due to high / critical CVE issues in de-serialization.
Even when this appender does not use the unmarshaller methods scoped by the CVEs, it might be possible that applications using this appender will automatically pick up Jackson for marshalling.
Therefore I think it is a good idea to release a new version of the appender with the upgraded Jackson dependencies.

Messages show up in channel out of order

It seems that the messages I'm logging some times show up in Slack out of order. Is this a problem you've seen before?

My logback config looks something like this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

  <appender name="slackAppender" class="com.github.maricn.logback.SlackAppender">
      <token>xxxx-xxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxx</token>
      <channel>#xxxxxxxx</channel>
      <username>${HOSTNAME}</username>
  </appender>

  <appender name="asyncSlackAppender" class="ch.qos.logback.classic.AsyncAppender">
      <appender-ref ref="slackAppender" />
  </appender>

  <logger name="slackLogger">
    <appender-ref ref="asyncSlackAppender" />
  </logger>

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

</configuration>

Do not use channel name when using webhook URL

When you post messages to the Slack by webhook URL, channel name is not needed. Webhook URL is created for specific channel, so there is no need for channel name.

If you set correct channel name, it will work, but if you set different channel, it won't work.

There is no need to set channel name in this case, so use channel name only when token is used.

Exception thrown while using webhookurl while it is working fine when token is passed

Exception in thread "main" java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.joran.spi.Interpreter@8:15 - no applicable action for [webhookUri], current ElementPath  is [[configuration][appender][webhookUri]]
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:152)
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.reinitialize(LogbackLoggingSystem.java:195)
	at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:65)
	at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:50)
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:106)
	at org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:289)
	at org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:262)
	at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:231)
	at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:207)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:121)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:68)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:335)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)
	at employee.EmployeeBoot.main(EmployeeBoot.java:26)

Support Proxy environment

It would be great if proxy settings could be provided to the appender.

e.g. an complete Proxy object which would be used in the openConnection method

Throttle / Buffer Messages

Slack allows only 1 msg. per second per channel (Rate-Limits).

The Appender should buffer messages and send them by a max rate of 1 per second.
If the buffer grows over a defined limit, it may discard messages until the buffer size is below the threshold.

Slack sends HTTP status 429 when rate-limiting occurs. This includes a time when the next call can be made. This should also been taken into account.

There is a risk to get permanently banned. "Continuing to send messages after exceeding a rate limit runs the risk of your app being permanently disabled."

License

Hello @maricn,

Thank you for this repository.

What is the license of this repository? I'd like to you the SlackAppender class ( only that class ).

Could you specify a license?

Thank you,
Kiru

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.