/// <summary> /// Writes the LogMessageContent. /// </summary> /// <param name="logMessageContent">Content of the log message.</param> public void WriteInfo(LogMessageContent logMessageContent) { StringBuilder message = new StringBuilder(); if (string.IsNullOrWhiteSpace(logMessageContent.HostName) == false) { message.AppendFormat("[ Host:{0} ] ", logMessageContent.HostName); } if (string.IsNullOrWhiteSpace(logMessageContent.ControllerName) == false && string.IsNullOrWhiteSpace(logMessageContent.ActionName) == false) { message.AppendFormat("[ Controller:{0} , Action:{1} ] ", logMessageContent.ControllerName, logMessageContent.ActionName); } if (string.IsNullOrWhiteSpace(logMessageContent.LoggingId) == false) { message.AppendFormat("[ {0}:{1} ] ", "LoggingId", logMessageContent.LoggingId); } if (string.IsNullOrWhiteSpace(logMessageContent.ProcessElapsedMilliseconds) == false) { message.Append(logMessageContent.ProcessElapsedMilliseconds); } ExceptionlessClient.Default .CreateLog( source: logMessageContent.AbsolutePath, message: message.ToString(), level: LogLevel.Info) .AddObject(logMessageContent) .Submit(); }
/// <summary> /// Writes the log message content. /// </summary> /// <param name="messageContent">Content of the message.</param> /// <exception cref="System.NotImplementedException"></exception> public void WriteInfo(LogMessageContent messageContent) { List <string> logContent = new List <string>(); logContent.Add(Environment.NewLine); if (string.IsNullOrWhiteSpace(messageContent.LoggingId) == false) { logContent.Add("LoggingId: "); logContent.Add(messageContent.LoggingId); } if (string.IsNullOrWhiteSpace(messageContent.ControllerName) == false) { logContent.Add("Controller: "); logContent.Add(messageContent.ControllerName); } if (string.IsNullOrWhiteSpace(messageContent.ActionName) == false) { logContent.Add("Action: "); logContent.Add(messageContent.ActionName); } logContent.Add("Request: "); logContent.Add(messageContent.Request); logContent.Add("Request Content: "); logContent.Add(messageContent.RequestContent); if (string.IsNullOrWhiteSpace(messageContent.Parameters) == false) { logContent.Add("Parameters: "); logContent.Add(messageContent.Parameters); logContent.Add("-------------------------------------------------"); } if (messageContent.CustomProperties.Any()) { logContent.AddRange(messageContent.CustomProperties); logContent.Add("-------------------------------------------------"); } logContent.Add("Client IP: "); logContent.Add(string.Format("[{0}]", messageContent.ClientIp)); logContent.Add("QueryString: "); logContent.Add(messageContent.QueryString); logContent.Add("QueryStringNameValue: "); logContent.Add(messageContent.QueryStringNameValue); logContent.Add("-------------------------------------------------"); logContent.Add("Response: "); logContent.Add(messageContent.Response); logContent.Add("Response Content: "); logContent.Add(messageContent.ResponseContent); logContent.Add("================================================="); string logMessage = string.Join(Environment.NewLine, logContent.ToArray()); NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); logger.Info(logMessage); }