MAUI: How we can view debug statements in release mode - Stack Overflow

admin2025-04-28  2

I am trying to print the debugger statements on release mode for resolving one issue.

For that I did below changes:

1 Added DebugType, DebugSymbols, Debuggable and AndroidEnableDeveloperInstrumentation on .csproj file.

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android|AnyCPU'">
  <ApplicationId>companyname.appname</ApplicationId>
  <AndroidPackageFormat>apk</AndroidPackageFormat>
  <ApplicationTitle>appname</ApplicationTitle>
  <DebugType>portable</DebugType>
  <DebugSymbols>true</DebugSymbols>
  <Debuggable>true</Debuggable>
  <AndroidEnableDeveloperInstrumentation>true</AndroidEnableDeveloperInstrumentation>
</PropertyGroup>

2 Added android:debuggable="true" in android manifext file under application.

3 Added below code in MAUIProgram.cs.

builder.Logging.AddConsole(options =>
{
    options.IncludeScopes = true;
});
builder.Logging.SetMinimumLevel(LogLevel.Debug);
  1. Under App.xaml.cs added below code.

    using Microsoft.Extensions.Logging;

    public partial class App : Application { public App(ILogger logger) { InitializeComponent();

         logger.LogInformation("App started in production mode.");
         logger.LogError("An error occurred.");
     }
    

    }

  2. Under project properties enabled developer instrumentation for release mode.

But when I run in release mode I am getting below screen.

Is there any other changes to view the debugger statements in release mode?

I am trying to print the debugger statements on release mode for resolving one issue.

For that I did below changes:

1 Added DebugType, DebugSymbols, Debuggable and AndroidEnableDeveloperInstrumentation on .csproj file.

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android|AnyCPU'">
  <ApplicationId>com.companyname.appname</ApplicationId>
  <AndroidPackageFormat>apk</AndroidPackageFormat>
  <ApplicationTitle>appname</ApplicationTitle>
  <DebugType>portable</DebugType>
  <DebugSymbols>true</DebugSymbols>
  <Debuggable>true</Debuggable>
  <AndroidEnableDeveloperInstrumentation>true</AndroidEnableDeveloperInstrumentation>
</PropertyGroup>

2 Added android:debuggable="true" in android manifext file under application.

3 Added below code in MAUIProgram.cs.

builder.Logging.AddConsole(options =>
{
    options.IncludeScopes = true;
});
builder.Logging.SetMinimumLevel(LogLevel.Debug);
  1. Under App.xaml.cs added below code.

    using Microsoft.Extensions.Logging;

    public partial class App : Application { public App(ILogger logger) { InitializeComponent();

         logger.LogInformation("App started in production mode.");
         logger.LogError("An error occurred.");
     }
    

    }

  2. Under project properties enabled developer instrumentation for release mode.

But when I run in release mode I am getting below screen.

Is there any other changes to view the debugger statements in release mode?

Share Improve this question asked Jan 8 at 13:22 Matthew PansMatthew Pans 8891 gold badge11 silver badges29 bronze badges 3
  • you need to look at the logs, not the output window – Jason Commented Jan 8 at 14:47
  • @Jason In output window itself all logs are coming? – Matthew Pans Commented Jan 8 at 15:53
  • Possible duplicate of stackoverflow.com/questions/74798921/… – Stephen Quan Commented Jan 9 at 9:26
Add a comment  | 

1 Answer 1

Reset to default 1

As I can see from your screenshots you are building for Android. If that is the case, then use

    Console.WriteLine(DebugLine);

Then check logcat for any DOTNET lines. Should look like this:

转载请注明原文地址:http://anycun.com/QandA/1745854855a91267.html