Skip to content

Commit

Permalink
Merge pull request #74 from 7474/configure-log
Browse files Browse the repository at this point in the history
Configure log
  • Loading branch information
7474 authored Oct 3, 2020
2 parents 11e272e + 4b3b698 commit 9335d9a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
26 changes: 25 additions & 1 deletion RealDiceBot/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// Generated with Bot Builder V4 SDK Template for Visual Studio EchoBot v4.10.2

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.ApplicationInsights;
using Microsoft.Extensions.Logging.AzureAppServices;

namespace RealDiceBot
{
Expand All @@ -17,6 +21,26 @@ public static void Main(string[] args)

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, builder) =>
{
// https://docs.microsoft.com/ja-jp/aspnet/core/fundamentals/logging/?view=aspnetcore-3.1
builder.AddAzureWebAppDiagnostics();
// https://docs.microsoft.com/ja-jp/azure/azure-monitor/app/ilogger#aspnet-core-applications
builder.AddApplicationInsights(hostingContext.Configuration["APPINSIGHTS_INSTRUMENTATIONKEY"]);
builder.AddFilter<ApplicationInsightsLoggerProvider>("", LogLevel.Warning);
})
.ConfigureServices(serviceCollection => serviceCollection
.Configure<AzureFileLoggerOptions>(options =>
{
options.FileName = "azure-diagnostics-";
options.FileSizeLimit = 50 * 1024;
options.RetainedFileCountLimit = 5;
})
.Configure<AzureBlobLoggerOptions>(options =>
{
options.BlobName = "log.txt";
}))
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
Expand Down
3 changes: 2 additions & 1 deletion RealDiceBot/RealDiceBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@

<ItemGroup>
<PackageReference Include="Azure.Storage.Queues" Version="12.4.2" />
<PackageReference Include="BotFrameworkTwitterAdapter" Version="0.1.4" />
<PackageReference Include="BotFrameworkTwitterAdapter" Version="0.1.6" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.15.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.8" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.10.3" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.10.3" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="3.1.8" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 9335d9a

Please sign in to comment.