protected override void BeforeInvoke(InvocationContext invocationContext) { _logger = _loggerFactory.CreateLogger(invocationContext.GetOwningType()); _logAttribute = invocationContext.GetOwningAttribute() as LogAttribute; var level = _logAttribute.LogLevel; _logger.Log(level, "{owningType}: Method executing: {methodName}", invocationContext.GetOwningType(), invocationContext.GetExecutingMethodName()); }
/// <inheritdoc /> public void BeforeInvoke(InvocationContext invocationContext) { // Create a logger based on the class type that owns the executing method this.logger = this.loggerFactory.CreateLogger(invocationContext.GetOwningType()); // Get the Logging Attribute this.loggingAttribute = invocationContext.GetAttributeFromMethod <LogAttribute>(); // Get the Logging Level var loggingLevel = this.loggingAttribute.LoggingLevel; // Log the method being executed this.logger.Log(loggingLevel, $"{invocationContext.GetOwningType()}: Method executing: {invocationContext.GetExecutingMethodName()}"); }
protected override void AfterInvoke(InvocationContext invocationContext, object methodResult) { _logger.Log(_logAttribute.LogLevel, "{owningType}: Method executed: {methodName}", invocationContext.GetOwningType(), invocationContext.GetExecutingMethodName()); }
/// <inheritdoc /> public void AfterInvoke(InvocationContext invocationContext, object methodResult) { this.logger.Log(this.loggingAttribute.LoggingLevel, $"{invocationContext.GetOwningType()}: Method executed: {invocationContext.GetExecutingMethodName()}"); }