Skip to content

Commit 9fc8159

Browse files
committed
Make the dev-server log less (#18971)
* Make the dev-server log less * Allow loading a user configured settings file
1 parent 43b3a5e commit 9fc8159

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/Components/WebAssembly/DevServer/src/Microsoft.AspNetCore.Components.WebAssembly.DevServer.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
<ItemGroup>
3333
<NuspecProperty Include="publishDir=$(PublishDir)" />
3434
<NuspecProperty Include="componentsrootdir=..\..\..\" />
35-
<NuspecProperty Include="blazorversion=$(PackageVersion)" />
3635
</ItemGroup>
3736

3837
</Project>

src/Components/WebAssembly/DevServer/src/Server/Program.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
using System;
54
using System.Collections.Generic;
6-
using System.Diagnostics;
75
using System.IO;
86
using System.Linq;
9-
using System.Threading;
107
using Microsoft.AspNetCore.Hosting;
118
using Microsoft.Extensions.Configuration;
129
using Microsoft.Extensions.Hosting;
10+
using Microsoft.Extensions.Logging;
1311

1412
namespace Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server
1513
{
@@ -27,17 +25,21 @@ public class Program
2725
/// </summary>
2826
public static IHost BuildWebHost(string[] args) =>
2927
Host.CreateDefaultBuilder(args)
30-
.ConfigureHostConfiguration(cb => {
28+
.ConfigureHostConfiguration(config =>
29+
{
3130
var applicationPath = args.SkipWhile(a => a != "--applicationpath").Skip(1).FirstOrDefault();
32-
var name = Path.ChangeExtension(applicationPath,".StaticWebAssets.xml");
31+
var applicationDirectory = Path.GetDirectoryName(applicationPath);
32+
var name = Path.ChangeExtension(applicationPath, ".StaticWebAssets.xml");
3333

34-
if (name != null)
34+
var inMemoryConfiguration = new Dictionary<string, string>
3535
{
36-
cb.AddInMemoryCollection(new Dictionary<string, string>
37-
{
38-
[WebHostDefaults.StaticWebAssetsKey] = name
39-
});
40-
}
36+
["Logging:LogLevel:Microsoft"] = "Warning",
37+
["Logging:LogLevel:Microsoft.Hosting.Lifetime"] = "Information",
38+
[WebHostDefaults.StaticWebAssetsKey] = name,
39+
};
40+
41+
config.AddInMemoryCollection(inMemoryConfiguration);
42+
config.AddJsonFile(Path.Combine(applicationDirectory, "blazor-devserversettings.json"), optional: true, reloadOnChange: true);
4143
})
4244
.ConfigureWebHostDefaults(webBuilder =>
4345
{

0 commit comments

Comments
 (0)