2
1

More than 3 years have passed since last update.

Azure App Service でエラーを BLOB にロギングする

Last updated at Posted at 2020-05-11

Azure App Service でエラーを BLOB にロギングする

# 以下の記事が書かれた時の版数は .NET Core 3.1 (3.1.201), ASP.NET Core 3.1 (3.1.3), Microsoft.Extensions.Logging.AzureAppServices 3.1.3 となります.

最低限エラーが残っていないと困るので…….

Azure Portal にログインして、該当の Azure App Service にアクセス. 左メニューの 監視 / App Service ログ から「アプリケーション ログ (Blob)」を設定.

nuget で Microsoft.Extensions.Logging.AzureAppServices をインストール. あとは Program.cs に AddAzureWebAppDiagnostics を追加すれば、Startup.cs の UseExceptionHandler の効果で、最低限 unhandled exception がロギングされるようになる.

WebApplication1/Program.cs
                 .ConfigureWebHostDefaults(webBuilder =>
                 {
                     webBuilder.UseStartup<Startup>();
-                });
+                })
+                .ConfigureLogging(logging => logging.AddAzureWebAppDiagnostics());
     }
 }
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1