Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactor Core should not initialize SLF4J immediately at startup #3967

Open
sagebind opened this issue Jan 15, 2025 · 0 comments
Open

Reactor Core should not initialize SLF4J immediately at startup #3967

sagebind opened this issue Jan 15, 2025 · 0 comments
Labels
type/enhancement A general enhancement

Comments

@sagebind
Copy link

Reactor initializes SLF4J logging to be initialized statically before a program's main method runs due to this static block:

static {
resetLoggerFactory();
}

This is less-than-ideal for us, since one of the first things we do in our main is do some housekeeping and SLF4J logger configuration. But because Reactor creates a logger factory statically and then logs a message to it here:

loggerFactory.apply(name).debug("Using Slf4j logging framework");

This forces SLF4J to initialize, and our logging implementation of choice (in our case Logback) to initialize before we've had a chance to configure it how we want to from within main. Reactor should not initialize and then immediately use an SLF4J logger statically.

Motivation

It seems unusual for Reactor to attempt to initialize so much statically. I have not yet run into any other library in the past near-decade since we've been using this method of configuring our logger that attempted to log statically. This is the first and only library that I've attempted to use that was not compatible with our method of configuring loggers.

Desired solution

It seems like other classes such as Hooks in my testing also run statically before main and emit logs, so I am not entirely sure what would have to change. But ideally, logging would be initialized lazily, and no logs should be attempted to be emitted until a Reactor class is actually used at normal runtime.

Considered alternatives

We could rewrite our stack to only use default logger paths and classes such that our logger is able to be initialized in the way we want it to before main gets to run, but this could be quite a bit of work to change for us.

Additional context

@sagebind sagebind added the type/enhancement A general enhancement label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant