Skip to content
Advertisement

Logback conversion rule parametrizing

Is there any way of parametrizing conversion rule in Logback? I’ve tried adding child nodes, additional attributes and I don’t see a way to do it.

JavaScript

I would like to add parameter that will be used by LongMessageConverter class.

My application is setup on Spring Boot and I am using Sl4J.

Advertisement

Answer

This is more a question around Logback than anything to do with Spring Boot. What you need to do is something similar to the MDCConverter. Within your pattern you would specify something like:

JavaScript

The 25 is an option made available to the Converter during the start() method call. It is identified as the first option. You could end up passing a number of options to the converter. This way the converter is generic for any number of patterns that you specify in your Logback configuration.

The start method would look like:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement