通过 How to add a namespace using the new dotnet 6 template? 的回答知道了答案:无法指定 namespace
Adding namespaces outside top-level statements is not supported.
Top-level statements are implicitly in the global namespace.
Top-level statements are specifically not allowed in combination with file-scoped namespace declarations (introduced in C# 10 supported by .NET 6).
接着发现 LogLevel 是根据程序集的名称而不是 namespace
<AssemblyName>Cnblogs.Zzk.Api</AssemblyName>
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Cnblogs.Zzk.Api": "Warning"
}
}
}
尝试了在 Program.cs 中添加 partial class
,也无济于事
namespace Cnblogs.Zzk.Api
{
public partial class Program
{ }
}