예제 #1
0
        /* C R E A T E  N E W  W I N D O W */
        /*----------------------------------------------------------------------------
            %%Function: CreateNewWindow
            %%Qualified: AzLog.AzLogWindow.CreateNewWindow
            %%Contact: rlittle

        ----------------------------------------------------------------------------*/
        public static AzLogWindow CreateNewWindow(AzLogModel azlm, string sViewName, AzLogFilter azlf, ILogClient ilc)
        {
            AzLogWindow azlw = new AzLogWindow();

            azlw.SetView(sViewName);
            azlw.m_azlv = new AzLogView(azlw);
            azlw.m_azlv.SetFilter(azlf);

            // propagate the filter values we were given into the textboxes on our window
            AzLogFilter.AzLogFilterCondition azlfc;

            azlfc = azlf.Operations[0].Condition;
            if (azlfc.LHS.Source == AzLogFilter.AzLogFilterValue.DataSource.DttmRow && azlfc.Comparison == AzLogFilter.AzLogFilterCondition.CmpOp.Gte)
                azlw.m_ebStart.Text = azlfc.RHS.Dttm(null).ToString("MM/dd/yy HH:mm");

            azlfc = azlf.Operations[1].Condition;
            if (azlfc.LHS.Source == AzLogFilter.AzLogFilterValue.DataSource.DttmRow && azlfc.Comparison == AzLogFilter.AzLogFilterCondition.CmpOp.Lt)
                azlw.m_ebEnd.Text = azlfc.RHS.Dttm(null).ToString("MM/dd/yy HH:mm");

            azlw.m_ilc = ilc;
            azlw.m_azlm = azlm;
            azlw.m_azlv.BuildView(azlw.m_azlm, new CompareLogEntryTickCount(azlw.m_azlm));

            azlw.m_lvLog.VirtualListSize = azlw.m_azlv.Length;

            return azlw;
        }
예제 #2
0
        static void Main(string[] args)
        {
            SeverityFilter warning_filter = new SeverityFilter()
            {
                comparison = ComparisonOperator.geq,
                severity   = SyslogSeverity.Warning
            };

            Console.WriteLine("This program is going to listen for all messages with severity >= Warning.");
            Console.WriteLine("All received messages will be written on this console in their native format.");

            Console.WriteLine();
            Console.WriteLine("You must start Logbus daemon prior to running this program.");
            Console.WriteLine("Please press ENTER when you are sure that Logbus daemon is already running...");
            Console.ReadLine();

            Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);

            try
            {
                logclient = ClientHelper.CreateUnreliableClient(warning_filter);
                logclient.MessageReceived += new EventHandler <SyslogMessageEventArgs>(logclient_MessageReceived);

                logclient.Start();
                Console.WriteLine("Listener is started. Press CTRL+C to exit when you are finished");

                Thread.Sleep(Timeout.Infinite);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Something went wrong...");
                Console.WriteLine(ex);
                Environment.Exit(1);
            }
        }
