Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds support for logback encoders (the message field is encoded). #794

Merged
merged 1 commit into from
Nov 28, 2019

Conversation

jeacott1
Copy link

@jeacott1 jeacott1 commented Nov 18, 2019

adds support for logback encoders (the message field is encoded)
adds support for global tags and extras (not threadbound). tags and extras are
distinguished by the existing mdcTags property.

basic usage:
encoders

    <appender name="jsonSentryAppender" class="io.sentry.logback.SentryAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>WARN</level>
        </filter>
        <encoder
            class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
           <providers>
               <timestamp />
                <version />
                <logLevel />
                ...

basic usage:
global entries as tags or extras

  LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory();
  context.putProperty("global", "value");

@jeacott1 jeacott1 force-pushed the logback-appender-mod branch 4 times, most recently from eaa118f to cafb55b Compare November 18, 2019 23:12
adds support for global tags and extras. tags and extras are
 distinguished by the existing mdcTags property.

basic usage:
encoders

```
    <appender name="jsonSentryAppender" class="io.sentry.logback.SentryAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>WARN</level>
        </filter>
        <encoder
            class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
           <providers>
               <timestamp />
                <version />
                <logLevel />
                ...
...
```

basic usage:
global entries as tags or extras

```

  LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory();
  context.putProperty("global", "value");

```
Copy link
Contributor

@metlos metlos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, apart from the one nitpick.

/**
* Appender encoder.
*/
protected Encoder<ILoggingEvent> encoder;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be at least AtomicReference and CAS'd on the use sites so that the unsynchronized access is somewhat handled? Or is it only ever supposed to be mutated by logback during instantiation and before any logging can occur?

Copy link
Author

@jeacott1 jeacott1 Nov 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as I understand it this isn't an issue. And yes, I think you'd typically create and replace with a new appender than dynamically replace an encoder.

fyi fwiw logstashencoder is doing the same thing:
https://github.com/logstash/logstash-logback-encoder/blob/bbd8333120f274f4d9ef12e797eae2331fed1a52/src/main/java/net/logstash/logback/appender/AbstractLogstashTcpSocketAppender.java#L199

@bruno-garcia bruno-garcia merged commit aaad367 into getsentry:master Nov 28, 2019
@bruno-garcia
Copy link
Member

Thank you @jeacott1

@jeacott1
Copy link
Author

should probably add something to the documentation too at some point :)

@bruno-garcia
Copy link
Member

@jeacott1
Copy link
Author

sure!

@bruno-garcia
Copy link
Member

Thank you @jeacott1

@jeacott1
Copy link
Author

please check getsentry/sentry-docs#1379

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants