/// <summary> /// Writes a debug message to the configured log4net buffer without setting a thread context variable. /// Useful for initialization code or any code which executes prior to a session being created. /// </summary> /// <param name="source"> An ILoggingSource implementation. </param> /// <param name="message"> The message to be written to the log. </param> /// <param name="formatParameters"> String formatting parameters used to render the message. </param> public static void LogDebugWithoutContext(this ILoggingSource source, string message, params object[] formatParameters) { var logger = LogManager.GetLogger(source.GetType()); if (logger.IsDebugEnabled) { logger.Debug(string.Format(message, formatParameters)); } }
/// <summary> /// Writes a debug message to the configured log4net buffer. /// </summary> /// <param name="source"> An ILoggingSource implementation. </param> /// <param name="message"> The message to be written to the log. </param> /// <param name="formatParameters"> String formatting parameters used to render the message. </param> public static void LogError(this ILoggingSource source, string message, params object[] formatParameters) { setSessionLogContext(); var logger = LogManager.GetLogger(source.GetType()); if (logger.IsErrorEnabled) { logger.Error(string.Format(message, formatParameters)); } }
/// <summary> /// Writes a debug message to the configured log4net buffer. /// </summary> /// <param name="source"> An ILoggingSource implementation. </param> /// <param name="message"> The message to be written to the log. </param> /// <param name="exception"> The exception associated with the log message. </param> /// <param name="formatParameters">String formatting parameters used to render the message.</param> public static void LogFatal(this ILoggingSource source, string message, Exception exception, params object[] formatParameters) { setSessionLogContext(); var logger = LogManager.GetLogger(source.GetType()); if (logger.IsFatalEnabled) { logger.Fatal(string.Format(message, formatParameters), exception); } }
/// <summary> /// Writes a debug message to the configured log4net buffer. /// </summary> /// <param name="source"> An ILoggingSource implementation. </param> /// <param name="message"> The message to be written to the log. </param> /// <param name="formatParameters"> String formatting parameters used to render the message. </param> public static void LogInfo(this ILoggingSource source, string message, params object[] formatParameters) { setSessionLogContext(); var logger = LogManager.GetLogger(source.GetType()); if (logger.IsInfoEnabled) { if (formatParameters != null && formatParameters.Length > 0) { logger.Info(string.Format(message, formatParameters)); } else { logger.Info(message); } } }
/// <summary> /// Logs the specified message. /// </summary> /// <param name="sender">The logging source.</param> /// <param name="aspectName">The aspect of the code where the message is coming from.</param> /// <param name="message">The message text.</param> /// <param name="ex">The exception to log.</param> public static void LogError(this ILoggingSource sender, string aspectName, string message, Exception ex) => Log(sender.LoggingHandler, MediaLogMessageType.Error, aspectName, $"{message}\r\n" + $"{ex?.GetType().Name}: {ex?.Message}\r\nStack Trace:\r\n{ex?.StackTrace}");
/// <summary> /// Logs the specified message. /// </summary> /// <param name="sender">The logging source.</param> /// <param name="aspectName">The aspect of the code where the message is coming from.</param> /// <param name="message">The message text.</param> public static void LogError(this ILoggingSource sender, string aspectName, string message) => Log(sender.LoggingHandler, MediaLogMessageType.Error, aspectName, message);
private static void setAzureCredentials(IWindsorContainer container, ILoggingSource log) { CloudStorageAccount.SetConfigurationSettingPublisher( (configurationKey, publishConfigurationValue) => { var connectionString = RoleEnvironment.IsAvailable ? RoleEnvironment.GetConfigurationSettingValue(configurationKey) : ConfigurationManager.AppSettings[configurationKey]; publishConfigurationValue(connectionString); }); var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString"); log.WriteInfoMessage("Using Azure queue endpoint {0}", storageAccount.QueueEndpoint.AbsoluteUri); container.Register(Component.For<CloudStorageAccount>().Instance(storageAccount)); }
/// <summary> /// Used by applications which need to set their session log ids directly, rather than via claims. /// </summary> /// <returns></returns> public static void LogClearSessionId(this ILoggingSource source) { LogIdOverride = new Guid?(); }
/// <summary> /// Returns the current session id, if one has been set. /// </summary> /// <returns></returns> public static Guid?LogGetSessionId(this ILoggingSource source) { return(LogIdOverride); }
/// <summary> /// Used by applications which need to set their session log ids directly, rather than via claims. /// </summary> /// <returns></returns> public static Guid LogSetSessionId(this ILoggingSource source, Guid sessionId) { LogIdOverride = sessionId; return(LogIdOverride.Value); }
/// <summary> /// Used by applications which need to set their session log ids directly, rather than via claims. /// </summary> /// <returns></returns> public static Guid LogSetSessionId(this ILoggingSource source) { LogIdOverride = Guid.NewGuid(); return(LogIdOverride.Value); }