Skip to content

Commit e8c32f7

Browse files
author
Sergey Komisarchik
committed
remove Thread dependency and add compat up to netstandard1.0
1 parent 8911305 commit e8c32f7

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/Serilog.Enrichers.Thread/Enrichers/ThreadIdEnricher.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
using System.Threading;
1616
using Serilog.Core;
1717
using Serilog.Events;
18+
using System;
1819

1920
namespace Serilog.Enrichers
2021
{
2122
/// <summary>
22-
/// Enriches log events with a ThreadId property containing the current <see cref="Thread.ManagedThreadId"/>.
23+
/// Enriches log events with a ThreadId property containing the <see cref="Environment.CurrentManagedThreadId"/>.
2324
/// </summary>
2425
public class ThreadIdEnricher : ILogEventEnricher
2526
{
@@ -35,7 +36,7 @@ public class ThreadIdEnricher : ILogEventEnricher
3536
/// <param name="propertyFactory">Factory for creating new properties to add to the event.</param>
3637
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
3738
{
38-
logEvent.AddPropertyIfAbsent(new LogEventProperty(ThreadIdPropertyName, new ScalarValue(Thread.CurrentThread.ManagedThreadId)));
39+
logEvent.AddPropertyIfAbsent(new LogEventProperty(ThreadIdPropertyName, new ScalarValue(Environment.CurrentManagedThreadId)));
3940
}
4041
}
4142
}

src/Serilog.Enrichers.Thread/ThreadLoggerConfigurationExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
namespace Serilog
2222
{
2323
/// <summary>
24-
/// Extends <see cref="LoggerConfiguration"/> to add enrichers for <see cref="Thread"/>.
24+
/// Extends <see cref="LoggerConfiguration"/> to add enrichers for <see cref="Environment.CurrentManagedThreadId"/>.
2525
/// capabilities.
2626
/// </summary>
2727
public static class ThreadLoggerConfigurationExtensions
2828
{
2929
/// <summary>
30-
/// Enrich log events with a ThreadId property containing the current <see cref="Thread.ManagedThreadId"/>.
30+
/// Enrich log events with a ThreadId property containing the <see cref="Environment.CurrentManagedThreadId"/>.
3131
/// </summary>
3232
/// <param name="enrichmentConfiguration">Logger enrichment configuration.</param>
3333
/// <returns>Configuration object allowing method chaining.</returns>

src/Serilog.Enrichers.Thread/project.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.0.0-rc-*",
2+
"version": "2.0.1-*",
33
"description": "Enrich Serilog events with properties from the current thread.",
44
"authors": [ "Serilog Contributors" ],
55
"packOptions": {
@@ -9,7 +9,7 @@
99
"iconUrl": "http://serilog.net/images/serilog-enricher-nuget.png"
1010
},
1111
"dependencies": {
12-
"Serilog": "2.0.0-rc-577"
12+
"Serilog": "2.0.0"
1313
},
1414
"buildOptions": {
1515
"keyFile": "../../assets/Serilog.snk",
@@ -19,9 +19,8 @@
1919
"frameworks": {
2020
"net4.5": {
2121
},
22-
"netstandard1.3": {
22+
"netstandard1.0": {
2323
"dependencies": {
24-
"System.Threading.Thread": "4.0.0-rc2-24027"
2524
}
2625
}
2726
}

0 commit comments

Comments
 (0)