예제 #3
0
        public void TestTlsClient()
        {
            _success = new AutoResetEvent(false);
            using (ILogBus logbus = LogbusSingletonHelper.Instance)
            {
                logbus.Start();

                using (ILogClient client = ClientHelper.CreateReliableClient(new TrueFilter()))
                {
                    client.Start();
                    client.MessageReceived += client_MessageReceived;

                    ILog logger = LoggerHelper.GetLogger();
                    logger.Notice("Hello K.I.T.T.!");

                    Assert.IsTrue(_success.WaitOne(10000));
                }
            }
        }
        public override void ActivateOptions()
        {

            StackifyAPILogger.Log("ActiveOptions on log4net appender");

            try
            {
                if (!String.IsNullOrEmpty(globalContextKeys))
                {
                    _GlobalContextKeys = globalContextKeys.Split(',').Select(s => s.Trim()).ToList();
                }

                if (!String.IsNullOrEmpty(threadContextKeys))
                {
                    _ThreadContextKeys = threadContextKeys.Split(',').Select(s => s.Trim()).ToList();
                }

                if (!String.IsNullOrEmpty(logicalThreadContextKeys))
                {
                    _LogicalThreadContextKeys = logicalThreadContextKeys.Split(',').Select(s => s.Trim()).ToList();
                }

                if (!String.IsNullOrEmpty(callContextKeys))
                {
                    _CallContextKeys = callContextKeys.Split(',').Select(s => s.Trim()).ToList();
                }

                _HasContextKeys = _GlobalContextKeys.Any() || _ThreadContextKeys.Any() || _LogicalThreadContextKeys.Any() || _CallContextKeys.Any();

                _logClient = CreateLogClient(apiKey, uri);
            }
            catch (Exception ex)
            {
                StackifyAPILogger.Log(ex.Message, true);
            }

          

            base.ActivateOptions();

        }
        public override void ActivateOptions()
        {
            StackifyAPILogger.Log("ActiveOptions on log4net appender");

            try
            {
                //if (!String.IsNullOrEmpty(globalContextKeys))
                //{
                //    _GlobalContextKeys = globalContextKeys.Split(',').Select(s => s.Trim()).ToList();
                //}

                //if (!String.IsNullOrEmpty(threadContextKeys))
                //{
                //    _ThreadContextKeys = threadContextKeys.Split(',').Select(s => s.Trim()).ToList();
                //}

                //if (!String.IsNullOrEmpty(logicalThreadContextKeys))
                //{
                //    _LogicalThreadContextKeys = logicalThreadContextKeys.Split(',').Select(s => s.Trim()).ToList();
                //}

                if (!String.IsNullOrEmpty(callContextKeys))
                {
                    _CallContextKeys = callContextKeys.Split(',').Select(s => s.Trim()).ToList();
                }

//                _HasContextKeys = _GlobalContextKeys.Any() || _ThreadContextKeys.Any() || _LogicalThreadContextKeys.Any() || _CallContextKeys.Any();
                _HasContextKeys = _CallContextKeys.Any();

                _logClient = CreateLogClient(apiKey, uri);
            }
            catch (Exception ex)
            {
                StackifyAPILogger.Log(ex.Message, true);
            }



            base.ActivateOptions();
        }
예제 #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("This program monitors only heartbeats coming from any entity in the system.");
            Console.WriteLine("Press CTRL+C when you are finished.");

            PropertyFilter idFilt = new PropertyFilter
            {
                comparison   = ComparisonOperator.eq,
                propertyName = Property.MessageID,
                value        = "HEARTBEAT"
            };
            SeverityFilter debugFilter = new SeverityFilter {
                comparison = ComparisonOperator.eq, severity = SyslogSeverity.Debug
            };

            using (ILogClient client = ClientHelper.CreateUnreliableClient(idFilt & debugFilter))
            {
                client.MessageReceived += client_MessageReceived;
                client.Start();
                Thread.Sleep(Timeout.Infinite);
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="bufferBaseFilename"></param>
 /// <param name="batchPostingLimit"></param>
 /// <param name="period"></param>
 /// <param name="eventBodyLimitBytes"></param>
 /// <param name="levelControlSwitch"></param>
 /// <param name="logClient"></param>
 /// <param name="payloadReader"></param>
 /// <param name="retainedInvalidPayloadsLimitBytes"></param>
 /// <param name="bufferSizeLimitBytes"></param>
 public LogShipper(
     string bufferBaseFilename,
     int batchPostingLimit,
     TimeSpan period,
     long?eventBodyLimitBytes,
     LoggingLevelSwitch levelControlSwitch,
     ILogClient <TPayload> logClient,
     IPayloadReader <TPayload> payloadReader,
     long?retainedInvalidPayloadsLimitBytes,
     long?bufferSizeLimitBytes)
 {
     _batchPostingLimit   = batchPostingLimit;
     _eventBodyLimitBytes = eventBodyLimitBytes;
     _logClient           = logClient;
     _payloadReader       = payloadReader;
     _controlledSwitch    = new ControlledLevelSwitch(levelControlSwitch);
     _connectionSchedule  = new ExponentialBackoffConnectionSchedule(period);
     _retainedInvalidPayloadsLimitBytes = retainedInvalidPayloadsLimitBytes;
     _bufferSizeLimitBytes = bufferSizeLimitBytes;
     _fileSet = new FileSet(bufferBaseFilename);
     _timer   = new PortableTimer(c => OnTick());
     SetTimer();
 }
예제 #8
0
        /* C R E A T E  N E W  W I N D O W */

        /*----------------------------------------------------------------------------
        *       %%Function: CreateNewWindow
        *       %%Qualified: AzLog.AzLogWindow.CreateNewWindow
        *       %%Contact: rlittle
        *
        *  ----------------------------------------------------------------------------*/
        public static AzLogWindow CreateNewWindow(AzLogModel azlm, string sViewName, AzLogFilter azlf, ILogClient ilc)
        {
            AzLogWindow azlw = new AzLogWindow();

            if (String.IsNullOrEmpty(sViewName))
            {
                sViewName = "Default";
            }

            azlw.SetView(sViewName);
            azlw.m_azlv = new AzLogView(azlw);
            azlw.m_azlv.SetFilter(azlf);

            // propagate the filter values we were given into the textboxes on our window
            AzLogFilter.AzLogFilterCondition azlfc;

            azlfc = azlf.Operations[0].Condition;
            if (azlfc.LHS.Source == AzLogFilter.AzLogFilterValue.DataSource.DttmRow && azlfc.Comparison == AzLogFilter.AzLogFilterCondition.CmpOp.Gte)
            {
                azlw.m_ebStart.Text = azlfc.RHS.Dttm(null).ToLocalTime().ToString("MM/dd/yy HH:mm");
            }

            azlfc = azlf.Operations[1].Condition;
            if (azlfc.LHS.Source == AzLogFilter.AzLogFilterValue.DataSource.DttmRow && azlfc.Comparison == AzLogFilter.AzLogFilterCondition.CmpOp.Lt)
            {
                azlw.m_ebEnd.Text = azlfc.RHS.Dttm(null).ToLocalTime().ToString("MM/dd/yy HH:mm");
            }

            azlw.m_ilc  = ilc;
            azlw.m_azlm = azlm;
            azlw.m_azlv.BuildView(azlw.m_azlm, new CompareLogEntryTickCount(azlw.m_azlm));
            // azlw.m_lvLog.VirtualListSize = azlw.m_azlv.Length;
            azlw.m_lvLog.SetVirtualListSize(azlw.m_azlv.Length);
            return(azlw);
        }
예제 #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="bufferBaseFilename"></param>
 /// <param name="batchPostingLimit"></param>
 /// <param name="period"></param>
 /// <param name="eventBodyLimitBytes"></param>
 /// <param name="levelControlSwitch"></param>
 /// <param name="logClient"></param>
 /// <param name="payloadReader"></param>
 /// <param name="retainedInvalidPayloadsLimitBytes"></param>
 /// <param name="bufferSizeLimitBytes"></param>
 /// <param name="registerTemplateIfNeeded"></param>
 public ElasticsearchLogShipper(string bufferBaseFilename, int batchPostingLimit, TimeSpan period,
                                long?eventBodyLimitBytes, LoggingLevelSwitch levelControlSwitch, ILogClient <List <string> > logClient,
                                IPayloadReader <List <string> > payloadReader, long?retainedInvalidPayloadsLimitBytes,
                                long?bufferSizeLimitBytes, Action registerTemplateIfNeeded)
     : base(bufferBaseFilename, batchPostingLimit, period, eventBodyLimitBytes,
            levelControlSwitch, logClient, payloadReader, retainedInvalidPayloadsLimitBytes, bufferSizeLimitBytes)
 {
     _registerTemplateIfNeeded = registerTemplateIfNeeded;
 }
예제 #10
0
 public LogService(ILogClient client)
 {
     this.client = client;
 }
예제 #11
0
        private static void Run(int timeout)
        {
            _messagesRcvd = new BitArray(_expected, false);
            _received     = 0;
            string pid = Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture);

            ILogCollector  server     = CollectorHelper.CreateCollector();
            string         host       = Dns.GetHostName();
            PropertyFilter hostFilter = new PropertyFilter
            {
                comparison   = ComparisonOperator.eq,
                value        = host,
                propertyName = Property.Host
            };
            FacilityEqualsFilter facFilter = new FacilityEqualsFilter {
                facility = SyslogFacility.Local4
            };
            PropertyFilter pidFilter = new PropertyFilter
            {
                comparison   = ComparisonOperator.eq,
                value        = pid,
                propertyName = Property.ProcessID
            };
            PropertyFilter idFilter = new PropertyFilter
            {
                value        = "BENCH",
                comparison   = ComparisonOperator.eq,
                propertyName = Property.MessageID
            };
            SeverityFilter sevFilter = new SeverityFilter
            {
                comparison = ComparisonOperator.eq,
                severity   = SyslogSeverity.Notice
            };

            using (ILogClient client = ClientHelper.CreateReliableClient(hostFilter & pidFilter & idFilter & sevFilter & facFilter))
            {
                client.MessageReceived += client_MessageReceived;
                client.Start();

                for (int i = 0; i < _expected; i++)
                {
                    if (timeout > 0)
                    {
                        Nanosleep(timeout);
                    }
                    SyslogMessage message = new SyslogMessage
                    {
                        Timestamp = DateTime.Now,
                        Facility  = SyslogFacility.Local4,
                        Severity  = SyslogSeverity.Notice,
                        Host      = host,
                        ProcessID = pid,
                        MessageId = "BENCH",
                        Text      = i.ToString()
                    };

                    server.SubmitMessage(message);
                }
                silenceTimer = new Timer(state => Stop.Set(), null, 40000, Timeout.Infinite);
                Console.WriteLine("Waiting up to 30 seconds after last message received...");
                Stop.WaitOne();
            }

            if (_expected == _received)
            {
                Console.WriteLine("Received all messaged");
            }
            else
            {
                Console.WriteLine("Lost {0} messages", _expected - _received);
            }
        }
예제 #12
0
 public LogService(
     ILogClient logClient)
 {
     _logClient = logClient;
 }
예제 #13
0
 internal Report(ILog log, ILogClient logClient, bool synchronousCloudReporting = false)
 {
     _log       = log;
     _logClient = logClient;
     _synchronousCloudReporting = synchronousCloudReporting;
 }
예제 #14
0
        static void Main(string[] args)
        {
            bool reliable = args != null && args.Length > 0 && args[0] == "--reliable";

            Console.CancelKeyPress += Console_CancelKeyPress;

            Console.WriteLine("This program periodically measures the RTT for log messages sent by here");

            if (!reliable)
            {
                Console.WriteLine("Going in unreliable mode. Messages are subject to loss.");
                Console.WriteLine("Use the --reliable switch to go into reliable mode, where messages don't get lost.");
            }
            else
            {
                Console.WriteLine("Reliable mode activated. No messages will be lost because of the network.");
            }

            PropertyFilter hostFilter = new PropertyFilter
            {
                comparison   = ComparisonOperator.eq,
                value        = Dns.GetHostName(),
                propertyName = Property.Host
            };
            PropertyFilter pidFilter = new PropertyFilter
            {
                comparison = ComparisonOperator.eq,
                value      =
                    Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture),
                propertyName = Property.ProcessID
            };
            PropertyFilter idFilter = new PropertyFilter
            {
                value        = "RTT",
                comparison   = ComparisonOperator.eq,
                propertyName = Property.MessageID
            };

            _target = CollectorHelper.CreateCollector((reliable) ? "tls" : "udp");
            FilterBase filter = hostFilter & pidFilter & idFilter;

            _source = (reliable) ? ClientHelper.CreateReliableClient(filter) : ClientHelper.CreateUnreliableClient(filter);
            _log    = LoggerHelper.GetLogger("Logfile");

            _source.MessageReceived += source_MessageReceived;
            _source.Start();

            while (true)
            {
                _id++;
                DateTime      curTimestamp = DateTime.UtcNow;
                double        millis       = (curTimestamp - DateTime.Today).TotalMilliseconds;
                string        text         = _id.ToString(CultureInfo.InvariantCulture) + "_" + millis.ToString(CultureInfo.InvariantCulture);
                SyslogMessage message      = new SyslogMessage(SyslogFacility.Local3, SyslogSeverity.Notice, text)
                {
                    MessageId = "RTT"
                };

                _target.SubmitMessage(message);

                if (!_ar.WaitOne(10000))
                {
                    Console.WriteLine("RTT sent at {0} lost", curTimestamp);
                    _log.Warning("RTT sent at {0} lost", curTimestamp);
                    continue;
                }
                Thread.Sleep(3000);
            }
        }