static async Task AsyncMain() { #region ConfigureLogging using (var listener = new CustomEventListener()) using (var eventSourceLogger = new SimpleSourceLogger()) { listener.EnableEvents(eventSourceLogger, EventLevel.Informational); var loggingFactory = LogManager.Use <EventSourceLoggingFactory>(); loggingFactory.WithLogger(eventSourceLogger); var endpointConfiguration = new EndpointConfiguration("EndpointName"); // other Endpoint Configuration var endpointInstance = await Endpoint.Start(endpointConfiguration) .ConfigureAwait(false); try { // either a blocking action or split the instantiation // and disposal in to the server startup and shutdown } finally { await endpointInstance.Stop() .ConfigureAwait(false); } } #endregion }
static async Task AsyncMain() { Console.Title = "Samples.Logging.SimpleSourceLogger"; #region ConfigureLogging using (var listener = new CustomEventListener()) using (var eventSourceLogger = new SimpleSourceLogger()) { listener.EnableEvents(eventSourceLogger, EventLevel.Informational); var loggingFactory = LogManager.Use <EventSourceLoggingFactory>(); loggingFactory.WithLogger(eventSourceLogger); var endpointConfiguration = new EndpointConfiguration("Samples.Logging.SimpleSourceLogger"); ApplyBasicConfig(endpointConfiguration); var endpointInstance = await Endpoint.Start(endpointConfiguration) .ConfigureAwait(false); await SendMessage(endpointInstance) .ConfigureAwait(false); Console.WriteLine("Press any key to exit"); Console.ReadKey(); await endpointInstance.Stop() .ConfigureAwait(false); } #endregion }