Nlog: InternalLogger: Add Impersonation Capability

Created on 16 Oct 2019  路  4Comments  路  Source: NLog/NLog

Request: I would like the ability to impersonate another user before writing to the InternalLogger.
Benefit: It will be easier for me to deal with app pool rights to shared drives/folders if I can impersonate another user via code. We run our app pools under the default app pool user in IIS and I'd like to output the nlog internal file to a shared drive.
Side Note: I am able to successfully use impersonation for targets when writing to a file, so that type of logging I can cover with another user easily enough. It's just the InternalLogger that I would like this ability.
Dev Environment: .Net Framework 4.6.1. Visual Studio 2015/2019.
Config File: I do not use a config file for nlog currently. I'm configuring everything in code. The relevant code is:

  InternalLogger.LogLevel = LogLevel.Debug; 
  InternalLogger.LogFile = "z:\\nloginternal.txt";
question

All 4 comments

Hi! Thanks for opening your first issue here! Please make sure to follow the issue template - so we could help you better!

I guess you are waiting for the this feature:

https://github.com/NLog/NLog/issues/3350

But until then you can assign InternalLogger.LogWriter and make you own custom TextWriter that implements Impersonation Capability.

Remember NLog InternalLogger is intended as an easy lightweight diagnostic tool. Adding heavy overhead and platform specific features is not going in that direction.

Hi Rolf, thanks for getting back with me. Thank you for the advice, I will implement my own custom TextWriter.

I assume your question has been answered, if not, please let us know!

Was this page helpful?
0 / 5 - 0 ratings