• Version 1.17.0
Show / Hide Table of Contents

Logging Services

Engine-level Logging

The Microsoft.Extensions.Logging is used for Engine-level logging. Therefore, one can use any .NET logging library (NLog, Serilog, etc.) that supports this API.

Using NLog


// Inside your Main method or startup code.

var settings = new EngineSettings();

settings.LoggerFactory = new LoggerFactory();
settings.LoggerFactory.AddProvider(new NLogLoggerProvider());

var fixEngine = Engine.Init(settings);

Additionally, the NLog.config file should be added to the application directory, e.g.:

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <targets>
        <target name="logfile" xsi:type="File" fileName="FixEngineLog.txt"/>
        <target name="logconsole" xsi:type="Console" />
    </targets>

    <rules>
        <logger name="*" minlevel="Warn" writeTo="logconsole" />
        <logger name="*" minlevel="Info" writeTo="logfile" />
    </rules>
</nlog>

Using Serilog


// Inside your Main method or startup code.

Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug() // Set the minimum log level
.Enrich.FromLogContext()  // Enrich the output by the log context
.WriteTo.File("FixEngineLog.txt", outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.ffff}|{Level:u3}|{SourceContext}|{Message:lj}{NewLine}{Exception}", rollingInterval: RollingInterval.Day)
.WriteTo.Console(LogEventLevel.Debug) // Write to the console
// Add other sinks as needed
.CreateLogger();

var settings = new EngineSettings();

settings.LoggerFactory = new LoggerFactory();
settings.LoggerFactory.AddProvider(new SerilogLoggerProvider());

var fixEngine = Engine.Init(settings);

See Also

  • NLog library
  • NLog Extensions Logging
  • Serilog library
  • Serilog Extensions Logging
In this article
Back to top Copyright © Onix Solutions.
Generated by DocFX