Exemplo n.º 1
0
        /// <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));
            }
        }
Exemplo n.º 2
0
        /// <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));
            }
        }
Exemplo n.º 3
0
        /// <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);
            }
        }
Exemplo n.º 4
0
        /// <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);
                }
            }
        }