saleem-mirza / serilog-enrichers-context

Enriches Serilog events with information from the environment variables or user provided custom property.
Apache License 2.0
5 stars 2 forks source link

WithMachineName configuration extension method conflict with Serilog.Enrichers.Environment #2

Closed Lumirris closed 7 years ago

Lumirris commented 7 years ago

The WithMachineName method in:

https://github.com/saleem-mirza/serilog-enrichers-context/blob/master/src/Serilog.Enrichers.Context/ContextLoggerConfigurationExtension.cs

has the same signature as in

https://github.com/serilog/serilog-enrichers-environment/blob/master/src/Serilog.Enrichers.Environment/EnvironmentLoggerConfigurationExtensions.cs

This seems to (only recently?) prevent you from using both packages at the same time, because there's an ambiguity build error.

saleem-mirza commented 7 years ago

@Lumirris thanks for bringing up this issue. Unfortuntely, it's not easy to modify interface at this time as both packages are being used by community in production environment. However, ugly solution is to not use both packages at same time. Both packages are providing more or less same functionality.

tcartwright commented 8 months ago

I know this issue is a bit dated, but another way around the is to just call the extension method directly, like so:

Serilog.EnvironmentLoggerConfigurationExtensions.WithMachineName(logger.Enrich);

OR

Serilog.ContextLoggerConfigurationExtension.WithMachineName(logger.Enrich);

That way you can still continue to use both libraries. Posting this for anyone else who comes across this issue.