Пример #1
0
        /// <summary>
        /// Logs a message at the Warning level.
        /// </summary>
        /// <param name="message">Message to log.</param>
        public static void Warn(object message)
        {
            var logEntry = new StandardLogEntry
            {
                Level     = Level.Warn,
                Entry     = message,
                DateTime  = DateTime.Now,
                UserName  = GetCurrentUserName(),
                SessionId = GetCurrentSessionId()
            };

            LogManager.Log.Write(logEntry);
        }
Пример #2
0
        /// <summary>
        /// Logs a formatted message at the Info level.
        /// </summary>
        /// <param name="format">Formatted message to log.</param>
        /// <param name="args">Variable number of parameters to be used with the formatted string.</param>
        public static void InfoFormat(string format, params object[] args)
        {
            var logEntry = new StandardLogEntry
            {
                Level     = Level.Info,
                Format    = format,
                Arguments = args,
                DateTime  = DateTime.Now,
                UserName  = GetCurrentUserName(),
                SessionId = GetCurrentSessionId()
            };

            LogManager.Log.Write(logEntry);
        }
Пример #3
0
        /// <summary>
        /// Logs a message with exception at the Fatal level.
        /// </summary>
        /// <param name="message">Message to log.</param>
        /// <param name="exception">Exception details.</param>
        public static void Fatal(object message, Exception exception)
        {
            var logEntry = new StandardLogEntry
            {
                Level     = Level.Fatal,
                Entry     = message,
                Exception = exception,
                DateTime  = DateTime.Now,
                UserName  = GetCurrentUserName(),
                SessionId = GetCurrentSessionId()
            };

            LogManager.Log.Write(logEntry);
        }
Пример #4
0
        /// <summary>
        /// Logs a formatted message at the Debug level.
        /// </summary>
        /// <param name="format">Formatted message to log.</param>
        /// <param name="args">Variable number of parameters to be used with the formatted string.</param>
        public static void DebugFormat(string format, params object[] args)
        {
            var logEntry = new StandardLogEntry
            {
                Level     = Level.Debug,
                Entry     = string.Format(CultureInfo.InvariantCulture, format, args),
                Format    = format,
                Arguments = args,
                DateTime  = DateTime.Now,
                UserName  = GetCurrentUserName(),
                SessionId = GetCurrentSessionId()
            };

            LogManager.Log.Write(logEntry);
        }