protected virtual void LogUnauthorized(HttpActionContext actionContext, HmacResult result, Customer customer) { try { var logger = EngineContext.Current.Resolve <ILogger>(); var localization = EngineContext.Current.Resolve <ILocalizationService>(); string strResult = result.ToString(); string description = localization.GetResource("Admin.WebApi.AuthResult." + strResult, 0, false, strResult); var logContext = new LogContext { ShortMessage = localization.GetResource("Admin.WebApi.UnauthorizedRequest").FormatWith(strResult), FullMessage = "{0}\r\n{1}".FormatWith(description, actionContext.Request.Headers.ToString()), LogLevel = LogLevel.Warning, Customer = customer, HashNotFullMessage = true, HashIpAddress = true }; logger.InsertLog(logContext); } catch (Exception exc) { exc.Dump(); } }
protected virtual void LogUnauthorized(HttpActionContext actionContext, HmacResult result, Customer customer) { try { var logger = EngineContext.Current.Resolve<ILogger>(); var localization = EngineContext.Current.Resolve<ILocalizationService>(); string strResult = result.ToString(); string description = localization.GetResource("Admin.WebApi.AuthResult." + strResult, 0, false, strResult); var logContext = new LogContext() { ShortMessage = localization.GetResource("Admin.WebApi.UnauthorizedRequest").FormatWith(strResult), FullMessage = "{0}\r\n{1}".FormatWith(description, actionContext.Request.Headers.ToString()), LogLevel = LogLevel.Warning, Customer = customer, HashNotFullMessage = true, HashIpAddress = true }; logger.InsertLog(logContext); } catch (Exception exc) { exc.Dump(); } }
protected virtual void LogUnauthorized(HttpActionContext actionContext, IDependencyScope dependencyScope, HmacResult result, Customer customer) { try { var localization = dependencyScope.GetService <ILocalizationService>(); var loggerFactory = dependencyScope.GetService <ILoggerFactory>(); var logger = loggerFactory.GetLogger(this.GetType()); var strResult = result.ToString(); var description = localization.GetResource("Admin.WebApi.AuthResult." + strResult, 0, false, strResult); logger.Warn( new SecurityException("{0}\r\n{1}".FormatInvariant(description, actionContext.Request.Headers.ToString())), localization.GetResource("Admin.WebApi.UnauthorizedRequest").FormatInvariant(strResult) ); } catch (Exception exception) { exception.Dump(); } }