/// <summary>
        /// Publishes the specified exception.
        /// </summary>
        /// <param name="exception">The exception.</param>
        /// <param name="additionalParameters">The additional parameters.</param>
        public void Publish(Exception exception, NameValueCollection additionalParameters)
        {
            if (additionalParameters != null)
            {
                foreach (var key in additionalParameters.AllKeys)
                {
                    RIExtendedMessageProperty.AttachToSingleMessage("Additional Info", key, additionalParameters[key]);
                }
            }

            var details = ExceptionFormatter.ConstructIndentedMessage(exception, additionalParameters /*, _exceptionExtender.Extender*/);

            RILogManager.Get(_category).Send(MessageType.SendException, exception.Message, details);
        }
        /// <summary>
        /// Aggregates most logging patterns to a single method.
        /// </summary>
        /// <typeparam name="TState">The type of the state.</typeparam>
        /// <param name="logLevel">The log level.</param>
        /// <param name="eventId">The event identifier.</param>
        /// <param name="state">The state.</param>
        /// <param name="exception">The exception.</param>
        /// <param name="formatter">The formatter.</param>
        /// <exception cref="System.ArgumentNullException"></exception>
        public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter)
        {
            if (!IsEnabled(logLevel) || logLevel == LogLevel.None)
            {
                return;
            }

            if (formatter == null)
            {
                throw new ArgumentNullException(nameof(formatter));
            }

            var message = formatter(state, null);

            if (string.IsNullOrEmpty(message))
            {
                return;
            }

            if ((eventId.Name ?? string.Empty).Contains("Microsoft.EntityFrameworkCore"))
            {
                LogSqlCommand(eventId, message);
                return;
            }

            var messageType = MessageType.Clear;

            switch (logLevel)
            {
            case LogLevel.Debug:
                messageType = MessageType.SendDebug;
                break;

            case LogLevel.Trace:
                messageType = MessageType.SendTrace;
                break;

            case LogLevel.Information:
                messageType = MessageType.SendInformation;
                break;

            case LogLevel.Warning:
                messageType = MessageType.SendWarning;
                break;

            case LogLevel.Error:
                messageType = MessageType.SendError;
                break;

            case LogLevel.Critical:
                messageType = MessageType.SendFatal;
                break;
            }

            var details = (string)null;

            if (exception != null)
            {
                var additional = (NameValueCollection)null;
                if (eventId.Id > 0)
                {
                    additional = new NameValueCollection
                    {
                        ["eventName"] = eventId.Name ?? messageType.ToString(),
                        ["eventId"]   = eventId.Id.ToString()
                    };
                }

                details = ExceptionFormatter.ConstructIndentedMessage(exception, additional);
            }

            GetLogger().Send(messageType, message, details);
        }
 /// <summary>
 /// Sends the message.
 /// </summary>
 /// <param name="msg">The MSG.</param>
 /// <param name="ex">The ex.</param>
 /// <param name="args">The arguments.</param>
 public void SendMessage(string msg, Exception ex, params object[] args)
 {
     RILogManager.Get(WorkManagerConfig.ApplicationName).Send(MessageType.SendMessage, msg, ExceptionFormatter.ConstructIndentedMessage(ex), args);
 }
 /// <summary>
 /// Sends the fatal.
 /// </summary>
 /// <param name="msg">The MSG.</param>
 /// <param name="ex">The ex.</param>
 /// <param name="args">The arguments.</param>
 public override void SendFatal(string msg, Exception ex, params object[] args)
 {
     RILogManager.Get(WorkManagerConfig.ApplicationName).Send(MessageType.SendFatal, msg, ExceptionFormatter.ConstructIndentedMessage(ex), args);
     MiscHelper.WriteToEventLog(WorkManagerConfig.ApplicationName, ConstructExceptionMessage(msg, ex, args), EventLogEntryType.Error);
 }