From 74fee42bdf1c5096fab0d095f5f7c3400c5f2726 Mon Sep 17 00:00:00 2001 From: wiselen <123637620+wiselencave@users.noreply.github.com> Date: Sat, 2 Aug 2025 20:43:28 +0300 Subject: [PATCH] Update logging.md Fix docs: log messages not shown in Visual Studio Output by default --- en/manual/troubleshooting/logging.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/en/manual/troubleshooting/logging.md b/en/manual/troubleshooting/logging.md index d335eca4..d89224a0 100644 --- a/en/manual/troubleshooting/logging.md +++ b/en/manual/troubleshooting/logging.md @@ -17,7 +17,19 @@ The name of the module (such as the script containing the log message) is displa The console displays log messages from all modules, not just your own scripts. For example, it also displays messages from the @'Stride.Core.Serialization.Contents.ContentManager'. -If you run your game from Visual Studio, log messages are shown in the Visual Studio **Output** window instead. +If you run your game from Visual Studio, log messages are not shown in the **Output** window by default. +To display them, you need to manually register a log listener that writes to `Debug.WriteLine` (see example below). + +```csharp +GlobalLogger.GlobalMessageLogged += new TextWriterLogListener(new DebugTextWriter()); + +// Minimal TextWriter for Output window logging +public class DebugTextWriter : TextWriter +{ + public override Encoding Encoding => Encoding.UTF8; + public override void WriteLine(string? value) => Debug.WriteLine(value); +} +``` ![Log output window](media/log-output-in-visual-studio.png) @@ -133,4 +145,4 @@ namespace MyGame * [Debug text](debug-text.md) * [Profiling](profiling.md) -* [Scripts](../scripts/index.md) \ No newline at end of file +* [Scripts](../scripts/index.md)