예제 #1
0
파일: Program.cs 프로젝트: dimmik/TLog
        static void Main(string[] args)
        {
            var log = LogManager.GetLogger("console");
            log.Trace("trace");
            log.Debug("debug");
            log.Info("info");
            log.Warn("warn");
            log.Error("error");
            Console.WriteLine("press any key");
            Console.ReadKey();
            var tlogFactory = new LogFactory(minLevel: LogLevel.Info)
            {
                Trace = log.Trace,
                Debug = log.Debug,
                Info = m =>
                {
                    Thread.Sleep(new Random().Next(1000));
                    log.Info(m);
                    //Thread.Sleep(1000); // for async test
                },
                Error = (msg, e) => log.Error(e, msg),
                Flush = (msg, e) => LogManager.GetLogger("file").Error(e, msg),

                //FlushLevel = LogLevel.Debug
            };
            //tlogFactory.Trace = null;
            TestLog(tlogFactory.GetLogger("test logger"));
            TestLog(tlogFactory.GetAsyncLogger("test async logger"));
            Console.WriteLine("press any key");
            Console.ReadKey();
        }
예제 #2
0
        static void Main(string[] args)
        {
            var log = LogManager.GetLogger("console");

            log.Trace("trace");
            log.Debug("debug");
            log.Info("info");
            log.Warn("warn");
            log.Error("error");
            Console.WriteLine("press any key");
            Console.ReadKey();
            var tlogFactory = new LogFactory(minLevel: LogLevel.Info)
            {
                Trace = log.Trace,
                Debug = log.Debug,
                Info  = m =>
                {
                    Thread.Sleep(new Random().Next(1000));
                    log.Info(m);
                    //Thread.Sleep(1000); // for async test
                },
                Error = (msg, e) => log.Error(e, msg),
                Flush = (msg, e) => LogManager.GetLogger("file").Error(e, msg),

                //FlushLevel = LogLevel.Debug
            };

            //tlogFactory.Trace = null;
            TestLog(tlogFactory.GetLogger("test logger"));
            TestLog(tlogFactory.GetAsyncLogger("test async logger"));
            Console.WriteLine("press any key");
            Console.ReadKey();
        }
예제 #3
0
파일: TLogFactory.cs 프로젝트: dimmik/TLog
 public TransactionalLog(LogFactory factory,
     string id)
 {
     _factory = factory;
     _identifier = id;
 }