/// <summary> /// Logs information useful for recreating a trace later on from the logs. /// </summary> /// <remarks> /// We only log handles, counters, and content types. We do not log private information such as user names or user queries. /// Note that we could infer the class name and method name using reflection, however we decided against it for performance reasons. /// </remarks> /// <param name="instrumentationPoint">instrumentation point inside the method</param> /// <param name="log">log</param> /// <param name="className">name of the controller class</param> /// <param name="methodName">name of method insider controller class (should correspond to an HTTP action)</param> /// <param name="logEntry">log entry (can be null; in the case, we log app and user handles only)</param> private void LogTracingInfo(LogControllerInstrumentationPoints instrumentationPoint, ILog log, string className, string methodName, string logEntry = null) { // All entries have class and method names, the point of instrumentation, the request guid, and app and user handles, and the name of the identity provider string message = $"{className}.{methodName}: {instrumentationPoint.ToString()} "; message += $"Guid = {this.RequestGuid}, AppHandle = {this.AppHandle}, UserHandle = {this.UserHandle}, IdentityProvider = {this.UserPrincipal?.IdentityProvider}"; // If log entry is not null, append the app handle and the user handle only, otherwise append the log entry if (logEntry != null) { message += ", " + logEntry; } log.LogInformation(message); }
/// <summary> /// Logs information useful for recreating a trace later on from the logs. /// </summary> /// <remarks> /// We only log handles, counters, and content types. We do not log private information such as user names or user queries. /// Note that we could infer the class name and method name using reflection, however we decided against it for performance reasons. /// </remarks> /// <param name="instrumentationPoint">instrumentation point inside the method</param> /// <param name="log">log</param> /// <param name="className">name of the controller class</param> /// <param name="methodName">name of method insider controller class (should correspond to an HTTP action)</param> /// <param name="logEntry">log entry (can be null; in the case, we log app and user handles only)</param> private void LogTracingInfo(LogControllerInstrumentationPoints instrumentationPoint, ILog log, string className, string methodName, string logEntry = null) { // All entries have class and method names, the point of instrumentation, the request guid string message = $"{className}.{methodName}: {instrumentationPoint.ToString()} "; message += $"Guid = {this.RequestGuid}"; // append the log entry if (logEntry != null) { message += ", " + logEntry; } log.LogInformation(message); }