When a field that needs to access values from the context is passed in the config of LogWriting, it expects a component implementing logging.ContextFilter to be injected. Even if a component implementing logging.ContextFilter is passed, there is a random failure that arises when starting the server with the message:
your JSON application logging configuration includes fields that display information from the context, but no component is available that implements logging.ContextFilter
This is thrown by a check done in JSONLogFormatter's StartComponent(). JSONLogFormatter requires a context filter to be injected if it requires one. It expects ComponentLoggerManager to set the context filter in JSONLogFormatter.
Since the context filter is set in StartComponent() of ComponentLoggerManager, when JSONLogFormatter's StartComponent() is called first the service fails.
Solution
The check for context.Filter should be done only after ComponentLoggerManager has exectued StartComponent.
Move the check for context filter in to AlllowAccess() lifecycle instead of StartComponent() in JSONLogFormatter component
Summary
When a field that needs to access values from the context is passed in the config of
LogWriting
, it expects a component implementinglogging.ContextFilter
to be injected. Even if a component implementinglogging.ContextFilter
is passed, there is a random failure that arises when starting the server with the message:This is thrown by a check done in
JSONLogFormatter
'sStartComponent()
.JSONLogFormatter
requires a context filter to be injected if it requires one. It expectsComponentLoggerManager
to set the context filter inJSONLogFormatter
. Since the context filter is set inStartComponent()
ofComponentLoggerManager
, whenJSONLogFormatter
'sStartComponent()
is called first the service fails.Solution
The check for
context.Filter
should be done only afterComponentLoggerManager
has exectuedStartComponent
. Move the check for context filter in toAlllowAccess()
lifecycle instead ofStartComponent()
inJSONLogFormatter
component