Michal Rakoczy created LOG4NET-695:
--------------------------------------
Summary: LoggingEvent - ThreadName calculated incorrectly in .net8
Key: LOG4NET-695
URL: https://issues.apache.org/jira/browse/LOG4NET-695
Project: Log4net
Issue Type: Bug
Components: Core
Affects Versions: 2.0.14
Reporter: Michal Rakoczy
Version:
{code}
log4net 2.0.15
{code}
Problematic code:
https://github.com/apache/logging-log4net/blob/master/src/log4net/Core/LoggingEvent.cs
{code}
public string ThreadName
{
get
{
if (m_data.ThreadName == null && this.m_cacheUpdatable)
{
#if NETCF
// Get thread ID only
m_data.ThreadName =
SystemInfo.CurrentThreadId.ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
#else
// '.NET ThreadPool Worker' appears as a default thread
pool name in .NET 6+.
// Prefer the numeric thread ID instead.
string threadName =
System.Threading.Thread.CurrentThread.Name;
if (!string.IsNullOrEmpty(threadName) && threadName !=
".NET ThreadPool Worker")
{
m_data.ThreadName = threadName;
}
{code}
In .NET 8 the threads from thread pool have new name: ".NET TP Worker".
So probably additional condition in this code is required:
{code}
if (!string.IsNullOrEmpty(threadName) && threadName != ".NET ThreadPool Worker"
&& threadName != ".NET TP Worker")
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)