Exemple #1
0
        /// <summary>
        /// Executes a logging.
        /// </summary>
        /// <param name="level">The <see cref="Level"/> of the logging.</param>
        /// <param name="exception">Optionally an <see cref="Exception"/> object to accompany the logging.</param>
        /// <param name="message">The log message.</param>
        /// <param name="args">Any formatting arguments for the log message.</param>
        public void Log(Level level, Exception exception, string message, params object[] args)
        {
            var nlogLevel = NLogLoggerFactory.ToNLogLevel(level);

            if (_logger.IsEnabled(nlogLevel))
            {
                _logger.Log(nlogLevel, exception, message, args);
            }
        }
Exemple #2
0
 /// <summary>
 /// Called when a logging was directed to this target.
 /// </summary>
 /// <param name="logEvent">The <see cref="LogEventInfo"/> describing the logging.</param>
 protected override void Write(LogEventInfo logEvent)
 {
     NLogLoggerFactory.Factory.RaiseEvent(new LogEvent
     {
         Exception       = logEvent.Exception,
         LogLevel        = NLogLoggerFactory.ToLevel(logEvent.Level),
         RenderedMessage = Layout.Render(logEvent),
         Stamp           = logEvent.TimeStamp
     });
 }