Ability to Configure Custom Logback Encoder/Layout
See original GitHub issueI 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:
- Created 8 years ago
- Comments:13 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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?
Closed via #2232