Esempio n. 1
0
        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);
        }