Nlog 以及如何提供凭据以打开远程日志文件

Nlog and how to present credentials in order to open a remote log file

有没有办法在定位文件时输入 Active Directory 凭据?

在我的公司,有多个应用程序写入单个日志文件,其中包含启动、成功或错误等信息。我想在我的 nlog.config 文件上创建一个新目标,但该文件是远程文件并且需要用户名和密码。

这在 Nlog 中可行吗?还是我应该使用传统的 类 文件和模拟程序?

谢谢, m0dest0.

您需要ImpersonatingWrapper

<target xsi:type="ImpersonatingWrapper"
          name="wrapper1"
          userName="user1"
          password="tooDifficultPassword"
          revertToSelf="false"
          impersonationLevel="Impersonation"
          domain="Domain1"
          logOnType="Interactive"
          logOnProvider="Default">
    <target xsi:type="file" name="file1" /> 

对于其他选项,请检查 Wiki page of ImpersonatingWrapper