Hello again,
I'm trying to log an http header that hold's the username (this information is just passed at every call on ServiceStack's headers)
I'm trying to put the logging login on a single point that's servicestack servicerunngers as
<pre>
public override object Execute(IRequest request, object instance, TRequest requestDto)
{
var username = request.Headers.Get(HeaderHelper.UserName);
if (!string.IsNullOrEmpty(username))
{
Serilog.Log.Logger.ForContext(HeaderHelper.UserName, username);
}
Serilog.Log.ForContext(instance.GetType()).Debug("[Request] Logging request {@Request}", requestDto, username);
return base.Execute(request, instance, requestDto);
}
</pre>
using this approach won't log the username field in my template (consider this for now as template
<add key="serilog:write-to:RollingFile.outputTemplate" value="{Username} - {Timestamp:HH:mm:ss} [{Level}] [{SourceContext}] {Message}{NewLine}{Exception}" />)
I've tried to create as well an enricher but I can't find the Username field inside the enricher
public class UsernameEnricher: ILogEventEnricher
{
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
//where should I look here ?
}
}
Thanks