-
Use case : create a logger with 1 kind of sink, but add another sink later. Let's say I create a console sink at the program start-up. Then later on in program execution I decide that I need a file logger as well. I'm finding that calling
When I run this I only get logs on console. It creates a log file, but no logs are written to it. If I pass down both sinks for the same |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey, the API doesn't allow that because it wouldn't be safe. Allowing this would require the backend worker thread to either take a lock or a thread-safe check for updated sinks before forwarding each log message, which would introduce performance overhead. Once a
You have a few options:
Let me know if you need further help! |
Beta Was this translation helpful? Give feedback.
Hey, the API doesn't allow that because it wouldn't be safe. Allowing this would require the backend worker thread to either take a lock or a thread-safe check for updated sinks before forwarding each log message, which would introduce performance overhead. Once a
Logger
is created, new sinks cannot be added.quill::Frontend::create_or_get_logger
ensures that a logger with a givenlogger_name
is created only once. If the logger already exists, the existing instance is returned instead of creating a new one—this is why you see only a single sink.You have a few options:
Use a different logger name and simply switch to using the latest created logger (simplest and recommended)
auto logger…