Skip to content

Add sink after logger has been created #658

Answered by odygrd
persona94 asked this question in Q&A
Discussion options

You must be logged in to vote

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 given logger_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:

  1. Use a different logger name and simply switch to using the latest created logger (simplest and recommended)

    auto logger…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@persona94
Comment options

Answer selected by persona94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants