jhipster-dotnetcore
jhipster-dotnetcore copied to clipboard
LoggerNameEnricher with generics
Overview of the feature request
When the LoggerNameEnricher gets a generic type as context, it produces some pretty unreadable text - something like A.B.C.D.E.F.0.0.0, Culture=neutral, PublicKeyToken=null]]
I'd like to have something better readable
Motivation for or Use Case
I use generic classes that produce logs
Possible improvement
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
if (!logEvent.Properties.TryGetValue("SourceContext", out var context))
{
return;
}
string fullQualifiedClassName = context.ToString().Trim('"');
string fullQualifiedClassNameWithoutGenerics = Regex.Replace(fullQualifiedClassName,"`1\\[\\[.*\\]\\]","<?>");
logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("LoggerName", GetAbbreviatedClassName(fullQualifiedClassNameWithoutGenerics, 39)));
}
Related issues or PR
- [ x ] Checking this box is mandatory (this is just to show you read everything)
i understand if your solution is better you can create a PR here => https://github.com/jhipster/jhipster-net/blob/930dfba8ed354bbd514c601b12642620a119ae22/src/JHipsterNet.Web/Logging/LoggerNameEnricher.cs