forked from postsharp/PostSharp.Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
52 lines (46 loc) · 1.78 KB
/
Copy pathProgram.cs
File metadata and controls
52 lines (46 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using PostSharp.Patterns.Diagnostics;
using PostSharp.Patterns.Diagnostics.Backends.Serilog;
using PostSharp.Patterns.Diagnostics.RecordBuilders;
using Serilog;
using System;
using System.Threading.Tasks;
using static PostSharp.Patterns.Diagnostics.FormattedMessageBuilder;
[assembly: Log]
namespace ClientExample
{
public static class Program
{
private static readonly LogSource logSource = LogSource.Get();
private static async Task Main()
{
using (var logger = new LoggerConfiguration()
.Enrich.WithProperty("Application", "ClientExample")
.MinimumLevel.Debug()
.WriteTo.Async(a => a.DurableHttp(requestUri: "http://localhost:31311", batchPostingLimit: 5))
.WriteTo.Console(
outputTemplate:
"{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] {Indent:l}{Message:l}{NewLine}{Exception}")
.CreateLogger())
{
var backend = new SerilogLoggingBackend(logger);
backend.Options.IncludeActivityExecutionTime = true;
backend.Options.IncludeExceptionDetails = true;
backend.Options.SemanticParametersTreatedSemantically = SemanticParameterKind.All;
backend.Options.IncludedSpecialProperties = SerilogSpecialProperties.All;
backend.Options.ContextIdGenerationStrategy = ContextIdGenerationStrategy.Hierarchical;
LoggingServices.DefaultBackend = backend;
using (logSource.Debug.OpenActivity(Formatted("Running the client"), new OpenActivityOptions
{
Properties = new[]
{
new LoggingProperty("User", "Gaius Julius Caesar") {IsBaggage = true}
}
}))
{
await QueueProcessor.ProcessQueue(".\\My\\Queue");
}
}
Console.WriteLine("Done!");
}
}
}