Skip to content

Commit dff597c

Browse files
committed
Support converting '.NET TP Worker' to the numeric thread ID on .NET 8+
1 parent e024c5c commit dff597c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/log4net/Core/LoggingEvent.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -736,17 +736,18 @@ public string ThreadName
736736
m_data.ThreadName =
737737
SystemInfo.CurrentThreadId.ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
738738
#else
739-
// '.NET ThreadPool Worker' appears as a default thread pool name in .NET 6+.
739+
// '.NET ThreadPool Worker' appears as a default thread name in the .NET 6-7 thread pool.
740+
// '.NET TP Worker' is the default thread name in the .NET 8+ thread pool.
740741
// Prefer the numeric thread ID instead.
741742
string threadName = System.Threading.Thread.CurrentThread.Name;
742-
if (!string.IsNullOrEmpty(threadName) && threadName != ".NET ThreadPool Worker")
743+
if (!string.IsNullOrEmpty(threadName) && threadName != ".NET ThreadPool Worker" && threadName != ".NET TP Worker")
743744
{
744745
m_data.ThreadName = threadName;
745746
}
746747
else
747748
{
748749
// The thread name is not available or unsuitable. Therefore we
749-
// go the the AppDomain to get the ID of the
750+
// go to the AppDomain to get the ID of the
750751
// current thread. (Why don't Threads know their own ID?)
751752
try
752753
{

0 commit comments

Comments
 (0)