Click or drag to resize

Logging & Tracing

With the release of V5.0 SphinxConnector.NET has replaced the Common.Logging library with its own logging abstraction. NuGet packages for following logging frameworks are available:

Setting up Logging

This section is intended to be a quick introduction on how to setup logging in your application. In this example we'll use NLog. To have SphinxConnector.NET use NLog we'll first install the SphinxConnector.Logging.NLog nuget package and add the following line to our application startup class:

SphinxConnectorLoggerFactory.SetLoggerProvider(new NLogLoggerPovider());

NLog can be configured either in an app or web.config file or programmatically. In this example we'll use the app.config file. First we need to add the config section for NLog to the config file:

Config sections
  <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>

Next we add the NLog configuration:

NLog config
<nlog xmlns="" xmlns:xsi="" autoReload="true" throwExceptions="false">
      <target name="console" xsi:type="Console" layout="${longdate} ${level:uppercase=true} ${callsite} ${message} ${exception:format=tostring}"/>
      <logger name="*" minlevel="Trace" writeTo="console"> </logger>

The NLog configuration is straightforward: We setup a console target and a catch-all logger with a mininum log level of Trace.

Note Note

In a production environment the log level generally should not be set lower than Info except for debugging puposes, because Trace is very verbose and may slow down your application.