Skip to content
Merged
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
7 changes: 4 additions & 3 deletions src/log4net/Core/LoggingEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -736,17 +736,18 @@ public string ThreadName
m_data.ThreadName =
SystemInfo.CurrentThreadId.ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
#else
// '.NET ThreadPool Worker' appears as a default thread pool name in .NET 6+.
// '.NET ThreadPool Worker' appears as a default thread name in the .NET 6-7 thread pool.
// '.NET TP Worker' is the default thread name in the .NET 8+ thread pool.
// Prefer the numeric thread ID instead.
string threadName = System.Threading.Thread.CurrentThread.Name;
if (!string.IsNullOrEmpty(threadName) && threadName != ".NET ThreadPool Worker")
if (!string.IsNullOrEmpty(threadName) && threadName != ".NET TP Worker" && threadName != ".NET ThreadPool Worker")
{
m_data.ThreadName = threadName;
}
else
{
// The thread name is not available or unsuitable. Therefore we
// go the the AppDomain to get the ID of the
// go to the AppDomain to get the ID of the
// current thread. (Why don't Threads know their own ID?)
try
{
Expand Down