• Version 4.1.0
Show / Hide Table of Contents

Logging

This section explains how logging services are organized in the OnixS .NET Core CME STP Handler.

NLog logging

The NLog library is used for Handler-level logging.

NLog could be configured either through a configuration file or programmatically.

Handler loggers

There are two NLog loggers used to make logging flexible.

  • OnixS.CmeStpHandler

Logger controls Handler-related tracing and debug output.

  • OnixS.CmeStpHandler.FIXML

Logger controls FIXML message processing-related tracing and debug output. FIXML messages will be added to log with the Info level.

NLog shutdown

NLog will, by default attempt to flush automatically at application shutdown. Microsoft Windows give .NET applications a limited amount of time to perform shutdown (usually 2 sec) before being terminated. If having an NLog configuration with NLog Targets that requires network-traffic (Http, Mail, TCP), then it is a really good idea to perform a manual Flush/Shutdown independent on running on Linux/Windows.

NLog.LogManager.Shutdown(); // Flush and close down internal threads and timers

.NET applications running on Mono/Linux are required to stop threads/timers before entering the application shutdown phase. Failing to do this will cause unhandled exceptions and segmentation faults, and other unpredictable behavior.

Example

For example (NLog.config):


<?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" throwConfigExceptions="true">

  <targets>
    <target name="logfile" xsi:type="File" fileName="CmeMdHandlerLog.txt" deleteOldFileOnStartup="false"
            layout="${date:universalTime=true:format=yyyyMMdd-HH\:mm\:ss.ffffff}|${level:uppercase=true}|${logger}|${message}"/>

    <target name="logconsole" xsi:type="Console" />
  </targets>

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


See Also

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