Merge pull request #22 from NicolasConstant/topic_logs
add logs support
This commit is contained in:
commit
f1dd03cab3
4 changed files with 20 additions and 2 deletions
8
src/BirdsiteLive.Common/Settings/LogsSettings.cs
Normal file
8
src/BirdsiteLive.Common/Settings/LogsSettings.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace BirdsiteLive.Common.Settings
|
||||
{
|
||||
public class LogsSettings
|
||||
{
|
||||
public string Type { get; set; }
|
||||
public string InstrumentationKey { get; set; }
|
||||
}
|
||||
}
|
|
@ -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>
|
||||
|
|
|
@ -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}";
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
{
|
||||
"Logging": {
|
||||
"Type": "none",
|
||||
"InstrumentationKey": "key",
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
|
|
Reference in a new issue