Create() public static méthode

Creates the log event.
public static Create ( NLog.LogLevel logLevel, string loggerName, IFormatProvider formatProvider, [ message, object parameters ) : LogEventInfo
logLevel NLog.LogLevel The log level.
loggerName string Name of the logger.
formatProvider IFormatProvider The format provider.
message [ The message.
parameters object The parameters.
Résultat LogEventInfo
Exemple #1
0
        private void WriteToTargets(LogLevel level, IFormatProvider formatProvider, [Localizable(false)] string message)
        {
            // please note that this overload calls the overload of LogEventInfo.Create with object[] parameter on purpose -
            // to avoid unnecessary string.Format (in case of calling Create(LogLevel, string, IFormatProvider, object))
            var logEvent = LogEventInfo.Create(level, Name, formatProvider, message, (object[])null);

            LoggerImpl.Write(_loggerType, GetTargetsForLevel(level), PrepareLogEventInfo(logEvent), Factory);
        }
Exemple #2
0
        private void WriteToTargets(LogLevel level, Exception ex, IFormatProvider formatProvider, [Localizable(false)] string message, object[] args)
        {
            var targetsForLevel = GetTargetsForLevel(level);

            if (targetsForLevel != null)
            {
                var logEvent = LogEventInfo.Create(level, Name, ex, formatProvider, message, args);
                WriteToTargets(logEvent, targetsForLevel);
            }
        }
Exemple #3
0
        private void WriteToTargets(LogLevel level, Exception ex, [Localizable(false)] string message, object[] args)
        {
            var targetsForLevel = GetTargetsForLevel(level);

            if (targetsForLevel != null)
            {
                var logEvent = LogEventInfo.Create(level, Name, ex, Factory.DefaultCultureInfo, message, args);
                WriteToTargets(logEvent, targetsForLevel);
            }
        }
Exemple #4
0
        private void WriteToTargets <T>(LogLevel level, IFormatProvider formatProvider, T value)
        {
            var targetsForLevel = GetTargetsForLevel(level);

            if (targetsForLevel != null)
            {
                var logEvent = LogEventInfo.Create(level, Name, formatProvider, value);
                WriteToTargets(logEvent, targetsForLevel);
            }
        }
Exemple #5
0
        private void WriteToTargets <T>(LogLevel level, IFormatProvider formatProvider, T value)
        {
            var logEvent = PrepareLogEventInfo(LogEventInfo.Create(level, Name, formatProvider, value));
            var ex       = value as Exception;

            if (ex != null)
            {
                //also record exception
                logEvent.Exception = ex;
            }
            LoggerImpl.Write(_loggerType, GetTargetsForLevel(level), logEvent, Factory.ThrowExceptions);
        }
Exemple #6
0
        private void WriteToTargets(LogLevel level, IFormatProvider formatProvider, [Localizable(false)] string message)
        {
            var targetsForLevel = GetTargetsForLevel(level);

            if (targetsForLevel != null)
            {
                // please note that this overload calls the overload of LogEventInfo.Create with object[] parameter on purpose -
                // to avoid unnecessary string.Format (in case of calling Create(LogLevel, string, IFormatProvider, object))
                var logEvent = LogEventInfo.Create(level, Name, formatProvider, message, (object[])null);
                WriteToTargets(logEvent, targetsForLevel);
            }
        }
Exemple #7
0
        internal void WriteToTargets <T>(LogLevel level, IFormatProvider formatProvider, T value)
        {
            var logEvent = PrepareLogEventInfo(LogEventInfo.Create(level, this.Name, formatProvider, value));
            var ex       = value as Exception;

            if (ex != null)
            {
                //also record exception
                logEvent.Exception = ex;
            }
            LoggerImpl.Write(this.loggerType, this.GetTargetsForLevel(level), logEvent, this.Factory);
        }
Exemple #8
0
        internal void WriteToTargets(LogLevel level, [Localizable(false)] string message, Exception ex)
        {
            LogEventInfo logEventInfo;

            if (this.loggingConfiguration.PoolingEnabled())
            {
                logEventInfo = this.loggingConfiguration.PoolFactory.Get <LogEventInfoPool, LogEventInfo>().Get(level, this.Name, this.Factory.DefaultCultureInfo, message, null, ex);
            }
            else
            {
                logEventInfo = LogEventInfo.Create(level, this.Name, message, ex);
            }

            this.WriteToTargets(logEventInfo);
        }
Exemple #9
0
        internal void WriteToTargets(LogLevel level, IFormatProvider formatProvider, [Localizable(false)] string message, object[] args)
        {
            LogEventInfo info;

            if (this.loggingConfiguration.PoolingEnabled())
            {
                info = this.loggingConfiguration.PoolFactory.Get <LogEventInfoPool, LogEventInfo>().Get(level, this.Name, formatProvider, message, args, null);
            }
            else
            {
                info = LogEventInfo.Create(level, this.Name, formatProvider, message, args);
            }

            LoggerImpl.Write(this.loggerType, this.GetTargetsForLevel(level), PrepareLogEventInfo(info), this.Factory);
        }
Exemple #10
0
        internal void WriteToTargets(LogLevel level, IFormatProvider formatProvider, [Localizable(false)] string message)
        {
            // please note that this overload calls the overload of LogEventInfo.Create with object[] parameter on purpose -
            // to avoid unnecessary string.Format (in case of calling Create(LogLevel, string, IFormatProvider, object))

            LogEventInfo info;

            if (this.loggingConfiguration.PoolingEnabled())
            {
                info = this.loggingConfiguration.PoolFactory.Get <LogEventInfoPool, LogEventInfo>().Get(level, this.Name, formatProvider, message, (object[])null, null);
            }
            else
            {
                info = LogEventInfo.Create(level, this.Name, formatProvider, message, (object[])null);
            }

            LoggerImpl.Write(this.loggerType, this.GetTargetsForLevel(level), PrepareLogEventInfo(info), this.Factory);
        }
Exemple #11
0
        internal void WriteToTargets <T>(LogLevel level, IFormatProvider formatProvider, T value)
        {
            LogEventInfo logEventInfo;

            if (this.loggingConfiguration.PoolingEnabled())
            {
                logEventInfo = this.loggingConfiguration.PoolFactory.Get <LogEventInfoPool, LogEventInfo>().Get(level, this.Name, this.Factory.DefaultCultureInfo, "{0}", new object[] { value }, null);
            }
            else
            {
                logEventInfo = LogEventInfo.Create(level, this.Name, formatProvider, value);
            }

            var logEvent = PrepareLogEventInfo(logEventInfo);
            var ex       = value as Exception;

            if (ex != null)
            {
                //also record exception
                logEvent.Exception = ex;
            }
            LoggerImpl.Write(this.loggerType, this.GetTargetsForLevel(level), logEvent, this.Factory);
        }
Exemple #12
0
 internal void WriteToTargets(LogLevel level, IFormatProvider formatProvider, [Localizable(false)] string message, object[] args)
 {
     LoggerImpl.Write(this.loggerType, this.GetTargetsForLevel(level), PrepareLogEventInfo(LogEventInfo.Create(level, this.Name, formatProvider, message, args)), this.Factory);
 }
Exemple #13
0
 internal void WriteToTargets(LogLevel level, Exception ex, [Localizable(false)] string message, object[] args)
 {
     LoggerImpl.Write(this.loggerType, this.GetTargetsForLevel(level), PrepareLogEventInfo(LogEventInfo.Create(level, this.Name, ex, this.Factory.DefaultCultureInfo, message, args)), this.Factory);
 }
Exemple #14
0
 internal void WriteToTargets <T>(LogLevel level, IFormatProvider formatProvider, T value)
 {
     LoggerImpl.Write(this.loggerType, this.GetTargetsForLevel(level), PrepareLogEventInfo(LogEventInfo.Create(level, this.Name, formatProvider, value)), this.Factory);
 }
Exemple #15
0
        private void WriteToTargets <T>(LogLevel level, IFormatProvider formatProvider, T value)
        {
            var logEvent = PrepareLogEventInfo(LogEventInfo.Create(level, Name, formatProvider, value));

            LoggerImpl.Write(_loggerType, GetTargetsForLevel(level), logEvent, Factory);
        }
Exemple #16
0
 private void WriteToTargets(LogLevel level, Exception ex, IFormatProvider formatProvider, [Localizable(false)] string message, object[] args)
 {
     LoggerImpl.Write(_loggerType, GetTargetsForLevel(level), PrepareLogEventInfo(LogEventInfo.Create(level, Name, ex, formatProvider, message, args)), Factory);
 }
Exemple #17
0
 internal void WriteToTargets(LogLevel level, [Localizable(false)] string message, Exception ex)
 {
     LoggerImpl.Write(this.loggerType, this.GetTargetsForLevel(level), PrepareLogEventInfo(LogEventInfo.Create(level, this.Name, message, ex)), this.Factory);
 }
Exemple #18
0
 private void WriteToTargets(LogLevel level, Exception ex, [Localizable(false)] string message, object[] args)
 {
     LoggerImpl.Write(_loggerType, GetTargetsForLevel(level), PrepareLogEventInfo(LogEventInfo.Create(level, Name, ex, Factory.DefaultCultureInfo, message, args)), Factory.ThrowExceptions);
 }