From f9d296a406b631c35cbcfe853f75d6e5e019dc47 Mon Sep 17 00:00:00 2001 From: Stewart Webb Date: Fri, 15 May 2026 22:19:07 +1000 Subject: [PATCH 1/3] add new env var to allow stdout logs to not have header for every single line of multiline messages --- src/Runner.Common/Constants.cs | 1 + src/Runner.Common/StdoutTraceListener.cs | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/Runner.Common/Constants.cs b/src/Runner.Common/Constants.cs index 42f6e714781..72bdafb829d 100644 --- a/src/Runner.Common/Constants.cs +++ b/src/Runner.Common/Constants.cs @@ -308,6 +308,7 @@ public static class Agent public static readonly string ForcedInternalNodeVersion = "ACTIONS_RUNNER_FORCED_INTERNAL_NODE_VERSION"; public static readonly string ForcedActionsNodeVersion = "ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION"; public static readonly string PrintLogToStdout = "ACTIONS_RUNNER_PRINT_LOG_TO_STDOUT"; + public static readonly string StdoutMultilineLogPrefixing = "ACTIONS_RUNNER_STDOUT_MULTILINE_LOG_PREFIXING"; public static readonly string ActionArchiveCacheDirectory = "ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE"; public static readonly string SymlinkCachedActions = "ACTIONS_RUNNER_SYMLINK_CACHED_ACTIONS"; public static readonly string EmitCompositeMarkers = "ACTIONS_RUNNER_EMIT_COMPOSITE_MARKERS"; diff --git a/src/Runner.Common/StdoutTraceListener.cs b/src/Runner.Common/StdoutTraceListener.cs index 150263ac77c..1c1d77a0781 100644 --- a/src/Runner.Common/StdoutTraceListener.cs +++ b/src/Runner.Common/StdoutTraceListener.cs @@ -9,10 +9,18 @@ namespace GitHub.Runner.Common public sealed class StdoutTraceListener : ConsoleTraceListener { private readonly string _hostType; + private readonly bool _prefixMultilineLogs = true; public StdoutTraceListener(string hostType) { this._hostType = hostType; + // The stdout log prefixing behaviour was on before this environment variable, + // so only disable it if the env var was set + bool multilinePrefixingEnvSetting = StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable(Constants.Variables.Agent.StdoutMultilineLogPrefixing), defaultValue: true); + if (!multilinePrefixingEnvSetting) + { + this._prefixMultilineLogs = false; + } } // Copied and modified slightly from .Net Core source code. Modification was required to make it compile. @@ -26,11 +34,20 @@ public override void TraceEvent(TraceEventCache eventCache, string source, Trace if (!string.IsNullOrEmpty(message)) { - var messageLines = message.Split(Environment.NewLine); - foreach (var messageLine in messageLines) + if (this._prefixMultilineLogs) + { + var messageLines = message.Split(Environment.NewLine); + foreach (var messageLine in messageLines) + { + WriteHeader(source, eventType, id); + WriteLine(messageLine); + WriteFooter(eventCache); + } + } + else { WriteHeader(source, eventType, id); - WriteLine(messageLine); + WriteLine(message); WriteFooter(eventCache); } } From cca5076ab8528e0af872822d7503479d019374e7 Mon Sep 17 00:00:00 2001 From: Tingluo Huang Date: Mon, 8 Jun 2026 11:12:29 -0400 Subject: [PATCH 2/3] Rename StdoutMultilineLogPrefixing constant --- src/Runner.Common/Constants.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Runner.Common/Constants.cs b/src/Runner.Common/Constants.cs index 72bdafb829d..8536e942a27 100644 --- a/src/Runner.Common/Constants.cs +++ b/src/Runner.Common/Constants.cs @@ -308,7 +308,7 @@ public static class Agent public static readonly string ForcedInternalNodeVersion = "ACTIONS_RUNNER_FORCED_INTERNAL_NODE_VERSION"; public static readonly string ForcedActionsNodeVersion = "ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION"; public static readonly string PrintLogToStdout = "ACTIONS_RUNNER_PRINT_LOG_TO_STDOUT"; - public static readonly string StdoutMultilineLogPrefixing = "ACTIONS_RUNNER_STDOUT_MULTILINE_LOG_PREFIXING"; + public static readonly string DisableStdoutMultilineLogPrefixing = "ACTIONS_RUNNER_DISABLE_STDOUT_MULTILINE_LOG_PREFIXING"; public static readonly string ActionArchiveCacheDirectory = "ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE"; public static readonly string SymlinkCachedActions = "ACTIONS_RUNNER_SYMLINK_CACHED_ACTIONS"; public static readonly string EmitCompositeMarkers = "ACTIONS_RUNNER_EMIT_COMPOSITE_MARKERS"; From 866f21461e6ddf1e8ce09a74e1a589e40c3dfeda Mon Sep 17 00:00:00 2001 From: Tingluo Huang Date: Mon, 8 Jun 2026 11:13:14 -0400 Subject: [PATCH 3/3] Change multiline log prefixing behavior --- src/Runner.Common/StdoutTraceListener.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Runner.Common/StdoutTraceListener.cs b/src/Runner.Common/StdoutTraceListener.cs index 1c1d77a0781..81d36cadc9b 100644 --- a/src/Runner.Common/StdoutTraceListener.cs +++ b/src/Runner.Common/StdoutTraceListener.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.Globalization; using System.IO; @@ -9,18 +9,12 @@ namespace GitHub.Runner.Common public sealed class StdoutTraceListener : ConsoleTraceListener { private readonly string _hostType; - private readonly bool _prefixMultilineLogs = true; + private readonly bool _disablePrefixMultilineLogs = false; public StdoutTraceListener(string hostType) { this._hostType = hostType; - // The stdout log prefixing behaviour was on before this environment variable, - // so only disable it if the env var was set - bool multilinePrefixingEnvSetting = StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable(Constants.Variables.Agent.StdoutMultilineLogPrefixing), defaultValue: true); - if (!multilinePrefixingEnvSetting) - { - this._prefixMultilineLogs = false; - } + this._disablePrefixMultilineLogs = StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable(Constants.Variables.Agent.DisableStdoutMultilineLogPrefixing)); } // Copied and modified slightly from .Net Core source code. Modification was required to make it compile. @@ -34,7 +28,7 @@ public override void TraceEvent(TraceEventCache eventCache, string source, Trace if (!string.IsNullOrEmpty(message)) { - if (this._prefixMultilineLogs) + if (!this._disablePrefixMultilineLogs) { var messageLines = message.Split(Environment.NewLine); foreach (var messageLine in messageLines)