This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Add sensible defaults to templates that use logging

Fixes #286
  • Loading branch information...
phenning committed Oct 30, 2015
1 parent 3e0d112 commit e6d34253635d243e1d639d51b98ec038c00f1998
Showing with 103 additions and 30 deletions.
  1. +2 −3 src/BaseTemplates/StarterWeb/Startup.cs
  2. +10 −1 src/BaseTemplates/StarterWeb/appsettings.json
  3. +1 −0 src/BaseTemplates/StarterWeb/project.json
  4. +1 −0 src/BaseTemplates/WebAPI.vstemplate
  5. +7 −2 src/BaseTemplates/WebAPI/Startup.cs
  6. +10 −0 src/BaseTemplates/WebAPI/appsettings.json
  7. +2 −0 src/BaseTemplates/WebAPI/project.json
  8. +2 −3 src/Rules/StarterWeb/AI/IndividualAuth/Startup.cs
  9. +8 −0 src/Rules/StarterWeb/AI/IndividualAuth/appsettings.json
  10. +1 −0 src/Rules/StarterWeb/AI/IndividualAuth/project.json
  11. +2 −3 src/Rules/StarterWeb/AI/NoAuth/Startup.cs
  12. +8 −0 src/Rules/StarterWeb/AI/NoAuth/appsettings.json
  13. +1 −0 src/Rules/StarterWeb/AI/NoAuth/project.json
  14. +2 −3 src/Rules/StarterWeb/AI/OrganizationalAuth/Multiple/Startup.cs
  15. +8 −0 src/Rules/StarterWeb/AI/OrganizationalAuth/Multiple/appsettings.json
  16. +2 −3 src/Rules/StarterWeb/AI/OrganizationalAuth/Single/Startup.cs
  17. +8 −0 src/Rules/StarterWeb/AI/OrganizationalAuth/Single/appsettings.json
  18. +1 −0 src/Rules/StarterWeb/AI/OrganizationalAuth/Single/project.json
  19. +2 −3 src/Rules/StarterWeb/IndividualAuth/Startup.cs
  20. +8 −0 src/Rules/StarterWeb/IndividualAuth/appsettings.json
  21. +1 −0 src/Rules/StarterWeb/IndividualAuth/project.json
  22. +1 −0 src/Rules/StarterWeb/OrganizationalAuth/Common/project.json
  23. +2 −3 src/Rules/StarterWeb/OrganizationalAuth/Multiple/Startup.cs
  24. +2 −3 src/Rules/StarterWeb/OrganizationalAuth/Single/Startup.cs
  25. +2 −3 src/Rules/WebAPI/AI/NoAuth/Startup.cs
  26. +8 −0 src/Rules/WebAPI/AI/NoAuth/appsettings.json
  27. +1 −0 src/Rules/WebAPI/AI/NoAuth/project.json
