Skip to main content
To build your own logger:
  1. Create a DLL containing a class that implements SuperOffice.Diagnostics.Logging.ILoggerProviderPlugin (found in SOCORE.DLL).
  2. Add the SuperOffice.Diagnostics.Logging.ILoggerProviderPluginAttribute to the class to mark it as a plugin.
  3. Add a reference to the Microsoft.Extensions.Logging.Abstractions package.
  4. Return something that implements an ILogger.
  5. Drop the DLL and its dependencies into the bin folder.
  6. Add binding redirects as needed if your dependencies and NetServers dependencies disagree.

ILogger and plugins

NetServer uses the standard ILogger providers via a plug-in system. To use your own logger system, you need to make your own assembly (DLL) containing a plug-in class that implements the ILoggerProviderPlugin interface. NetServer’s class factory will load your plug-in, discover the ILoggerProviderPlugin implementation by finding the \[ILoggerProviderPluginAttribute\] on the class.
NetServer’s logger will call the plug-in’s CreateLoggerProvider function to get an ILoggerProvider. This is a Microsoft-defined interface for getting ILogger instances. This definition lives in the Microsoft.Extensions.Logging.Abstractions NuGet package. The ILoggerProvider that is returned is added to the log provider collection that NetServer uses to log. All the log providers are used whenever logging happens. Each log provider may be configured differently. When NetServer wants to log something, it calls each ILogger provider with the same log message, and each provider then does whatever it wants. The ILogProvider’s CreateLogger() is called with a category name (usually a class full name): ILogger CreateLogger(string categoryName) The ILogger’s Log methods are called: Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter) The exception may be set or may be null. The formatter is a function that turns the log message into a string.