NLog

Creates and manages instances of Logger objects.

Works well with .net core. Install from nuget `NLog 4.5.11`

Configuration

Set the config file `NLog.config`

<targets>
    <target name="logfile"
        xsi:type="File" 
        archiveNumbering="Date"
        archiveEvery="Day"
        maxArchiveFiles="50"
        bufferSize="102400"
        fileName="appname.log" />
</targets>

<rules>
    <logger name="*" minlevel="Debug" writeTo="logfile" />
</rules>

Example use

var logger = NLog.LogManager.GetCurrentClassLogger();

logger.Debug("Some debug");
logger.Debug("Some other debug");

logger.Info("Some info.");

~ this will then create `appname.log` in your executing bin directory.

References

Leave a Reply