Buffering log messages in NLog and manually flushes them to target

后端 未结 1 862
轻奢々
轻奢々 2021-01-02 06:15

I am trying to log via the NLog MailTarget. It works just fine, but i wanted to wrap the mailtarget with the BufferedTargetWrapper to buffer the log messages un

1条回答
  •  一向
    一向 (楼主)
    2021-01-02 07:08

    According to the documentation your approach should not work, but it is fine. Just give the flush method an empty lambda expression:

    LogManager.Configuration.AllTargets
        .OfType()
        .ToList()
        .ForEach(b => b.Flush(e =>
            {
                //do nothing here
            }));
    

    0 讨论(0)
提交回复
热议问题