Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
294 additions
and
175 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
sample7/SampleConsoleAppDI7/Properties/launchSettings.json
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
samples/SampleWebApi5/Controllers/WeatherForecastController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace SampleWebApi.Controllers; | ||
|
||
[ApiController] | ||
[Route("[controller]")] | ||
public class WeatherForecastController : ControllerBase | ||
{ | ||
private static readonly string[] Summaries = new[] | ||
{ | ||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" | ||
}; | ||
|
||
private readonly ILogger<WeatherForecastController> _logger; | ||
|
||
public WeatherForecastController(ILogger<WeatherForecastController> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
[HttpGet] | ||
public IEnumerable<WeatherForecast> Get() | ||
{ | ||
var rng = new Random(); | ||
var result = Enumerable.Range(1, 5).Select(index => new WeatherForecast | ||
{ | ||
Date = DateTime.Now.AddDays(index), | ||
TemperatureC = rng.Next(-20, 55), | ||
Summary = Summaries[rng.Next(Summaries.Length)] | ||
}) | ||
.ToArray(); | ||
|
||
_logger.LogInformation("Returns {name}", result.Select(w => w.Summary)); | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using NetLah.Diagnostics; | ||
using NetLah.Extensions.Logging; | ||
|
||
namespace SampleWebApi; | ||
|
||
internal class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
ApplicationInfo.Initialize(null); | ||
AppLog.InitLogger(); | ||
try | ||
{ | ||
AppLog.Logger.LogInformation("Application configure..."); // write log console only | ||
|
||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
AppLog.Logger.LogCritical(ex, "Host terminated unexpectedly"); | ||
} | ||
finally | ||
{ | ||
Serilog.Log.CloseAndFlush(); | ||
} | ||
} | ||
|
||
public static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.UseSerilog2(logger => | ||
{ | ||
if (ApplicationInfo.Instance is { } appInfo) | ||
{ | ||
logger.LogInformation("Application initializing... AppTitle:{appTitle}; Version:{appVersion} BuildTime:{appBuildTime}; Framework:{frameworkName}", | ||
appInfo.Title, appInfo.InformationalVersion, appInfo.BuildTimestampLocal, appInfo.FrameworkName); | ||
} | ||
}) // write log to sinks | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:38544", | ||
"sslPort": 44357 | ||
} | ||
}, | ||
"profiles": { | ||
"SampleWebApi5": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": false, | ||
"launchUrl": "swagger", | ||
"applicationUrl": "https://localhost:5001;http://localhost:5000", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"launchUrl": "swagger", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net8.0;net7.0;net6.0;net5.0;netcoreapp3.1</TargetFrameworks> | ||
<IsPackable>false</IsPackable> | ||
<UserSecretsId>netlah-serilog-31ba4057fe93</UserSecretsId> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Remove="Logs\**" /> | ||
<Content Remove="Logs\**" /> | ||
<EmbeddedResource Remove="Logs\**" /> | ||
<None Remove="Logs\**" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.ApiDescription.Server" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" /> | ||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" /> | ||
<PackageReference Include="NetLah.Abstractions" /> | ||
<PackageReference Include="Serilog" /> | ||
<PackageReference Include="Serilog.AspNetCore" /> | ||
<PackageReference Include="Serilog.Enrichers.Thread" /> | ||
<PackageReference Include="Serilog.Extensions.Hosting" /> | ||
<PackageReference Include="Serilog.Extensions.Logging" /> | ||
<PackageReference Include="Serilog.Settings.Configuration" /> | ||
<PackageReference Include="Serilog.Sinks.Console" /> | ||
<PackageReference Include="Serilog.Sinks.Debug" /> | ||
<PackageReference Include="Serilog.Sinks.File" /> | ||
<PackageReference Include="Serilog.Sinks.Seq" /> | ||
<PackageReference Include="Swashbuckle.AspNetCore" /> | ||
<PackageReference Condition="'$(NET_5_0_LESS)' == true" Include="System.Net.Http.Json" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\NetLah.Extensions.Logging.Serilog.AspNetCore\NetLah.Extensions.Logging.Serilog.AspNetCore.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.