Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ Log.Logger = new LoggerConfiguration()
.CreateLogger();
```

To get tags to populate on the exceptionless UI, add a `Tags` string enumerable to any log.

```Example with Serilog:
Serilog: Log.ForContext("Tags", new List() { "Tag1", "Tag2"}).Information("Seri info");
```

```Example with ILogger
using (var scope = _logger.BeginScope(new Dictionary<string, object> { ["Tags"] = new string[] { "Tag1", "Tag2" }}))
{
_logger.Log(logLevel, eventId, state, exception, formatter);
}
```

* [Documentation](https://github.com/serilog/serilog/wiki)

Copyright &copy; 2023 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html).
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Exceptionless;
using Exceptionless.Logging;
using Serilog.Core;
Expand Down Expand Up @@ -36,6 +37,20 @@ internal static string GetSource(this LogEvent log) {
return null;
}

internal static string[] GetTags(this LogEventPropertyValue value)
{
var propertyCollection = value.FlattenProperties() as List<object>;
if (propertyCollection == null) return Array.Empty<string>();

List<string> tags = new List<string>();
foreach (var item in propertyCollection)
{
tags.Add(item.ToString());
}

return tags.ToArray();
}

internal static LogLevel GetLevel(this LogEventLevel log)
{
switch (log)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ public void Emit(LogEvent logEvent) {
if (!String.IsNullOrWhiteSpace(emailAddress) || !String.IsNullOrWhiteSpace(description))
builder.SetUserDescription(emailAddress, description);
break;
case "Tags":
builder.AddTags(prop.Value.GetTags());
break;
default:
builder.SetProperty(prop.Key, prop.Value.FlattenProperties());
break;
Expand Down