// Normal
_logger.Information("Added entity {EntityName} with name {TypeName}", entityState.name, type.Name);
// Extension
_logger.LogInformation("Added entity {EntityName} with name {TypeName}", entityState.name, type.Name);
That passes some context information using reflection (caller file, method
public static class LoggerExtensions
{
public static void LogInformation(this ILogger logger, string messageTemplate, params object[] propertyValues)
{
var callerInfo = GetCallerInfo();
using (LogContext.PushProperty("Method", callerInfo.MethodName))
using (LogContext.PushProperty("FilePath", callerInfo.FileName))
using (LogContext.PushProperty("LineNumber", callerInfo.LineNumber))
{
logger.Information(messageTemplate, propertyValues);
}
}
// ...
}
Is it possible to have the analysis provided by this plugin for custom logging methods?
I have an extension method :
That passes some context information using reflection (caller file, method
Is it possible to have the analysis provided by this plugin for custom logging methods?