-
-
Notifications
You must be signed in to change notification settings - Fork 0
Logging and Diagnostics
The native Kotlin and Swift wrappers expose logging protocols that map to standard .NET logging levels.
- Trace
- Debug
- Information
- Warning
- Error
- Critical
- None
Trace output may contain detailed runtime information and should normally be disabled in production.
MAUICross supplies native Android and iOS logger adapters automatically. Add the providers you want before registering the wrapper:
builder.Logging.AddDebug();
builder.UseAMDevITAdMobWrapper();The adapters preserve the native tag and message and route them through
Microsoft.Extensions.Logging.
Typical categories include the MAUI banner handler, consent service, interstitial service, rewarded service, and app-open service.
Implement IDroidLogger and pass it to supported constructors. The protocol
contains IsEnabled plus one method for each level:
LogTrace, LogDebug, LogInfo, LogWarning,
LogError, LogCritical
Use a stable logger instance for the manager and wrappers so messages from consent, initialization, loading, presentation, and dismissal can be correlated.
Implement IAppleLogger as an NSObject:
public sealed class ConsoleAppleLogger : NSObject, IAppleLogger
{
public bool IsEnabled(AppleLogLevel level) => level != AppleLogLevel.None;
public void LogTrace(string message, string? tag) => Write("Trace", message, tag);
public void LogDebug(string message, string? tag) => Write("Debug", message, tag);
public void LogInfo(string message, string? tag) => Write("Info", message, tag);
public void LogWarning(string message, string? tag) => Write("Warning", message, tag);
public void LogError(string message, string? tag) => Write("Error", message, tag);
public void LogCritical(string message, string? tag) => Write("Critical", message, tag);
private static void Write(string level, string message, string? tag) =>
Console.WriteLine($"[{level}] {tag ?? "AdMobWrapper"}: {message}");
}Pass the logger to the manager and wrappers:
IAppleLogger logger = new ConsoleAppleLogger();
AdMobManager manager = new(logger);
InterstitialAdWrapper interstitial = new(logger);On Windows and Mac Catalyst, the MAUI consent placeholder:
- writes one warning when the singleton service is constructed;
- writes a debug message for each skipped consent operation;
- reports the platform name;
- returns neutral results without throwing.
This makes it possible to distinguish a real UMP implementation from the
desktop placeholder using both IsSupported and logs.
When investigating a failure, record:
- platform and OS version;
- wrapper/NuGet version;
- ad format and test ad-unit ID;
- consent status and privacy-options requirement;
- native error code and message;
- whether initialization completed;
- whether another load was already active;
- the native tag and log level.
Do not log production consent test-device identifiers or other user-sensitive data.