snakefoot / NLog.WindowsIdentity

NLog extensions for displaying User Windows Identity and target wrapper for user impersonation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NLog.WindowsIdentity

NLog extensions for displaying User Windows Identity and target wrapper for user impersonation

Version AppVeyor

How to install

  1. Install the package

    Install-Package NLog.WindowsIdentity or in your csproj:

    <PackageReference Include="NLog.WindowsIdentity" Version="5.*" />
  2. Add to your nlog.config:

    <extensions>
        <add assembly="NLog.WindowsIdentity"/>
    </extensions>

    Alternative register from code using fluent configuration API:

    LogManager.Setup().SetupExtensions(ext => {
        ext.RegisterTarget<NLog.Targets.Wrappers.ImpersonatingTargetWrapper>();
        ext.RegisterLayoutRenderer<NLog.LayoutRenderers.WindowsIdentityLayoutRenderer>();
    });

Example of Windows Identity UserName

Example of NLog.config-file that outputs Windows Identity UserName:

<nlog>
    <extensions>
        <add assembly="NLog.WindowsIdentity"/>
    </extensions>
    <targets>
        <target name="console" xsi:type="console" layout="${message}|User=${windows-identity}"  />
    </targets>
    <rules>
        <logger minLevel="Info" writeTo="console" />
    </rules>
</nlog>

Example of Impersonating Windows Identity

Example of NLog.config-file that apply ImpersonatingWrapper:

<nlog>
    <extensions>
        <add assembly="NLog.WindowsIdentity"/>
    </extensions>
    <targets>
        <target name="userConsole" xsi:type="ImpersonatingWrapper" userName="xxx">
            <target name="console" xsi:type="console" layout="${message}|User=${windows-identity}"  />
        </target>
    </targets>
    <rules>
        <logger minLevel="Info" writeTo="userConsole" />
    </rules>
</nlog>

About

NLog extensions for displaying User Windows Identity and target wrapper for user impersonation

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:C# 100.0%