VS2017 15.3.0プレビュー4と.NET Core 2.0プレビュー2をインストールし、既定のWeb MVCアプリケーションを作成しました。私は新しいロギング機能がどのように機能するのか興味がありますが、デバッグ出力ウィンドウを表示するときにappsettings.Development.jsonで定義されたロギング値をVSに使用させることはできません。ASP NETコア2.0 appsettings.Development.jsonがロギング設定で動作しない
私の理解では、appsettings.Development.jsonファイルはappsettings.jsonよりも優先されますが、後者のファイルの値だけがデバッグウィンドウに影響します。これは正しいですか?もしそうなら、追加のセットアップが必要ですか?
ここ値と結果は...
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Information",
"System": "Information",
"Microsoft": "Information"
}
}
}
空の出力デバッグ(ノート
appsettings.json
{
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "None"
}
},
"Console": {
"LogLevel": {
"Default": "Information"
}
}
}
}
appsettings.Development.json Application Insightsテレメトリ記録のみが表示されます働いていないVE)まだを取り除くためにどのように
しかし私はappsettings.jsonでログレベルを変更した場合、私は期待通りの出力を参照してください...
appsettings.json
{
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Information"
}
},
"Console": {
"LogLevel": {
"Default": "Information"
}
}
}
}
新しい出力(Microsoft.AspNetCore.Hosting.Internal.WebHostことに注意してください:情報が含まれるようになりました)デバッグ
マイStartup.csファイルには、以下のとおり、新しいプロジェクトで作成したデフォルトASP.NETコア2.0テンプレートです。また、appsettings.jsonファイルとappsettings.Development.jsonファイルは、新しいプロジェクトテンプレートによって自動的に作成されました。
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
// Add application services.
services.AddTransient<IEmailSender, AuthMessageSender>();
services.AddTransient<ISmsSender, AuthMessageSender>();
services.AddMvc();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseAuthentication();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
ここでは、ASP.NET Core 2.0 MVCテンプレートのデフォルトのProgram.csもあります。
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
SOLUTIONデフォルトで
DEV "appsettings.Development.json" の設定ファイルは、優先順位を取るため、メインの "appsettings.json" 設定ファイルのdevの設定後にロードされます。しかし、デフォルトのappsettings.Development.jsonファイルには、奇妙に思われるログレベル設定のデバッグノードは含まれていません。ここに作業devの設定です。あなたのappsettings.json
から
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "None",
"System": "None",
"Microsoft": "None"
},
"Debug": {
"LogLevel": {
"Default": "Information",
"System": "None",
"Microsoft": "Information"
}
}
}
}
あなたStartup.csは見えない何か好き? – Dealdiane
@Dealdianeスタートアップファイルを追加しました。すべてが新しいASP.NET Core 2.0 MVCテンプレートからの在庫です。私は、json設定ファイル内のログレベルでしか遊んでいません。 – OjM
Program.csも投稿できますか? – Dealdiane