Ejemplo n.º 1
0
        protected override async void OnEventWritten(EventWrittenEventArgs eventData)
        {
            if (httpConfiguration == null)
            {
                return;
            }

            await semaphoreSlim.WaitAsync();

            try
            {
                var model = serializeListener.Deserialize <TBaseEventInfo>(eventData.Payload[0].ToString());
                model.Level = eventData.Level;
                var json = serializeListener.Serialize(model);

                if (httpConfiguration.AuthenticationHeaderValue != null)
                {
                    httpClient.DefaultRequestHeaders.Authorization = httpConfiguration.AuthenticationHeaderValue;
                }

                var content = new StringContent(json, Encoding.UTF8, "application/json");

                httpClient.PostAsync(new Uri($"{httpConfiguration.Url}"), content);
            }
            finally
            {
                semaphoreSlim.Release();
            }
        }
Ejemplo n.º 2
0
 public void Debug(BaseEventInfo message)
 {
     BaseEventSource.Log.Debug(serializeListener.Serialize(message));
 }