question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to Configure Custom Logback Encoder/Layout

See original GitHub issue

I would like the ability to log output in JSON to help with ingesting them into an ELK setup. This can be accomplished by adding a custom Encoder or Layout on the appender. The current way of configuring appenders doesn’t expose this and so it must be done manually at run-time.

I don’t have a strong opinion but I feel like either layout or encoder would be fine, and that we shouldn’t use both. I see that there is already a layout being passed into AppenderFactory.build which may create some issues.

Ideally, we could just pass in a class name with a no-arg constructor as a string parameters in the appenders config section.

Would a PR that added this feature be welcome?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
ajmathcommented, Dec 31, 2015

For the curious, here is what I ended up doing to make this work.

https://gist.github.com/ajmath/e9f90c29cd224653c218

My only gripe is having to add the file META-INF/services file that contains my class name. Is there a way to have this done automatically via reflection?

0reactions
joschicommented, Mar 10, 2018

Closed via #2232

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chapter 6: Layouts - Logback
Configuring your custom layout. Custom layouts are configured as any other component. As mentioned earlier, FileAppender and its subclasses expect an encoder.
Read more >
Spring Boot : LOGBack custom fields in every log statement
No need to understand how LOGBack appender->Encoder->Layout work. ... %m%n # CONSOLE is set to be a ConsoleAppender using a PatternLayout. log4j.appender.
Read more >
Logstash Logback Encoder - GitCode - CSDN
For example, to configure global custom fields, you can specify <appender name="stash" class="net.logstash.logback.appender.
Read more >
Configuring Logback with Spring Boot - CodinGame
properties or for more complex needs you can use XML or Groovy to specify your settings. In this tutorial we will focus on...
Read more >
Configuring Logback With Spring Boot - DZone
In this tutorial, we will focus on using XML to define a custom logging configuration and look at some of the basics of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found