// Private Members
        private void LogEntry(ILoggingService logger, ActionExecutingContext actionContext)
        {
            try
            {
                var message = new LogMessage()
                              .Append($"Executing action {actionContext.ActionDescriptor.DisplayName} with arguments ");

                var args = "null";

                if (actionContext.ActionArguments.Count > 0)
                {
                    args = string.Join(", ", actionContext.ActionArguments.Select(x => $"{x.Key}:{x.Value}"));
                }

                message.Append("({Arguments})", args);

                message.Append(" - ModelState is {ValidationState}", actionContext.ModelState.ValidationState);

                logger.Information(message.MessageTemplate, parameters: message.MessageTemplateArgs);
            }
            catch (Exception ex)
            {
                logger.Warning(ex, "Failed to log entry");
            }
        }
Esempio n. 2
0
 /// <inheritdoc />
 public virtual ILog <TCategoryName> Message(string message, params object[] args)
 {
     LogMessage.Append(message);
     LogMessageArgs.AddRange(args);
     return(this);
 }