예제 #1
0
        /// <summary>
        /// Used to check if there have been recent failures or if the queue is backed up and if logs can be sent or not
        /// </summary>
        /// <returns></returns>
        public static bool CanSend()
        {
            if (_LogClient == null)
            {
                return(false);
            }

            return(_LogClient.CanQueue());
        }
예제 #2
0
 protected override void Write(AsyncLogEventInfo logEvent)
 {
     try
     {
         //make sure the buffer isn't overflowing
         //if it is skip since we can't do anything with the message
         if (StackifyLib.Logger.PrefixEnabled() || _logClient.CanQueue())
         {
             var logMsg = Translate(logEvent.LogEvent);
             if (logMsg != null)
             {
                 _logClient.QueueMessage(logMsg);
             }
             logEvent.Continuation(null); // Signal success to NLog
         }
         else
         {
             InternalLogger.Warn("StackifyTarget: Cannot send because queue is full");
             logEvent.Continuation(new OperationCanceledException("StackifyTarget: Cannot send because queue is full")); // Signal failure to NLog
             StackifyAPILogger.Log("Unable to send log because the queue is full");
         }
     }
     catch (Exception ex)
     {
         InternalLogger.Error("StackifyTarget: Failed to send");
         logEvent.Continuation(ex);  // Signal failure to NLog
         StackifyAPILogger.Log(ex.ToString());
     }
 }
예제 #3
0
        protected override void Append(LoggingEvent loggingEvent)
        {
            try
            {
                //make sure the buffer isn't overflowing
                //if it is skip since we can't do anything with the message

                if (Logger.PrefixEnabled() || _logClient.CanQueue())
                {
                    var logMsg = Translate(loggingEvent);
                    if (logMsg != null)
                    {
                        _logClient.QueueMessage(logMsg);
                    }
                }
                else
                {
                    StackifyAPILogger.Log("Unable to send log because the queue is full");
                }
            }
            catch (Exception ex)
            {
                StackifyAPILogger.Log(ex.ToString());
            }
        }