Logging - XSockets/XSockets.NET-4.0 GitHub Wiki
##Logging
As of 4.0 XSockets will use http://serilog.net as the default logger. Since it is a plugin you can of course replace SeriLog with something else if you want to.
By default the logger will log everything in Information
.
###Customize Serilog
It is very easy to set your custom SeriLogger/Configuration/Sink. Just inherit the XLogger
class from assembly XSockets.Logger.dll
and set the configuraiton of choice. For more information about SerilLog see http://serilog.net
All methods on XLogger is virtual so that you can override them, but if you want to redo the whole thing or even replace Serilog with another logger see the next section
//using Serilog;
//using XSockets.Logger;
//
// Sample below will write to console with level Verbose
//
public class MyLogger : XLogger
{
public MyLogger()
{
Log.Logger = new LoggerConfiguration().MinimumLevel.Verbose()
.WriteTo.ColoredConsole()
.CreateLogger();
}
}
###Custom Logger (replacing Serilog)
If you do not want Serilog or you just dont want to use the Xlogger
you can implement your own since the default XLogger is an overridable module.
Just implement the IXlogger
interface and implement all methods and your new logger is good to go.
//using System;
//using XSockets.Core.Common.Utility.Logging;
public class MyXLogger : IXLogger
{
public void SetEventLevel(LogEventLevel level)
{
throw new NotImplementedException();
}
public void Verbose(string template, params object[] parmeters)
{
throw new NotImplementedException();
}
public void Verbose(Exception ex, string template, params object[] parmeters)
{
throw new NotImplementedException();
}
public void Debug(string template, params object[] parmeters)
{
throw new NotImplementedException();
}
public void Debug(Exception ex, string template, params object[] parmeters)
{
throw new NotImplementedException();
}
public void Information(string template, params object[] parmeters)
{
throw new NotImplementedException();
}
public void Information(Exception ex, string template, params object[] parmeters)
{
throw new NotImplementedException();
}
public void Warning(string template, params object[] parmeters)
{
throw new NotImplementedException();
}
public void Warning(Exception ex, string template, params object[] parmeters)
{
throw new NotImplementedException();
}
public void Error(string template, params object[] parmeters)
{
throw new NotImplementedException();
}
public void Error(Exception ex, string template, params object[] parmeters)
{
throw new NotImplementedException();
}
public void Fatal(string template, params object[] parmeters)
{
throw new NotImplementedException();
}
public void Fatal(Exception ex, string template, params object[] parmeters)
{
throw new NotImplementedException();
}
public bool LevelEnabled(LogEventLevel level)
{
throw new NotImplementedException();
}
}