コンテナー イメージの既定のコンソール ロガーの書式設定

aspnet コンテナーで構成される既定のコンソール フォーマッタが変更されました。

以前の動作

以前の .NET 6 のサービス リリースでは、Logging__Console__FormatterName 環境変数が Json に設定された aspnet コンテナー イメージが構成されていました。 このため、コンソール出力は次のように書式設定されていました。

{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Now listening on: http://localhost:7000/","State":{"Message":"Now listening on: http://localhost:7000/","address":"http://localhost:7000/","{OriginalFormat}":"Now listening on: {address}"}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Now listening on: http://localhost:7001/","State":{"Message":"Now listening on: http://localhost:7001/","address":"http://localhost:7001/","{OriginalFormat}":"Now listening on: {address}"}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Now listening on: http://localhost:7002/","State":{"Message":"Now listening on: http://localhost:7002/","address":"http://localhost:7002/","{OriginalFormat}":"Now listening on: {address}"}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Application started. Press Ctrl\u002BC to shut down.","State":{"Message":"Application started. Press Ctrl\u002BC to shut down.","{OriginalFormat}":"Application started. Press Ctrl\u002BC to shut down."}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Hosting environment: Development","State":{"Message":"Hosting environment: Development","envName":"Development","{OriginalFormat}":"Hosting environment: {envName}"}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Content root path: C:\\source\\temp\\web50","State":{"Message":"Content root path: C:\\source\\temp\\web50","contentRoot":"C:\\source\\temp\\web50","{OriginalFormat}":"Content root path: {contentRoot}"}}

新しい動作

.NET 6.0.5 以降では、既定で aspnet コンテナー イメージの Logging__Console__FormatterName 環境変数は設定解除されています。 この結果、次のような単純で複数行の、人間が読みやすいコンソール出力が得られます。

warn: Microsoft.AspNetCore.Server.HttpSys.MessagePump[37]
      Overriding address(es) ''. Binding to endpoints added to UrlPrefixes instead.
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://localhost:7000/
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://localhost:7001/
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://localhost:7002/
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\source\temp\web50

導入されたバージョン

.NET 6.0.5 (2022 年 5 月提供)

破壊的変更の種類

この変更はソースの互換性に影響を与える可能性があります。

変更理由

.NET 6 GA リリースで JSON 形式を使う変更が導入されたとき、dotnet/dotnet-docker#2725 で説明されているように、元の単純な書式設定に依存していた多くのシナリオが継続できなくなりました。

引き続き JSON 形式を使いたい場合、Logging__Console__FormatterName 環境変数の値を Json に設定して、使用するようにコンテナーを構成できます。

影響を受ける API

[なし] :

関連項目