Update NLog target filename at runtime

前端 未结 7 1694
被撕碎了的回忆
被撕碎了的回忆 2020-12-05 18:14

In my application, I work on several thousand of document a day. I\'d like, in some cases some logs, one log by document. Then I\'d like for a specific target change the out

7条回答
  •  不知归路
    2020-12-05 19:04

    For anyone stuck on this, I finally found a solution. I was trying to update some syslog target settings at runtime and nothing was working. Simply updating the configuration does not work, you need to reset the Configuration object, which is as simple as doing this:

    LogManager.Configuration = LogManager.Configuration;
    

    This causes an internal event to fire and actually use the updated configuration.

提交回复
热议问题