public AzureDynamicLoggingEventEntity(LoggingEvent e, PartitionKeyTypeEnum partitionKeyType) { this["Domain"] = e.Domain; this["Identity"] = e.Identity; this["Level"] = e.Level.ToString(); this["LoggerName"] = e.LoggerName; this["Message"] = e.RenderedMessage + Environment.NewLine + e.GetExceptionString(); this["EventTimeStamp"] = e.TimeStamp; this["ThreadName"] = e.ThreadName; this["UserName"] = e.UserName; this["Location"] = e.LocationInformation.FullInfo; if (e.ExceptionObject != null) { this["Exception"] = e.ExceptionObject.ToString(); } foreach (DictionaryEntry entry in e.Properties) { var key = entry.Key.ToString() .Replace(":", "_") .Replace("@", "_") .Replace(".", "_"); this[key] = entry.Value; } Timestamp = e.TimeStamp; PartitionKey = e.MakePartitionKey(partitionKeyType); RowKey = e.MakeRowKey(); }
public AzureDynamicLoggingEventEntity(LoggingEvent e, PartitionKeyTypeEnum partitionKeyType) { this["Domain"] = e.Domain; this["Identity"] = e.Identity; this["Level"] = e.Level.ToString(); this["LoggerName"] = e.LoggerName; this["Message"] = e.RenderedMessage + Environment.NewLine + e.GetExceptionString(); this["EventTimeStamp"] = e.TimeStamp; this["ThreadName"] = e.ThreadName; this["UserName"] = e.UserName; this["Location"] = e.LocationInformation.FullInfo; if (e.ExceptionObject != null) { this["Exception"] = e.ExceptionObject.ToString(); } foreach (DictionaryEntry entry in e.Properties) { var key = entry.Key.ToString() .Replace(":", "_") .Replace("@", "_") .Replace(".", "_"); this[key] = entry.Value; } Timestamp = e.TimeStamp; PartitionKey = e.MakePartitionKey(partitionKeyType); RowKey = e.MakeRowKey(); }
public AzureLoggingEventEntity(LoggingEvent e, PartitionKeyTypeEnum partitionKeyType) { Domain = e.Domain; Identity = e.Identity; Level = e.Level.ToString(); var sb = new StringBuilder(e.Properties.Count); foreach (DictionaryEntry entry in e.Properties) { sb.AppendFormat("{0}:{1}", entry.Key, entry.Value); sb.AppendLine(); } Properties = sb.ToString(); Message = e.RenderedMessage + Environment.NewLine + e.GetExceptionString(); ThreadName = e.ThreadName; EventTimeStamp = e.TimeStamp; UserName = e.UserName; Location = e.LocationInformation.FullInfo; ClassName = e.LocationInformation.ClassName; FileName = e.LocationInformation.FileName; LineNumber = e.LocationInformation.LineNumber; MethodName = e.LocationInformation.MethodName; StackFrames = e.LocationInformation.StackFrames; if (e.ExceptionObject != null) { Exception = e.ExceptionObject.ToString(); } PartitionKey = e.MakePartitionKey(partitionKeyType); RowKey = e.MakeRowKey(); SequenceNumber = 0; }
public AzureLoggingEventEntity(LoggingEvent e, PartitionKeyTypeEnum partitionKeyType) { Domain = e.Domain; Identity = e.Identity; Level = e.Level.ToString(); var sb = new StringBuilder(e.Properties.Count); foreach (DictionaryEntry entry in e.Properties) { sb.AppendFormat("{0}:{1}", entry.Key, entry.Value); sb.AppendLine(); } Properties = sb.ToString(); Message = e.RenderedMessage + Environment.NewLine + e.GetExceptionString(); ThreadName = e.ThreadName; EventTimeStamp = e.TimeStamp; UserName = e.UserName; Location = e.LocationInformation.FullInfo; ClassName = e.LocationInformation.ClassName; FileName = e.LocationInformation.FileName; LineNumber = e.LocationInformation.LineNumber; MethodName = e.LocationInformation.MethodName; StackFrames = e.LocationInformation.StackFrames; if (e.ExceptionObject != null) { Exception = e.ExceptionObject.ToString(); } PartitionKey = e.MakePartitionKey(partitionKeyType); RowKey = e.MakeRowKey(); }
public AzureLayoutLoggingEventEntity(LoggingEvent e, PartitionKeyTypeEnum partitionKeyType, ILayout layout) { Level = e.Level.ToString(); Message = e.RenderedMessage + Environment.NewLine + e.GetExceptionString(); ThreadName = e.ThreadName; EventTimeStamp = e.TimeStamp; using (var w = new StringWriter()) { layout.Format(w, e); Message = w.ToString(); } PartitionKey = e.MakePartitionKey(partitionKeyType); RowKey = e.MakeRowKey(); }
public AzureLayoutLoggingEventEntity(LoggingEvent e, PartitionKeyTypeEnum partitionKeyType, ILayout layout) { Level = e.Level.ToString(); Message = e.RenderedMessage + Environment.NewLine + e.GetExceptionString(); ThreadName = e.ThreadName; EventTimeStamp = e.TimeStamp; using (var w = new StringWriter()) { layout.Format(w, e); Message = w.ToString(); } PartitionKey = e.MakePartitionKey(partitionKeyType); RowKey = e.MakeRowKey(); }
internal static string MakePartitionKey(this LoggingEvent loggingEvent, PartitionKeyTypeEnum partitionKeyType) { switch (partitionKeyType) { case PartitionKeyTypeEnum.LoggerName: return(loggingEvent.LoggerName); case PartitionKeyTypeEnum.DateReverse: // subtract from DateMaxValue the Tick Count of the current hour // so a Table Storage Partition spans an hour return($"{(DateTime.MaxValue.Ticks - loggingEvent.TimeStampUtc.Date.AddHours(loggingEvent.TimeStamp.Hour).Ticks + 1):D19}"); default: throw new ArgumentOutOfRangeException(nameof(partitionKeyType), partitionKeyType, null); } }
internal static string MakePartitionKey(this LoggingEvent loggingEvent, PartitionKeyTypeEnum partitionKeyType) { switch (partitionKeyType) { case PartitionKeyTypeEnum.LoggerName: return loggingEvent.LoggerName; case PartitionKeyTypeEnum.DateReverse: // substract from DateMaxValue the Tick Count of the current hour // so a Table Storage Parttition spans an hour return string.Format("{0:D19}", (DateTime.MaxValue.Ticks - loggingEvent.TimeStamp.Date.AddHours(loggingEvent.TimeStamp.Hour).Ticks + 1)); default: // ReSharper disable once NotResolvedInText throw new ArgumentOutOfRangeException("PartitionKeyType", partitionKeyType, null); } }
internal static string MakePartitionKey(this LoggingEvent loggingEvent, PartitionKeyTypeEnum partitionKeyType) { switch (partitionKeyType) { case PartitionKeyTypeEnum.LoggerName: return(loggingEvent.LoggerName); case PartitionKeyTypeEnum.DateReverse: // substract from DateMaxValue the Tick Count of the current hour // so a Table Storage Partition spans an hour return(string.Format("{0:D19}", DateTime.MaxValue.Ticks - loggingEvent.TimeStamp.Date.AddHours(loggingEvent.TimeStamp.Hour).Ticks + 1)); default: // ReSharper disable once NotResolvedInText throw new ArgumentOutOfRangeException("PartitionKeyType", partitionKeyType, null); } }
public AzureDynamicLoggingEventEntity(LoggingEvent e, PartitionKeyTypeEnum partitionKeyType, HashSet <string> columns) { void Add(string key, object value) { if (columns == null || columns.Contains(key)) { this[key.Replace(":", "_").Replace("@", "_").Replace(".", "_")] = value; } } Add("Domain", e.Domain); Add("Identity", e.Identity); Add("Level", e.Level.ToString()); Add("LoggerName", e.LoggerName); Add("Message", e.RenderedMessage); Add("EventTimeStamp", e.TimeStamp.ToUniversalTime()); Add("ThreadName", e.ThreadName); Add("UserName", e.UserName); Add("Location", e.LocationInformation.FullInfo); if (e.ExceptionObject != null) { Add("Exception", e.GetExceptionString()); } foreach (DictionaryEntry entry in e.Properties) { var value = entry.Value; if (value != null && !(value is byte[]) && !(value is bool) && !(value is DateTimeOffset) && !(value is DateTime) && !(value is double) && !(value is Guid) && !(value is int) && !(value is long) && !(value is string)) { value = e.Repository?.RendererMap.FindAndRender(value) ?? value.ToString(); } Add(entry.Key.ToString(), value); } Timestamp = e.TimeStamp.ToUniversalTime(); PartitionKey = e.MakePartitionKey(partitionKeyType); RowKey = e.MakeRowKey(); }
public AzureLoggingEventEntity(LoggingEvent e, PartitionKeyTypeEnum partitionKeyType) { // NOTE - Remove fields that don't make sense in .NET Standard //Domain = e.Domain; //Identity = e.Identity; Level = e.Level.ToString(); if (e.Properties != null && e.Properties.Count > 0) { var sb = new StringBuilder(); foreach (DictionaryEntry entry in e.Properties) { sb.AppendFormat("{0}:{1}", entry.Key, entry.Value); sb.AppendLine(); } Properties = sb.ToString(); } var exception = e.GetExceptionString(); Message = string.IsNullOrWhiteSpace(exception) ? e.RenderedMessage : e.RenderedMessage + Environment.NewLine + exception; ThreadName = e.ThreadName; EventTimeStamp = e.TimeStampUtc; //UserName = e.UserName; //Location = e.LocationInformation.FullInfo; //ClassName = e.LocationInformation.ClassName; //FileName = e.LocationInformation.FileName; //LineNumber = e.LocationInformation.LineNumber; //MethodName = e.LocationInformation.MethodName; // TODO - No stack frames for .NET Standard? //StackFrames = e.LocationInformation.StackFrames; if (e.ExceptionObject != null) { Exception = e.ExceptionObject.ToString(); } PartitionKey = e.MakePartitionKey(partitionKeyType); RowKey = e.MakeRowKey(); }
public AzureDynamicLoggingEventEntity(LoggingEvent e, PartitionKeyTypeEnum partitionKeyType) { // NOTE - Remove fields that don't make sense in .NET Standard //this["Domain"] = e.Domain; //this["Identity"] = e.Identity; this["Level"] = e.Level.ToString(); this["LoggerName"] = e.LoggerName; var exception = e.GetExceptionString(); this["Message"] = string.IsNullOrWhiteSpace(exception) ? e.RenderedMessage : e.RenderedMessage + Environment.NewLine + exception; this["EventTimeStamp"] = e.TimeStampUtc; this["ThreadName"] = e.ThreadName; //this["UserName"] = e.UserName; //this["Location"] = e.LocationInformation.FullInfo; if (e.ExceptionObject != null) { this["Exception"] = e.ExceptionObject.ToString(); } if (e.Properties != null && e.Properties.Count > 0) { foreach (DictionaryEntry entry in e.Properties) { var key = entry.Key.ToString() .Replace(":", "_") .Replace("@", "_") .Replace(".", "_"); this[key] = entry.Value; } } Timestamp = e.TimeStampUtc; PartitionKey = e.MakePartitionKey(partitionKeyType); RowKey = e.MakeRowKey(); }
public AzureLayoutLoggingEventEntity(LoggingEvent e, PartitionKeyTypeEnum partitionKeyType, ILayout layout) { Level = e.Level.ToString(); Message = e.RenderedMessage + Environment.NewLine + e.GetExceptionString(); ThreadName = e.ThreadName; EventTimeStamp = e.TimeStamp; using (var w = new StringWriter()) { layout.Format(w, e); Message = w.ToString(); } // Azure Storage Table string is encoded as a UTF-16-encoded value. // String values may be up to 64 KB in size. Note that the maximum number of characters supported is about 32 K or less. // To be safe we allow 32k characters instead of 32KB of string. if (Message.Length >= 32000) { Message = $"{Message.Substring(0, 31987)}... TRUNCATED"; } PartitionKey = e.MakePartitionKey(partitionKeyType); RowKey = e.MakeRowKey(); }
public AzureLoggingEventEntity(LoggingEvent e, PartitionKeyTypeEnum partitionKeyType, string message, int sequenceNumber) : this(e, partitionKeyType) { Message = message; SequenceNumber = sequenceNumber; }
public AzureDynamicLoggingEventEntity(LoggingEvent e, PartitionKeyTypeEnum partitionKeyType, string message, int sequenceNumber) : this(e, partitionKeyType) { this["Message"] = message; this["SequenceNumber"] = sequenceNumber; }
private DocDbCollectionSettings(string collectionName, PartitionKeyTypeEnum partitionKey, bool enableCrossParitionQueries) { CollectionName = collectionName; PartitionKeyType = partitionKey; EnableCrossParitionQueries = enableCrossParitionQueries; }
public static DocDbCollectionSettings Create(string collectionName, PartitionKeyTypeEnum partitionKey = PartitionKeyTypeEnum.None) { return(new DocDbCollectionSettings(collectionName, partitionKey, partitionKey != PartitionKeyTypeEnum.None)); }