You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When start() is invoked, the CompositeJsonFormatter starts by creating its internal JsonFactory then assign it to the configured JsonProviders. The next step is to configure the JsonProviders with the LoggerContext and then to start them. The sequence of looks as follows:
Unfortunately, some providers like the AbstractPatternJsonProvider start parsing their pattern immediately when the JsonFactory is set instead of waiting until they are actually started (see AbstractPatternJsonProvider.java#L73). This means that no context is available to them to report parsing errors.
A comment in the AbstractPatternJsonProvider says that parsing must be done when the JsonFactory is set and not during start() because the latter is invoked by logstash's XML parser "too early" before the formatter had a chance to set the JsonFactory.
According to this last comment, it seems obvious that the CompositeJsonFormatter must set the context on the providers BEFORE setting the JsonFactory.
Note: everything works nicely when Logback is configured via an XML configuration file because logback takes care of setting the context on every components it creates. The context is therefore already set when the JsonFactory is injected by the CompositeJsonFormatter.
Things are getting more tricky when one configures logback programmatically... If I rely on the CompositeJsonFormatter to propagate and set the context the providers, everything will work except errors will never be reported.
The text was updated successfully, but these errors were encountered:
When
start()
is invoked, theCompositeJsonFormatter
starts by creating its internal JsonFactory then assign it to the configuredJsonProviders
. The next step is to configure the JsonProviders with the LoggerContext and then to start them. The sequence of looks as follows:Unfortunately, some providers like the
AbstractPatternJsonProvider
start parsing their pattern immediately when the JsonFactory is set instead of waiting until they are actually started (see AbstractPatternJsonProvider.java#L73). This means that no context is available to them to report parsing errors.A comment in the AbstractPatternJsonProvider says that parsing must be done when the JsonFactory is set and not during start() because the latter is invoked by logstash's XML parser "too early" before the formatter had a chance to set the JsonFactory.
According to this last comment, it seems obvious that the CompositeJsonFormatter must set the context on the providers BEFORE setting the JsonFactory.
Note: everything works nicely when Logback is configured via an XML configuration file because logback takes care of setting the context on every components it creates. The context is therefore already set when the JsonFactory is injected by the CompositeJsonFormatter.
Things are getting more tricky when one configures logback programmatically... If I rely on the CompositeJsonFormatter to propagate and set the context the providers, everything will work except errors will never be reported.
The text was updated successfully, but these errors were encountered: