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);
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.");
}
}
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?
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: