Skip to content

Logging

pleykov edited this page Apr 28, 2017 · 5 revisions

The Kount RIS .NET SDK includes a basic logging framework abstraction. This allows your logging framework to be integrated with the SDK. By default the SDK provides two basic loggers: NOP and SIMPLE.

  • NOP is a logger that silently discards all logging. This is the default logger the SDK uses. SIMPLE is a logger that logs messages to a file that you specify on the machine the SDK is hosted on.
  • SIMPLE logger can be configured in your App.config. The following logging levels are available in order of decreasing severity: FATAL, ERROR, WARN, INFO, and DEBUG.

Custom logger integration

This is the recommended way to integrate a custom logger with the SDK. For the purpose of clarity suppose your logger is called "loggerX":

  1. Create the class Kount.Log.Factory.LoggerXFactory that implements Kount.Log.Factory.LoggerFactory.
  2. Create Kount.Log.Binding.LoggerX class that implements Kount.Log.Binding.Logger. This class will be the facade to your custom loggerX.
  3. Set your logger factory using the method Kount.Log.Factory.LogFactory.SetLoggerFactory().

A code sample below:

/// <summary>
/// A class demonstrating how to use logging
/// </summary>
public class ExampleClient
{
    /// <summary>
    /// The main entry point for the application.<br/>
    /// <b>Author:</b> Kount <a>[email protected]</a>;<br/>
    /// <b>Version:</b> 6.5.0. <br/>
    /// <b>Copyright:</b> 2010 Keynetics Inc <br/>
    /// </summary>
    [STAThread]
    public static void Main()
    {
        ILoggerFactory factory = LogFactory.GetLoggerFactory();
        ILogger logger = factory.GetLogger("Example Client");
        logger.Debug("Hello World");
        logger.Info("Hello World");
        logger.Warn("Hello World");
        logger.Error("Hello World");
        logger.Fatal("Hello World");

        // How to log messages and exceptions.
        try
        {
            Exception e = new Exception("Logging an exception");
            throw e;
        }
        catch (Exception e)
        {
            logger.Debug("Hello World", e);
            logger.Info("Hello World", e);
            logger.Warn("Hello World", e);
            logger.Error("Hello World", e);
            logger.Fatal("Hello World", e);
        }
    }
}

Next step