Closed markdehaas closed 1 year ago
Yes, removal was intentional as you can achieve the same thing by making serilog enricher. Something like:
public class ServiceNameEnricher : ILogEventEnricher
{
private readonly string _serviceName;
public ServiceNameEnricher(string serviceName)
{
_serviceName = serviceName;
}
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
if (!string.IsNullOrWhiteSpace(_serviceName))
{
logEvent.AddOrUpdateProperty(new LogEventProperty("service", new ScalarValue(_serviceName)));
}
}
}
and then use it when configuring logger like this:
public static IHostBuilder UseSerilogWithServiceName(this IHostBuilder builder)
{
return builder
.UseSerilog((context, configuration) =>
{
configuration
.ReadFrom.Configuration(context.Configuration);
var serviceName = context.Configuration["Settings:ServiceName"].ToLower();
configuration.Enrich.With(new ServiceNameEnricher(serviceName));
}
}
Thanks. Together with some PropertyTransformationMap
entries we managed to get the exact same haviour. 👍
This recent change https://github.com/serilog-contrib/Serilog.Sinks.Logz.Io/commit/384d56ded78c46f20818376011739dc7f8c3e0bb as a fix for #29 and released in version
7.1.0
made some breaking changes to theSerilog.Sinks.Logz.Io.LogzioOptions
class. Some properties just got moved to a different (nested) object, but theEnvironment
andServiceName
properties seem to have been completely removed.Was the removal of these two properties intentional? They're not explicitly mentioned in the commit, issue, or changelog. Can they be restored or do these properties need to be configured in a different way now?