Search code examples
c#serilog

Is there an equivalent to using Serilog.ExtensionMethods in v2.10.0?


I am tasked with updating Serilog from v2.9.0 to the latest version (v2.10.0). Part of our code uses some extension methods on LogEvent:

if (logEvent.Exception != null)
            {
                // Exception telemetry
                return logEvent.ToDefaultExceptionTelemetry(
                    formatProvider,
                    includeLogLevelAsProperty: false,
                    includeRenderedMessageAsProperty: false,
                    includeMessageTemplateAsProperty: false);
            }
            else
            {
                // default telemetry
                return logEvent.ToDefaultTraceTelemetry(
                    formatProvider,
                    includeLogLevelAsProperty: false,
                    includeRenderedMessageAsProperty: false,
                    includeMessageTemplateAsProperty: false);
            }

I have just updated the Nuget packages we have installed to their latest versions, and I am told by Visual Studio that the namespace Serilog.ExtensionMethods no longer exists.

Is there an equivalent for these in the latest Serilog version?

I have tried to Google for this namespace, and the names of the methods but not found anything relevant.

A link to an upgrade path would also be useful, if one exists.

The list of packages I have updated are as follows:

| Package                           | Old version     | New version  |
-----------------------------------------------------------------------
| Serilog                           | 2.9.0           | 2.10.0       | 
| Serilog.AspNetCore                | 2.1.1           | 3.4.0        |
| Serilog.Exceptions                | 5.4.0           | 6.0.0        |
| Serilog.Extensions.Hosting        | 2.0.0           | 3.1.0        |
| Serilog.Settings.Configuration    | 2.6.1           | 3.1.0        |
| Serilog.Sinks.ApplicationInsights | 2.6.4           | 3.1.0        |
| Serilog.Sinks.Console             | 2.1.0           | 3.1.1        |
| Serilog.Sinks.File                | 4.0.0           | 4.1.0        |

Solution

  • Missing extension methods are from Serilog.Sinks.ApplicationInsights package. In release notes they say that braking changes were made in Major v3 release #96 PR.