-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathProgram.cs
33 lines (28 loc) · 1.25 KB
/
Program.cs
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
using PostSharp.Patterns.Diagnostics;
using PostSharp.Patterns.Diagnostics.Backends.EventSource;
using PostSharp.Samples.Logging.BusinessLogic;
// Add logging to all methods of this project.
[assembly: Log]
namespace PostSharp.Samples.Logging.Etw
{
[Log(AttributeExclude = true)] // Removes logging from the Program class itself.
internal class Program
{
private static void Main(string[] args)
{
var eventSourceBackend = new EventSourceLoggingBackend(new PostSharpEventSource());
if (eventSourceBackend.EventSource.ConstructionException != null)
{
throw eventSourceBackend.EventSource.ConstructionException;
}
LoggingServices.DefaultBackend = eventSourceBackend;
// Simulate some business logic.
QueueProcessor.ProcessQueue(@".\Private$\SyncRequestQueue");
// To collect and view the log:
// 1. Download PerfView from https://www.microsoft.com/en-us/download/details.aspx?id=28567.
// 2. Execute: perfview.exe collect -OnlyProviders:*PostSharp-Patterns-Diagnostics
// 3. Execute this program.
// 4. In PerfView, click 'Stop collecting', then in the PerfView tree view click 'PerfViewData.etl.zip' and finally 'Events'.
}
}
}