Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] No logs when using UseLogging #2693

Open
1 of 2 tasks
dr1rrb opened this issue Feb 12, 2025 · 0 comments
Open
1 of 2 tasks

[Android] No logs when using UseLogging #2693

dr1rrb opened this issue Feb 12, 2025 · 0 comments
Labels
area/logging kind/bug Something isn't working

Comments

@dr1rrb
Copy link
Member

dr1rrb commented Feb 12, 2025

Current behavior

When configuring log using the UseLogging, nothing appears in log on Android

Expected behavior

Logs

How to reproduce it (as minimally and precisely as possible)

  1. Create a an app using the ""recommended"" settings
  2. Configure log to trace (e.g. configure HR to trace)
  3. Launch the app on Android
  4. Observe nothing is outputted in logs from uno

Environment

Package Version(s): 5.7

  • [?] iOS
  • [?] macOS (AppKit)
  • [?] Mac Catalyst
  • Android
  • [?] WebAssembly
  • [?] Windows
  • [?] Skia (WPF)
  • [?] Skia (GTK on Linux/macOS/Windows)
  • [?] Skia (Linux Framebuffer)
  • Build tasks

Workaround

Configure logging using the code from a blank app:

static Application()
{
	App.InitializeLogging();
}
/// <summary>
/// Configures global Uno Platform logging
/// </summary>
public static void InitializeLogging()
{
#if DEBUG
	// Logging is disabled by default for release builds, as it incurs a significant
	// initialization cost from Microsoft.Extensions.Logging setup. If startup performance
	// is a concern for your application, keep this disabled. If you're running on the web or
	// desktop targets, you can use URL or command line parameters to enable it.
	//
	// For more performance documentation: https://platform.uno/docs/articles/Uno-UI-Performance.html

	var factory = LoggerFactory.Create(builder =>
	{
#if __WASM__
		builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider());
#elif __IOS__ || __MACCATALYST__
		builder.AddProvider(new global::Uno.Extensions.Logging.OSLogLoggerProvider());
#else
		builder.AddConsole();
#endif

		// Exclude logs below this level
		builder.SetMinimumLevel(LogLevel.Information);

		// Default filters for Uno Platform namespaces
		builder.AddFilter("Uno", LogLevel.Warning);
		builder.AddFilter("Windows", LogLevel.Warning);
		builder.AddFilter("Microsoft", LogLevel.Warning);

		// Generic Xaml events
		// builder.AddFilter("Microsoft.UI.Xaml", LogLevel.Debug );
		// builder.AddFilter("Microsoft.UI.Xaml.VisualStateGroup", LogLevel.Debug );
		// builder.AddFilter("Microsoft.UI.Xaml.StateTriggerBase", LogLevel.Debug );
		// builder.AddFilter("Microsoft.UI.Xaml.UIElement", LogLevel.Debug );
		// builder.AddFilter("Microsoft.UI.Xaml.FrameworkElement", LogLevel.Trace );

		// Layouter specific messages
		// builder.AddFilter("Microsoft.UI.Xaml.Controls", LogLevel.Debug );
		// builder.AddFilter("Microsoft.UI.Xaml.Controls.Layouter", LogLevel.Debug );
		// builder.AddFilter("Microsoft.UI.Xaml.Controls.Panel", LogLevel.Debug );

		// builder.AddFilter("Windows.Storage", LogLevel.Debug );

		// Binding related messages
		// builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug );
		// builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug );

		// Binder memory references tracking
		// builder.AddFilter("Uno.UI.DataBinding.BinderReferenceHolder", LogLevel.Debug );

		// DevServer and HotReload related
		// builder.AddFilter("Uno.UI.RemoteControl", LogLevel.Information);

		// Debug JS interop
		// builder.AddFilter("Uno.Foundation.WebAssemblyRuntime", LogLevel.Debug );
	});

	global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory = factory;

#if HAS_UNO
	global::Uno.UI.Adapter.Microsoft.Extensions.Logging.LoggingAdapter.Initialize();
#endif
#endif
}
@dr1rrb dr1rrb added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification. labels Feb 12, 2025
@kazo0 kazo0 changed the title No logs when using UseLogging [Android] No logs when using UseLogging Feb 18, 2025
@kazo0 kazo0 added area/logging and removed triage/untriaged Indicates an issue requires triaging or verification. labels Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/logging kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants