示例#1
0
        public static FilterAny Any(IEnumerable <Filter> filters)
        {
            var result = new FilterAny();

            result.AddRange(filters);

            return(result);
        }
示例#2
0
        private static void ParseXml(string filename)
        {
            using (new TimeTrace ("total"))
            {
                using (new TimeTrace ("process with E/S init"))
                {
                    using (var eventSource = Log4JFile.Create (filename))
                    using (new TimeTrace ("process inner"))
                    using (var filterTs = new FilterTimestamp (1411231371536L, 1411231371556L))
                    using (var filterLvl = new FilterLevel ("INFO", "ERROR"))
                    using (var filterLgr = new FilterLogger ("Root.ChildB"))
                    using (var filterMsg1 = new FilterMessage ("#2"))
                    using (var filterMsg2 = new FilterMessage ("#3"))
                    using (var filterNot = new FilterNot (filterLvl))
                    using (var filterAny = new FilterAny ())
                    using (var filterAll = new FilterAll ())
                    {
                        filterAny.Add (filterMsg1);
                        filterAny.Add (filterMsg2);

                        filterAll.Add (filterTs);
                        filterAll.Add (filterNot);
                        filterAll.Add (filterAny);
                        filterAll.Add (filterLgr);

                        var matchingEvents = eventSource
                            .GetEvents ()
                            .Where (filterAll)
                            .Take (20)
                            .ToList ();

                        foreach (var @event in matchingEvents)
                        {
                            PrintEvent (@event);
                        }

                        Console.WriteLine ("Found events: {0}", matchingEvents.Count);
                    }
                }

                using (new TimeTrace ("count all events"))
                using (var eventSource = Log4JFile.Create (filename))
                {
                    var count = eventSource.GetEvents ().Count ();

                    Console.WriteLine ("Found events: {0}", count);
                }
            }
        }