How Thread-Safe is NLog?

后端 未结 6 1958
慢半拍i
慢半拍i 2020-12-02 23:23

Well,

I have waited for days before deciding to post this issue, as I was not sure how to state this, resutling into a long detailed post. However, I think it is re

6条回答
  •  再見小時候
    2020-12-02 23:38

    This is an older question, but as current owner of NLog I have the following insights:

    • Creating a logger is thread-safe
    • Writing log messages is thread-safe
    • Usage of the context classes and renderers are (GDC, MDC etc) thread-safe
    • Adding new targets + rules at runtime is thread-safe (When using LoggingConfiguration.AddRule + ReconfigExistingLoggers)
    • Performing Reload of LoggingConfiguration will cause LogEvents from active loggers to be dropped until reload has completed.
    • Changing values of existing rules and targets at run-time isn't thread-safe!

    You should avoid changing the values of existing items at runtime. Instead one should use the context renderers (${event-properties}, ${GDC}, ${MDLC}, etc.)

提交回复
热议问题