Table of Contents

Creating a global and local logger

You can turn on globall logging to analyze operations performed by the InetLab.SMPP library.

LogManager.SetLoggerFactory(new ConsoleLogFactory(LogLevel.Debug));

It creates the global (available to other instances) logger and specifies logging mode at the Debug level. After that operation, all logging records associated with logging level Debug and less, will be echoed into the console.

Logging depth is defined by the following LogLevel values (by decreasing of outputted information amount):

  • LogLevel.All
  • LogLevel.Verbose
  • LogLevel.Debug
  • LogLevel.Info
  • LogLevel.Warning
  • LogLevel.Error
  • LogLevel.Fatal
  • LogLevel.Off

You can get a logger instance from any method and output your own records into it as well:

ILog log = LogManager.GetLogger("MyLogger");
log.Info("Connected to SMPP server");

As a result, it will output "Connected to SMPP server" into the log/console and mark it as LogLevel.Info.

To log a single instance you need to create logger and specify it as an instance parameter. For example, you can specify an individual (local) logger for SmppClient instance:

ConsoleLogger _log = new ConsoleLogger("MyClientLogger", LogLevel.Info);
SmppClient smppClient = new SmppClient();
smppClient.Logger = _log;

This makes logger _log to output data from the related instance only.

Read more about logging on "Common Tools: Built-in Logging" page.