CaptiveAire/Common.Logging.Serilog — pull request #2 by mperdeck (2014-06-28 13:32:51+00:00)
Title: Allow objects to be logged without destroying their structure

This pull request is related to logging an Object, rather than a string. For example:
log.Info(myobject);

I found that this logged just the name of the type, instead of the properties and their values. In other words, the structure of the object was being destroyed, which IMHO is counter to the intention of Serilog.

I traced the problem to method WriteInternal in SerilogCommonLogger.cs, line:
this._logger.Write(logLevel, exception, "{message:l}", message.ToString());

Removing the ToString solves the problem. In my pull request, I added a try-catch so if the logger somehow can't deal with the object and throws an exception, it tries to log the message again, but with ToString applied.

Thanks for creating this project! I'm looking forward to seeing a new version with this fix appear on NuGet, so I can use this package in my current project.

Thanks,

Matt