Why does spdlog::register_logger()
throw an exception?
#3226
Replies: 1 comment
-
Loggers with the same name cannot be registered in spdlog's logger registry. The reason why You are using an API that is not designed to replace sinks. You can use spdlog/include/spdlog/sinks/dist_sink.h Lines 42 to 45 in e593f66 |
Beta Was this translation helpful? Give feedback.
-
Hey,
For my application I need to be able to dynamically change the logging directory. Looking at the code I've noticed that the function
spdlog::set_default_logger()
can be invoked multiple times and will replace the default logger being used by spdlog in a manner that is thread safe.spdlog::register_logger()
doesn't behave the same way. The way spdlog works currently actually requires that we invoke 'spdlog::drop()` before replacing the logging target. Like so:We aren't able to replace a non-default logging sink, only the default logger can be replaced in a thread-safe manner. Is there a reason for this?
Thanks,
Beta Was this translation helpful? Give feedback.
All reactions