@@ -18,7 +18,7 @@ public Startup(IHostingEnvironment env)
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables();
Configuration = builder.Build();
Configuration = builder.Build().ReloadOnChanged("appsettings.json");
}
public IConfigurationRoot Configuration { get; set; }
@@ -37,8 +37,7 @@ public void ConfigureServices(IServiceCollection services)
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
// Configure the HTTP request pipeline.
@@ -1 +1,10 @@
{}
{
"Logging": {
"IncludeScopes": false,
"Switches": {
"Default": "Verbose",
"System": "Information",
"Microsoft": "Information"
}
}
}
@@ -12,6 +12,7 @@
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-*",
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-*",
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
"Microsoft.Extensions.Logging": "1.0.0-*",
"Microsoft.Extensions.Logging.Console": "1.0.0-*",
@@ -18,6 +18,7 @@
</TemplateData>
<TemplateContent>
<Project File="WebAPI.xproj" ReplaceParameters="true">
<ProjectItem ReplaceParameters="true" TargetFileName="appsettings.json">appsettings.json</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="project.json">project.json</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Project_Readme.html" OpenInWebBrowser="true">Project_Readme.html</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Startup.cs">Startup.cs</ProjectItem>
@@ -4,6 +4,7 @@
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@@ -13,6 +14,11 @@ public class Startup
{
public Startup(IHostingEnvironment env)
{
// Setup configuration sources.
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables();
Configuration = builder.Build().ReloadOnChanged("appsettings.json");
}
// This method gets called by a runtime.
@@ -28,8 +34,7 @@ public void ConfigureServices(IServiceCollection services)
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
// Adds middleware to the request pipeline for forwarding Windows Authentication, request scheme, remote IPs, etc to the IIS HttpPlatformHandler..
@@ -0,0 +1,10 @@
{
"Logging": {
"IncludeScopes": false,
"Switches": {
"Default": "Verbose",
"System": "Information",
"Microsoft": "Information"
}
}
}
@@ -9,6 +9,8 @@
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-*",
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
"Microsoft.Extensions.Logging": "1.0.0-*",
"Microsoft.Extensions.Logging.Console": "1.0.0-*",
"Microsoft.Extensions.Logging.Debug": "1.0.0-*"
@@ -40,7 +40,7 @@ public Startup(IHostingEnvironment env)
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
Configuration = builder.Build().ReloadOnChanged("appsettings.json");
}
public IConfigurationRoot Configuration { get; set; }
@@ -77,8 +77,7 @@ public void ConfigureServices(IServiceCollection services)
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
// Configure the HTTP request pipeline.
@@ -6,5 +6,13 @@
"DefaultConnection": {
"ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=aspnet5-$safeprojectname$-$guid2$;Trusted_Connection=True;MultipleActiveResultSets=true"
}
},
"Logging": {
"IncludeScopes": false,
"Switches": {
"Default": "Verbose",
"System": "Information",
"Microsoft": "Information"
}
}
}
@@ -25,6 +25,7 @@
"Microsoft.AspNet.Tooling.Razor": "1.0.0-*",
"Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-*",
"Microsoft.Extensions.Configuration.Abstractions": "1.0.0-*",
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-*",
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*",
"Microsoft.Extensions.Logging": "1.0.0-*",
@@ -24,7 +24,7 @@ public Startup(IHostingEnvironment env)
// This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
builder.AddApplicationInsightsSettings(developerMode: true);
}
Configuration = builder.Build();
Configuration = builder.Build().ReloadOnChanged("appsettings.json");
}
public IConfigurationRoot Configuration { get; set; }
@@ -46,8 +46,7 @@ public void ConfigureServices(IServiceCollection services)
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
// Configure the HTTP request pipeline.
@@ -1,5 +1,13 @@
{
"ApplicationInsights": {
"InstrumentationKey": ""
},
"Logging": {
"IncludeScopes": false,
"Switches": {
"Default": "Verbose",
"System": "Information",
"Microsoft": "Information"
}
}
}
@@ -14,6 +14,7 @@
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-*",
"Microsoft.Extensions.Configuration": "1.0.0-*",
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-*",
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
"Microsoft.Extensions.Logging": "1.0.0-*",
"Microsoft.Extensions.Logging.Console": "1.0.0-*",
@@ -33,7 +33,7 @@ public Startup(IHostingEnvironment env)
builder.AddApplicationInsightsSettings(developerMode: true);
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
Configuration = builder.Build().ReloadOnChanged("appsettings.json");
}
public IConfigurationRoot Configuration { get; set; }
@@ -51,8 +51,7 @@ public void ConfigureServices(IServiceCollection services)
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
// Configure the HTTP request pipeline.
@@ -1,5 +1,13 @@
{
"ApplicationInsights": {
"InstrumentationKey": ""
},
"Logging": {
"IncludeScopes": true,
"Switches": {
"Default": "Verbose",
"System": "Information",
"Microsoft": "Information"
}
}
}
@@ -32,7 +32,7 @@ public Startup(IHostingEnvironment env)
builder.AddApplicationInsightsSettings(developerMode: true);
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
Configuration = builder.Build().ReloadOnChanged("appsettings.json");
}
public IConfigurationRoot Configuration { get; set; }
@@ -50,8 +50,7 @@ public void ConfigureServices(IServiceCollection services)
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
// Configure the HTTP request pipeline.
@@ -1,5 +1,13 @@
{
"ApplicationInsights": {
"InstrumentationKey": ""
},
"Logging": {
"IncludeScopes": true,
"Switches": {
"Default": "Verbose",
"System": "Information",
"Microsoft": "Information"
}
}
}
@@ -17,6 +17,7 @@
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-*",
"Microsoft.Dnx.Runtime": "1.0.0-*",
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-*",
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*",
"Microsoft.Extensions.Logging": "1.0.0-*",
@@ -36,7 +36,7 @@ public Startup(IHostingEnvironment env)
builder.AddUserSecrets();
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
Configuration = builder.Build().ReloadOnChanged("appsettings.json");
}
public IConfigurationRoot Configuration { get; set; }
@@ -70,8 +70,7 @@ public void ConfigureServices(IServiceCollection services)
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
// Configure the HTTP request pipeline.
@@ -3,5 +3,13 @@
"DefaultConnection": {
"ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=aspnet5-$safeprojectname$-$guid2$;Trusted_Connection=True;MultipleActiveResultSets=true"
}
},
"Logging": {
"IncludeScopes": false,
"Switches": {
"Default": "Verbose",
"System": "Information",
"Microsoft": "Information"
}
}
}
@@ -24,6 +24,7 @@
"Microsoft.AspNet.Tooling.Razor": "1.0.0-*",
"Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-*",
"Microsoft.Extensions.Configuration.Abstractions": "1.0.0-*",
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-*",
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*",
"Microsoft.Extensions.Logging": "1.0.0-*",
@@ -16,6 +16,7 @@
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-*",
"Microsoft.Dnx.Runtime": "1.0.0-*",
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-*",
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*",
"Microsoft.Extensions.Logging": "1.0.0-*",
@@ -30,7 +30,7 @@ public Startup(IHostingEnvironment env)
builder.AddUserSecrets();
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
Configuration = builder.Build().ReloadOnChanged("appsettings.json");
}
public IConfigurationRoot Configuration { get; set; }
@@ -45,8 +45,7 @@ public void ConfigureServices(IServiceCollection services)
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
// Configure the HTTP request pipeline.
@@ -29,7 +29,7 @@ public Startup(IHostingEnvironment env)
builder.AddUserSecrets();
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
Configuration = builder.Build().ReloadOnChanged("appsettings.json");
}
public IConfigurationRoot Configuration { get; set; }
@@ -44,8 +44,7 @@ public void ConfigureServices(IServiceCollection services)
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
// Configure the HTTP request pipeline.
@@ -25,7 +25,7 @@ public Startup(IHostingEnvironment env)
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
Configuration = builder.Build().ReloadOnChanged("appsettings.json");
}
public IConfigurationRoot Configuration { get; set; }
@@ -46,8 +46,7 @@ public void ConfigureServices(IServiceCollection services)
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
// Adds middleware to the request pipeline for forwarding Windows Authentication, request scheme, remote IPs, etc to the IIS HttpPlatformHandler..
@@ -1,5 +1,13 @@
{
"ApplicationInsights": {
"InstrumentationKey": ""
},
"Logging": {
"IncludeScopes": false,
"Switches": {
"Default": "Verbose",
"System": "Information",
"Microsoft": "Information"
}
}
}
@@ -10,6 +10,7 @@
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-*",
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
"Microsoft.Extensions.Logging": "1.0.0-*",
"Microsoft.Extensions.Logging.Console": "1.0.0-*",

0 comments on commit e6d3425

Please sign in to comment.