Example #1
0
        protected override void Write(LogEventInfo logEvent)
        {
            var log = Component.Log.GetTaggedCopy(logEvent.LoggerName);

            string message;

            if (logEvent.Exception != null && logEvent.Message == "{0}")
            {
                message = logEvent.Exception.Message;
            }
            else
            {
                message = logEvent.FormattedMessage;
            }

            Dictionary <string, object> properties = null;

            if (logEvent.HasProperties)
            {
                properties = logEvent.Properties.ToDictionary(a => a.Key.ToString(), b => b.Value);
            }

            var level = LogLevelHelper.GetLogLevel(logEvent.Level);

            log.Write(level, message, logEvent.Exception, properties);
        }
        protected override void Append(LoggingEvent loggingEvent)
        {
            var level   = LogLevelHelper.GetLogLevel(loggingEvent.Level);
            var log     = Component.Log.GetTaggedCopy(loggingEvent.LoggerName);
            var message = loggingEvent.RenderedMessage;

            log.Write(level, message, loggingEvent.ExceptionObject);
        }
        protected override void Append(LoggingEvent loggingEvent)
        {
            var level = LogLevelHelper.GetLogLevel(loggingEvent.Level);

            if (level <= LogLevel.Info)
            {
                return;
            }

            var message = loggingEvent.RenderedMessage;

            var errorData = Component.Client.ExceptionRender.CreateEventFromLog(Component, level, loggingEvent.ExceptionObject, message, new Dictionary <string, object>());

            errorData.Add();
        }
        public void Log <TState>(Microsoft.Extensions.Logging.LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter)
        {
            if (!_isEnabled)
            {
                return;
            }

            var level   = LogLevelHelper.GetLogLevel(logLevel);
            var message = formatter(state, exception);

            Dictionary <string, object> properties = null;

            if (eventId.Id != 0 || !string.IsNullOrEmpty(eventId.Name))
            {
                properties = new Dictionary <string, object>
                {
                    { "EventId", eventId.ToString() }
                };
            }

            var log = Component.Log.GetTaggedCopy(_categoryName);

            log.Write(level, message, exception, properties);
        }