-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from datalust/dev
5.2.2 Release
- Loading branch information
Showing
4 changed files
with
30 additions
and
40 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,46 +1,36 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Serilog; | ||
using Serilog.Core; | ||
|
||
namespace Sample | ||
{ | ||
public static class Program | ||
{ | ||
public static async Task Main() | ||
{ | ||
// By sharing between the Seq sink and logger itself, | ||
// Seq API keys can be used to control the level of the whole logging pipeline. | ||
var levelSwitch = new LoggingLevelSwitch(); | ||
// By sharing between the Seq sink and logger itself, | ||
// Seq API keys can be used to control the level of the whole logging pipeline. | ||
var levelSwitch = new LoggingLevelSwitch(); | ||
|
||
try | ||
{ | ||
Log.Logger = new LoggerConfiguration() | ||
.MinimumLevel.ControlledBy(levelSwitch) | ||
.WriteTo.Console() | ||
.WriteTo.Seq("http://localhost:5341", controlLevelSwitch: levelSwitch) | ||
.CreateLogger(); | ||
try | ||
{ | ||
Log.Logger = new LoggerConfiguration() | ||
.MinimumLevel.ControlledBy(levelSwitch) | ||
.WriteTo.Console() | ||
.WriteTo.Seq("http://localhost:5341", controlLevelSwitch: levelSwitch) | ||
.CreateLogger(); | ||
|
||
Log.Information("Sample starting up"); | ||
Log.Information("Sample starting up"); | ||
|
||
foreach (var i in Enumerable.Range(0, 100)) | ||
{ | ||
Log.Information("Running loop {Counter}, switch is at {Level}", i, levelSwitch.MinimumLevel); | ||
foreach (var i in Enumerable.Range(0, 100)) | ||
{ | ||
Log.Information("Running loop {Counter}, switch is at {Level}", i, levelSwitch.MinimumLevel); | ||
|
||
Thread.Sleep(1000); | ||
Log.Debug("Loop iteration done"); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Log.Error(ex, "Unhandled exception"); | ||
} | ||
finally | ||
{ | ||
await Log.CloseAndFlushAsync(); | ||
} | ||
} | ||
Thread.Sleep(1000); | ||
Log.Debug("Loop iteration done"); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Log.Error(ex, "Unhandled exception"); | ||
} | ||
finally | ||
{ | ||
await Log.CloseAndFlushAsync(); | ||
} |
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 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