Provides Serilog logging adapter for ServiceStack Core.
This is a .NETStandard 1.6 version of the ServiceStack.Logging.Serilog lib. https://github.com/ServiceStack/ServiceStack/tree/master/src/ServiceStack.Logging.Serilog
LogManager.LogFactory = new SerilogFactory();Use Serilog's destructuring operator and ForContext.
public static ILog Log = LogManager.GetLogger(typeof(TestServices));
var testObj = new TestObj
{
Prop1 = "test",
Prop2 = -99,
Prop3 = null
};
Log.DebugFormat("Hi! {@testObj}", testObj);
Log.ForContext<TestObj>().DebugFormat("Hi! {@testObj}", testObj);Logging output:
15:37:06.398 | 3 | Hi! TestObj {Prop1="test", Prop2=-99, Prop3=null} (ServiceInterface.TestServices)
15:37:06.401 | 3 | Hi! TestObj {Prop1="test", Prop2=-99, Prop3=null} (ServiceInterface.TestServices+TestObj)
"{Timestamp:HH:mm:ss.fff} | {ThreadId,2} | {Message} ({SourceContext}){NewLine}{Exception}"