diff --git a/Directory.Packages.props b/Directory.Packages.props
index 3e160e1..1e656e6 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -9,6 +9,7 @@
+
diff --git a/src/Nocr.TelegramListener.Host/Infrastructure/HostBuilderFactory.cs b/src/Nocr.TelegramListener.Host/Infrastructure/HostBuilderFactory.cs
index adc35a7..33ee306 100644
--- a/src/Nocr.TelegramListener.Host/Infrastructure/HostBuilderFactory.cs
+++ b/src/Nocr.TelegramListener.Host/Infrastructure/HostBuilderFactory.cs
@@ -18,6 +18,8 @@ public class HostBuilderFactory where TStartup : class
.UseSerilog((ctx, logBuilder) =>
{
logBuilder.ReadFrom.Configuration(ctx.Configuration)
+ .Enrich.With()
+ .Enrich.WithThreadId()
.Enrich.FromLogContext();
});
diff --git a/src/Nocr.TelegramListener.Host/Infrastructure/ShortSourceContextEnricher.cs b/src/Nocr.TelegramListener.Host/Infrastructure/ShortSourceContextEnricher.cs
new file mode 100644
index 0000000..45254ad
--- /dev/null
+++ b/src/Nocr.TelegramListener.Host/Infrastructure/ShortSourceContextEnricher.cs
@@ -0,0 +1,16 @@
+using Serilog.Core;
+using Serilog.Events;
+
+public class ShortSourceContextEnricher : ILogEventEnricher
+{
+ public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
+ {
+ if (logEvent.Properties.TryGetValue("SourceContext", out var sourceContextValue))
+ {
+ var fullName = sourceContextValue.ToString().Trim('"'); // remove quotes
+ var shortName = fullName.Split('.').Last();
+ var shortContext = propertyFactory.CreateProperty("ShortSourceContext", shortName);
+ logEvent.AddPropertyIfAbsent(shortContext);
+ }
+ }
+}
diff --git a/src/Nocr.TelegramListener.Host/Nocr.TelegramListener.Host.csproj b/src/Nocr.TelegramListener.Host/Nocr.TelegramListener.Host.csproj
index 9558aa2..7f6bb28 100644
--- a/src/Nocr.TelegramListener.Host/Nocr.TelegramListener.Host.csproj
+++ b/src/Nocr.TelegramListener.Host/Nocr.TelegramListener.Host.csproj
@@ -8,6 +8,7 @@
+
diff --git a/src/Nocr.TelegramListener.Host/appsettings.json b/src/Nocr.TelegramListener.Host/appsettings.json
index a06c301..36638cd 100644
--- a/src/Nocr.TelegramListener.Host/appsettings.json
+++ b/src/Nocr.TelegramListener.Host/appsettings.json
@@ -12,7 +12,7 @@
{
"Name": "Console",
"Args": {
- "outputTemplate": "[{Level:u3}] {Timestamp:MM-dd HH:mm:ss} {TraceId} {SourceContext:l} {Message:lj}{NewLine}{Exception}"
+ "outputTemplate": "[{Level:u3}] {Timestamp:MM-dd HH:mm:ss} [#{ThreadId}] {ShortSourceContext:l} {Message:lj}{NewLine}{Exception}"
}
}
]