Merge pull request #22 from NicolasConstant/topic_logs

add logs support
This commit is contained in:
Nicolas Constant 2020-12-30 09:53:53 +01:00 committed by GitHub
commit f1dd03cab3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 2 deletions

View file

@ -0,0 +1,8 @@
namespace BirdsiteLive.Common.Settings
{
public class LogsSettings
{
public string Type { get; set; }
public string InstrumentationKey { get; set; }
}
}

View file

@ -9,6 +9,7 @@
<ItemGroup>
<PackageReference Include="Lamar.Microsoft.DependencyInjection" Version="4.1.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />
</ItemGroup>

View file

@ -38,8 +38,12 @@ namespace BirdsiteLive
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
//services.Configure<InstanceSettings>(Configuration.GetSection("Instance"));
//services.Configure<TwitterSettings>(Configuration.GetSection("Twitter"));
var logsSettings = Configuration.GetSection("Logging").Get<LogsSettings>();
if(string.Equals("insights", logsSettings.Type, StringComparison.OrdinalIgnoreCase))
{
var key = logsSettings.InstrumentationKey;
services.AddApplicationInsightsTelemetry(key);
}
services.AddControllersWithViews();
}
@ -55,6 +59,9 @@ namespace BirdsiteLive
var dbSettings = Configuration.GetSection("Db").Get<DbSettings>();
services.For<DbSettings>().Use(x => dbSettings);
var logsSettings = Configuration.GetSection("Logging").Get<LogsSettings>();
services.For<LogsSettings>().Use(x => logsSettings);
if (string.Equals(dbSettings.Type, DbTypes.Postgres, StringComparison.OrdinalIgnoreCase))
{
var connString = $"Host={dbSettings.Host};Username={dbSettings.User};Password={dbSettings.Password};Database={dbSettings.Name}";

View file

@ -1,5 +1,7 @@
{
"Logging": {
"Type": "none",
"InstrumentationKey": "key",
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",