Coder Social home page Coder Social logo

tersesystems / terse-logback Goto Github PK

View Code? Open in Web Editor NEW
195.0 7.0 14.0 3.65 MB

Structured Logging, Tracing, and Observability with Logback

Home Page: https://tersesystems.github.io/terse-logback/

License: Other

Java 100.00%
logback slf4j json structured-logging slf4j-api logstash-logback-encoder honeycomb

terse-logback's People

Contributors

eudes avatar shipkit-org avatar sullis avatar will-sargent-eero avatar wsargent 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

terse-logback's Issues

Using multiple censors does not apply all censors

Describe the bug
When using censors, if multiple are applied to net.logstash.logback.encoder.LogstashEncoder using com.tersesystems.logback.censor.CensoringJsonGeneratorDecorator, the last censor-ref "wins" and the others are ignored.

To Reproduce

Expected behavior
I expected both censors to be applied to logs, but only the last censor listed in the configuration is applied.

Screenshots
(Not a screenshot, but here's the output I'm seeing)

13:51:37,844 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
13:51:37,845 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/Users/tim.walter/dev/terse-logback/java/target/classes/logback.xml]
13:51:37,887 |-INFO in ch.qos.logback.core.joran.action.NewRuleAction - About to add new Joran parsing rule [*/censor,com.tersesystems.logback.censor.CensorAction].
13:51:37,887 |-INFO in ch.qos.logback.core.joran.action.NewRuleAction - About to add new Joran parsing rule [*/censor-ref,com.tersesystems.logback.censor.CensorRefAction].
13:51:37,888 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word censor with class [com.tersesystems.logback.censor.CensorConverter]
13:51:37,888 |-INFO in com.tersesystems.logback.censor.CensorAction - About to instantiate censor of type [com.tersesystems.logback.censor.RegexCensor]
13:51:37,889 |-INFO in com.tersesystems.logback.censor.CensorAction - Naming censor as [hunter2]
13:51:37,892 |-INFO in com.tersesystems.logback.censor.CensorAction - About to instantiate censor of type [com.tersesystems.logback.censor.RegexCensor]
13:51:37,892 |-INFO in com.tersesystems.logback.censor.CensorAction - Naming censor as [social-security-number]
13:51:37,893 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
13:51:37,895 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
13:51:37,912 |-INFO in com.tersesystems.logback.censor.CensorRefAction - Attaching censor named [hunter2] to com.tersesystems.logback.censor.CensoringJsonGeneratorDecorator@35b3557eat 27
13:51:37,912 |-INFO in com.tersesystems.logback.censor.CensorRefAction - Attaching censor named [social-security-number] to com.tersesystems.logback.censor.CensoringJsonGeneratorDecorator@35b3557eat 28
13:51:38,020 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
13:51:38,020 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
13:51:38,020 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
13:51:38,021 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@1188cc16 - Registering current configuration as safe fallback point
{"@timestamp":"2022-09-22T13:51:38.022-04:00","@version":"1","message":"hunter2","logger_name":"io.github.dutchmahoney.terselogbackcensorsexample.Main","thread_name":"io.github.dutchmahoney.terselogbackcensorsexample.Main.main()","level":"INFO","level_value":20000}
{"@timestamp":"2022-09-22T13:51:38.03-04:00","@version":"1","message":"[CENSORED: Social Security Number: 000-11-XXX2]","logger_name":"io.github.dutchmahoney.terselogbackcensorsexample.Main","thread_name":"io.github.dutchmahoney.terselogbackcensorsexample.Main.main()","level":"INFO","level_value":20000}
{"@timestamp":"2022-09-22T13:51:38.041-04:00","@version":"1","message":"SocialSecurityNumber[socialSecurityNumber[CENSORED: Social Security Number: 000-11-XXX2]","logger_name":"io.github.dutchmahoney.terselogbackcensorsexample.Main","thread_name":"io.github.dutchmahoney.terselogbackcensorsexample.Main.main()","level":"INFO","level_value":20000}

Desktop (please complete the following information):

  • OS: MacOS
  • Version: 12.6

Additional context
Nothing more to add but "thanks!"

Potential security vulnerability in the zstd C library.

Hi, @sullis , @eudes , I'd like to report a vulnerability issue in com.tersesystems.logback:logback-compress-encoder:1.0.2.

Issue Description

I noticed that com.tersesystems.logback:logback-compress-encoder:1.0.2 directly depends on com.github.luben:zstd-jni:v1.4.0-1 in the pom. However, as shown in the following dependency graph. However, com.github.luben:zstd-jni:v1.4.0-1 sufferes from the vulnerability which the C library zstd(version:1.4.0) exposed: CVE-2021-24031.

Dependency Graph between Java and Shared Libraries

image (12)

Suggested Vulnerability Patch Versions

com.github.luben:zstd-jni:v1.4.9-1 (>=v1.4.9-1) has upgraded this vulnerable C library zstd to the patch version 1.4.9.

Java build tools cannot report vulnerable C libraries, which may induce potential security issues to many downstream Java projects. Could you please upgrade this vulnerable dependency?

Thanks for your help~
Best regards,
Helen Parr

Define default logging for uncaught exceptions, especially asserts

Currently in the JDK, an failed assert will throw an AssertionError. Because the default uncaught exception handler doesn't have any kind of handling of AssertionError, this means that there's no logging or tracking of a failed assert past the stacktrace.

On top of that, assertions are only enabled if you have -ea set in the Java runtime.

https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.UncaughtExceptionHandler.html

https://docs.oracle.com/javase/11/docs/api/java/lang/AssertionError.html

http://www.javapractices.com/topic/TopicAction.do?Id=229

On one hand, this makes assertions a pain in a live environment. On the other hand, enabling assertions in a test suite could be a great way to add extra conditions and terminate early without binding junit code directly into executable code -- a junit assert can happen in a test, but you can stick assert anywhere in the codebase.

Assertion handling in particular is far more interesting than the documentation makes it out to be.

https://docs.oracle.com/javase/7/docs/technotes/guides/language/assert.html#design-faq-general

For example, you can turn on assertions dynamically for a package or a single class, using the classloader! Sadly only seems to apply when the class is first loaded, so you can't change it after that (or can you?)

https://docs.oracle.com/javase/9/docs/api/java/lang/ClassLoader.html#setPackageAssertionStatus-java.lang.String-boolean-

At the very least, assertions should trigger a dump of diagnostic logging statements associated with the thread, i.e. from Blacklite so that the operations leading up to the assertion are visible.

Why does logback have a dependency to audio libraries?

We have seen an open vulnerability using OWASP checks in logback because of an audio module in logback:
https://nvd.nist.gov/vuln/detail/CVE-2018-14948

The dependency: https://github.com/Trilarion/java-vorbis-support

However, I could not find any documentation on why logback needs this audio module besides of this: https://tersesystems.com/blog/2019/05/18/application-logging-in-java-part-4/

Unfortunately, this tutorial doesn't explain the use case.
Is it really necessary for a logging library to have a dependency to audio libraries?

Structured logging vs console output

Is your feature request related to a problem? Please describe.
We have been using structured logging directly to console for quite some time for our kubernetes JVMs. However it seems the current implementation of this library only supports JSON to file.

Describe the solution you'd like
Support JSON output to console as well, for deployed (production) workloads. For local development, we like plain old one-line logging. Unit testing against resulting JSON output should still work in development.

Describe alternatives you've considered
None

Additional context
Our agent requires "one linebreak per log statement".

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.