1

Is there a way to enter Active Directory credential when targeting a file?

On my company, there are multiple applications writing to a single log file with info like start, success or error. I'd like create a new target on my nlog.config file but the file is remote and requires user and password.

Is that possible in Nlog or should I go with the traditional classes of File and Impersonator?

Thanks, m0dest0.

m0dest0
  • 849
  • 4
  • 17
  • 36

1 Answers1

1

You need the 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" /> 

For other options, check the Wiki page of ImpersonatingWrapper

Julian
  • 33,915
  • 22
  • 119
  • 174