41 lines
1.6 KiB
C#
41 lines
1.6 KiB
C#
using Microsoft.AspNetCore.Components.Web;
|
|
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
|
using MudBlazor.Services;
|
|
using Serilog;
|
|
using Serilog.Core;
|
|
|
|
namespace Expose.MyIT.Client;
|
|
|
|
internal class Program
|
|
{
|
|
private static async Task Main(string[] args)
|
|
{
|
|
WebAssemblyHostBuilder builder = WebAssemblyHostBuilder.CreateDefault(args);
|
|
LoggingLevelSwitch levelSwitch = new();
|
|
LoggerConfiguration loggerConfiguration = new();
|
|
_ = loggerConfiguration.WriteTo.BrowserConsole();
|
|
_ = loggerConfiguration.MinimumLevel.ControlledBy(levelSwitch);
|
|
// string baseAddress = builder.HostEnvironment.BaseAddress;
|
|
string baseAddress = "https://localhost:7130/";
|
|
_ = loggerConfiguration.Enrich.WithProperty("InstanceId", Guid.NewGuid().ToString("n"));
|
|
_ = loggerConfiguration.WriteTo.BrowserHttp($"{baseAddress}ingest", controlLevelSwitch: levelSwitch);
|
|
Log.Logger = loggerConfiguration.CreateLogger();
|
|
Serilog.ILogger log = Log.ForContext<Program>();
|
|
try
|
|
{
|
|
builder.RootComponents.Add<App>("#app");
|
|
builder.RootComponents.Add<HeadOutlet>("head::after");
|
|
|
|
_ = builder.Services.AddScoped(serviceProvider => new HttpClient { BaseAddress = new Uri(baseAddress) });
|
|
_ = builder.Services.AddMudServices();
|
|
|
|
log.Information("Building Web Host");
|
|
await builder.Build().RunAsync();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Fatal(ex, "An exception occurred while creating the WASM host");
|
|
throw;
|
|
}
|
|
}
|
|
} |