/// <summary> /// This is the entry point of the service host process. /// </summary> private static void Main() { try { // The ServiceManifest.XML file defines one or more service type names. // Registering a service maps a service type name to a .NET type. // When Service Fabric creates an instance of this service type, // an instance of the class is created in this host process. ServiceRuntime.RegisterServiceAsync("TestMethodBoundryAspectLoggingServiceType", context => new TestMethodBoundryAspectLoggingService(context)).GetAwaiter().GetResult(); LoggingServices.DefaultBackend = new EventSourceLoggingBackend(); var eventSourceBackend = new EventSourceLoggingBackend(new PostSharpEventSource()); if (eventSourceBackend.EventSource.ConstructionException != null) { throw eventSourceBackend.EventSource.ConstructionException; } ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(TestMethodBoundryAspectLoggingService).Name); // Prevents this host process from terminating so services keep running. Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } }
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'. }