private void SendLogAction(LoggingEvent loggingEvent) { //we should always format event in the same thread as //many properties used in the event are associated with the current thread //like threadname, ndc stacks, threadcontent properties etc. //initializing a string for the formatted log string formattedMessage; //if Layout is null then format the log from the Loggly Client if (Layout == null) { // TODO: Adjust Formatter to optimally suit Google Cloud Logging. Formatter.AppendAdditionalLoggingInformation(_config, loggingEvent); formattedMessage = Formatter.ToJson(loggingEvent); } else { //formattedMessage = Formatter.ToJson(RenderLoggingEvent(loggingEvent), loggingEvent.TimeStamp); formattedMessage = RenderLoggingEvent(loggingEvent); } //var y= RenderLoggingEvent(loggingEvent); //var z = loggingEvent.RenderedMessage; var formattedLoggingEvent = new FormattedLoggingEvent(loggingEvent, formattedMessage); ThreadPool.QueueUserWorkItem(x => _client.Send(new FormattedLoggingEvent[] { formattedLoggingEvent })); }
protected override void Append(LoggingEvent loggingEvent) { // We initialize here and not in the ctor because at construction time config values are not available to us. if (_client == null) { _client = new Client(_config, RenderLoggingEvent); } Formatter.AppendAdditionalLoggingInformation(_config, loggingEvent); base.Append(loggingEvent); }