ProductPromotion
Logo

Java

made by https://0x3d.site

GitHub - tersesystems/echopraxia: Java Structured Logging API for Logback, Log4J2, and JUL
Java Structured Logging API for Logback, Log4J2, and JUL - tersesystems/echopraxia
Visit Site

GitHub - tersesystems/echopraxia: Java Structured Logging API for Logback, Log4J2, and JUL

GitHub - tersesystems/echopraxia: Java Structured Logging API for Logback, Log4J2, and JUL

mvnrepository License Apache

Echopraxia

Echopraxia is a Java logging API designed around structured logging.

What this means is that all arguments in a logging statement have a name and a value, for example:

logger.info("arg1 is {} and arg2 is {}", fb -> fb.list(
  fb.string("name", "value"),
  fb.number("age", 13)
));

writes out in logfmt as:

INFO 13.232 arg1 is name=value and arg2 is age=13

and in a JSON format as:

{
  "message": "arg1 is name=value and arg2 is age=13",
  "name": "value",
  "age": 13
}

What makes Echopraxia effective -- especially in debugging -- is that you can define your own mappings, and then pass in your own objects and render complex objects. For example, we can render a Person object:

Logger<PersonFieldBuilder> logger = LoggerFactory.getLogger(getClass(), PersonFieldBuilder.instance());

Person abe = new Person("Abe", 1, "yodelling");
abe.setFather(new Person("Bert", 35, "keyboards"));
abe.setMother(new Person("Candace", 30, "iceskating"));

logger.info("{}", fb -> fb.person("abe", abe));

And print out the internal state of the Person in both logfmt and JSON.

INFO 13.223 abe={Abe, 1, father={Bert, 35, father=null, mother=null, interests=[keyboards]}, mother={Candace, 30, father=null, mother=null, interests=[iceskating]}, interests=[yodelling]}

Echopraxia also has a "contextual" logging feature that renders fields in JSON:

var fooLogger = logger.withFields(fb -> fb.string("foo", "bar"));
fooLogger.info("This logs the 'foo' field automatically in JSON");

And has conditional logging based on fields and exceptions using JSONPath:

Condition c = (level, ctx) ->
    ctx.findString("$.exception.stackTrace[0].methodName")
        .filter(s -> s.endsWith("Foo"))
        .isPresent();
logger.error(c, "Only render this error if method name ends in Foo", e);

There is also a feature to change logging conditions dynamically using scripts.

Migration to 3.0

There are some changes in 3.0.x which require migration:

  • Logger<?> is no longer valid -- you must now specify Logger<SomeFieldBuilder> as there is no lower bound on wildcards.
  • You must add Logback or Log4J2 library dependencies explicitly (Echopraxia no longer pulls in Logback 1.2 or Log4J2 for you). Please see the installation page for details.
  • If you are extending or implementing a logger, the classes for abstract loggers and logger support have been moved to the spi package.
  • The default for all primitive (string, number, boolean) methods in FieldBuilder is now keyValue, you can override in your own field builder with fb.value as appropriate.
  • There is no Field.ValueField or Field.KeyValueField class any more, only Field interface.

Documentation

Please see the online documentation.

Examples

For the fastest possible way to try out Echopraxia, download and run the JBang script.

Simple examples and integrations with dropwizard metrics and OSHI are available at echopraxia-examples.

For a web application example, see this Spring Boot Project.

Scala API

There is a Scala API available at https://github.com/tersesystems/echopraxia-plusscala.

Benchmarks

Benchmarks are available at BENCHMARKS.md.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory