Kapsayıcı görüntülerinde varsayılan konsol günlükçü biçimlendirmesi
Kapsayıcılarda aspnet
yapılandırılan varsayılan konsol biçimlendiricisi değişti.
Önceki davranış
.NET 6'nın önceki hizmet sürümlerinde kapsayıcı görüntüleri ortam aspnet
değişkeni olarak ayarlanmış şekilde Json
yapılandırıldıLogging__Console__FormatterName
. Bunun sonucunda konsol çıkışı aşağıdakine benzer şekilde biçimlendirildi:
{"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}"}}
Yeni davranış
.NET 6.0.5'den başlayarak kapsayıcı aspnet
görüntülerinde Logging__Console__FormatterName
ortam değişkeni varsayılan olarak ayarlanmamıştır. Bu, aşağıdakine benzer basit, çok satırlı, insan tarafından okunabilir konsol çıkışına neden olur:
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
Sürüm kullanıma sunulmuştur
.NET 6.0.5 (Mayıs 2022 bakım)
Hataya neden olan değişikliğin türü
Bu değişiklik kaynak uyumluluğunu etkileyebilir.
Değişiklik nedeni
JSON biçimlendirmesini kullanma değişikliği .NET 6 GA sürümünde sunulduğunda, dotnet/dotnet-docker#2725'te açıklandığı gibi özgün, basit biçimlendirmeye dayalı birçok senaryoyu kırdı.
Önerilen eylem
JSON biçimlendirmesini kullanmaya devam etmek istiyorsanız, ortam değişkeni değerini Json
olarak ayarlayarak kapsayıcınızı bunu kullanacak şekilde Logging__Console__FormatterName
yapılandırabilirsiniz.
Etkilenen API’ler
Yok.
Ayrıca bkz.
Geri Bildirim
https://aka.ms/ContentUserFeedback.
Çok yakında: 2024 boyunca, içerik için geri bildirim mekanizması olarak GitHub Sorunları’nı kullanımdan kaldıracak ve yeni bir geri bildirim sistemiyle değiştireceğiz. Daha fazla bilgi için bkz.Gönderin ve geri bildirimi görüntüleyin