Skip to content

Commit 26137e2

Browse files
committed
perf: Disable logging in release builds
1 parent 34f77fc commit 26137e2

File tree

1 file changed

+12
-3
lines changed
  • src/SolutionTemplate/UnoSolutionTemplate.net6/Shared

1 file changed

+12
-3
lines changed

src/SolutionTemplate/UnoSolutionTemplate.net6/Shared/App.xaml.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,15 @@ private void OnSuspending(object sender, SuspendingEventArgs e)
116116
/// </summary>
117117
private static void InitializeLogging()
118118
{
119-
var factory = LoggerFactory.Create(builder =>
119+
#if DEBUG
120+
// Logging is disabled by default for release builds, as it incurs a significant
121+
// initialization cost from Microsoft.Extensions.Logging setup. If startup performance
122+
// is a concern for your application, keep this disabled. If you're running on web or
123+
// desktop targets, you can use url or command line parameters to enable it.
124+
//
125+
// For more performance documentation: https://platform.uno/docs/articles/Uno-UI-Performance.html
126+
127+
var factory = LoggerFactory.Create(builder =>
120128
{
121129
#if __WASM__
122130
builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider());
@@ -169,6 +177,7 @@ private static void InitializeLogging()
169177
#if HAS_UNO
170178
global::Uno.UI.Adapter.Microsoft.Extensions.Logging.LoggingAdapter.Initialize();
171179
#endif
172-
}
173-
}
180+
#endif
181+
}
182+
}
174183
}

0 commit comments

Comments
 (0)