private ElasticLogRecord ToElasticLogRecord(ElasticRawLogRecord record) { var retVal = new ElasticLogRecord { Id = record.Id, Index = record.Index, Exception = record.Exception, Timestamp = record.Timestamp, Level = record.Level, MessageTemplate = record.MessageTemplate, Message = ConvertMessageTemplate(record.MessageTemplate, record.Properties), ArchiveRecordId = GetProperty <string>(record.Properties, nameof(ElasticLogRecord.ArchiveRecordId)), ConversationId = GetProperty <string>(record.Properties, nameof(ElasticLogRecord.ConversationId)), MainAssembly = GetProperty <string>(record.Properties, nameof(ElasticLogRecord.MainAssembly)), MachineName = GetProperty <string>(record.Properties, nameof(ElasticLogRecord.MachineName)), ProcessId = GetProperty <long>(record.Properties, nameof(ElasticLogRecord.ProcessId)), ThreadId = GetProperty <long>(record.Properties, nameof(ElasticLogRecord.ThreadId)) }; return(retVal); }
private ElasticLogRecord MapLogRecord(LogRecord logrec) { Object v; var res = new ElasticLogRecord { LoggerName = logrec.LoggerName, LogLevel = Enum.GetName(typeof(LogRecord.ELogLevel), logrec.LogLevel), TimeUtc = logrec.TimeUtc, Message = logrec.Message, ExceptionType = logrec.ExceptionType, ExceptionMessage = logrec.ExceptionMessage, ExceptionAdditionalInfo = logrec.ExceptionAdditionalInfo, CorrelationId = logrec.CorrelationId, Server = logrec.Server, ApplicationPath = logrec.ApplicationPath, ProcessId = logrec.ProcessId, ThreadId = logrec.ThreadId, Identity = logrec.Identity, PerfData = logrec.PerformanceData }; if (logrec.AdditionalFields != null) { res.Host = logrec.AdditionalFields.TryGetValue("Host", out v) ? ((string)v).ShortenIfNecessary(100) : null; res.LoggedUser = logrec.AdditionalFields.TryGetValue("LoggedUser", out v) ? ((string)v).ShortenIfNecessary(200) : null; res.HttpStatusCode = logrec.AdditionalFields.TryGetValue("HttpStatusCode", out v) ? ((string)v).ShortenIfNecessary(15) : null; res.Url = logrec.AdditionalFields.TryGetValue("Url", out v) ? ((string)v).ShortenIfNecessary(2000) : null; res.Referer = logrec.AdditionalFields.TryGetValue("Referer", out v) ? ((string)v).ShortenIfNecessary(2000) : null; res.ClientIP = logrec.AdditionalFields.TryGetValue("ClientIP", out v) ? ((string)v).ShortenIfNecessary(50) : null; res.RequestData = logrec.AdditionalFields.TryGetValue("RequestData", out v) ? ((string)v).ShortenIfNecessary(2000) : null; res.ResponseData = logrec.AdditionalFields.TryGetValue("ResponseData", out v) ? ((string)v).ShortenIfNecessary(2000) : null; res.ServiceName = logrec.AdditionalFields.TryGetValue("ServiceName", out v) ? ((string)v).ShortenIfNecessary(100) : null; res.ServiceDisplayName = logrec.AdditionalFields.TryGetValue("ServiceDisplayName", out v) ? ((string)v).ShortenIfNecessary(200) : null; } return(res); }