File tree Expand file tree Collapse file tree 5 files changed +93
-0
lines changed Expand file tree Collapse file tree 5 files changed +93
-0
lines changed Original file line number Diff line number Diff line change @@ -199,3 +199,5 @@ project.lock.json
199
199
200
200
# JetBrains Rider
201
201
.idea
202
+
203
+ .vscode
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . IO ;
4
+ using System . Linq ;
5
+ using System . Threading . Tasks ;
6
+ using Microsoft . AspNetCore ;
7
+ using Microsoft . AspNetCore . Hosting ;
8
+ using Microsoft . Extensions . Configuration ;
9
+ using Microsoft . Extensions . Logging ;
10
+
11
+ using Serilog ;
12
+
13
+ namespace SimpleWebSample
14
+ {
15
+ public class Program
16
+ {
17
+ public static void Main ( string [ ] args )
18
+ {
19
+ Log . Logger = new LoggerConfiguration ( )
20
+ . Enrich . FromLogContext ( )
21
+ . WriteTo . LiterateConsole ( )
22
+ . CreateLogger ( ) ;
23
+
24
+ Log . Information ( "Getting the motors running..." ) ;
25
+
26
+ BuildWebHost ( args ) . Run ( ) ;
27
+ }
28
+
29
+ public static IWebHost BuildWebHost ( string [ ] args ) =>
30
+ WebHost . CreateDefaultBuilder ( args )
31
+ . UseStartup < Startup > ( )
32
+ . ConfigureLogging ( log =>
33
+ {
34
+ log . SetMinimumLevel ( LogLevel . Information ) ;
35
+ log . AddSerilog ( logger : Log . Logger , dispose : true ) ;
36
+ } )
37
+ . Build ( ) ;
38
+ }
39
+ }
Original file line number Diff line number Diff line change
1
+ ```
2
+ dotnet new web
3
+ dotnet add package Serilog.Extensions.Logging
4
+ dotnet add package Serilog.Sinks.Literate
5
+ ```
Original file line number Diff line number Diff line change
1
+ <Project Sdk =" Microsoft.NET.Sdk.Web" >
2
+ <PropertyGroup >
3
+ <TargetFramework >netcoreapp2.0</TargetFramework >
4
+ </PropertyGroup >
5
+ <ItemGroup >
6
+ <Folder Include =" wwwroot\" />
7
+ </ItemGroup >
8
+ <ItemGroup >
9
+ <PackageReference Include =" Microsoft.AspNetCore.All" Version =" 2.0.0" />
10
+ <PackageReference Include =" Serilog.Extensions.Logging" Version =" 2.0.0" />
11
+ <PackageReference Include =" Serilog.Sinks.Literate" Version =" 3.0.0" />
12
+ </ItemGroup >
13
+ </Project >
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Linq ;
4
+ using System . Threading . Tasks ;
5
+ using Microsoft . AspNetCore . Builder ;
6
+ using Microsoft . AspNetCore . Hosting ;
7
+ using Microsoft . AspNetCore . Http ;
8
+ using Microsoft . Extensions . DependencyInjection ;
9
+
10
+ namespace SimpleWebSample
11
+ {
12
+ public class Startup
13
+ {
14
+ // This method gets called by the runtime. Use this method to add services to the container.
15
+ // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
16
+ public void ConfigureServices ( IServiceCollection services )
17
+ {
18
+ }
19
+
20
+ // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
21
+ public void Configure ( IApplicationBuilder app , IHostingEnvironment env )
22
+ {
23
+ if ( env . IsDevelopment ( ) )
24
+ {
25
+ app . UseDeveloperExceptionPage ( ) ;
26
+ }
27
+
28
+ app . Run ( async ( context ) =>
29
+ {
30
+ await context . Response . WriteAsync ( "Hello World!" ) ;
31
+ } ) ;
32
+ }
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments