Пример #1
0
        static void Main(string[] args)

        {
            Stream       st     = File.OpenRead(@"C:\Users\tarun.tank\source\repos\log\VerifyLogging\log4net.config");
            CustomLogger logger = new CustomLogger(st, "MYCustomLoggerRepo");

            //logger.InitializeLogger("ClassLibrary1");

            logger.InitializeLoggerWithDynamicFile("MYCustomLogger", "MYCustomLogFile");
            logger.LogInfo(LogLevelWrapper.DEBUG, "MY log", "DEBUG 1 {0}--->{1}", new object[] { "firstArg", "SecondArg" });
            logger.changeConfiguration("MYCustomLoggerRepo");
            logger.LogInfo(LogLevelWrapper.ERROR, "MY log", "DEBU 2 {0}--->{1}", new object[] { "firstArg", "SecondArg" });

            //st = File.OpenRead(@"C:\Users\tarun.tank\source\repos\log\VerifyLogging\log4net.config");
            //CustomLogger loggerOther = new CustomLogger(st, "OtherCustomLoggerRepo");
            //loggerOther.InitializeLoggerWithDynamicFile("OtherCustomLogger", "OtherCustomLoggerFile");
            //loggerOther.LogInfo(LogLevelWrapper.ERROR, "Other log", " {0}--->{1}", new object[] { "firstArg", "SecondArg" });


            //logger.CloseRepository();
            //loggerOther.CloseRepository();


            //st = File.OpenRead(@"C:\Users\tarun.tank\source\repos\log\VerifyLogging\log4net.config");
            //CustomLogger loggerSeparate = new CustomLogger(st, "SeparateCustomLoggerRepo");
            //loggerSeparate.InitializeLoggerWithDynamicFile("SeparateCustomLogger", "SeparateCustomLoggerFile");
            //loggerSeparate.LogInfo(LogLevelWrapper.ERROR, "Separate log", " {0}--->{1}", new object[] { "firstArg", "SecondArg" });


            //logger.LogInfo(LogLevelWrapper.WARN, "MY log WARN log without format");
            //loggerOther.LogInfo(LogLevelWrapper.WARN, "Other log WARN log without format");
            //loggerSeparate.LogInfo(LogLevelWrapper.WARN, "Separate log WARN log without format");


            //logger.LogInfo(LogLevelWrapper.ERROR, "ERROR log format msg WITHOUT EX", " {0}--->{1}", new object[] { "firstArg", "SecondArg" });
            //logger.LogInfo(LogLevelWrapper.ERROR, "ERROR log without format msg WITHOUT EX");
            //logger.LogInfo(LogLevelWrapper.ERROR, new NullReferenceException(), "ERROR log format msg", " {0}--->{1}", new object[] { "firstArg", "SecondArg" });
            //logger.LogInfo(LogLevelWrapper.ERROR, new NullReferenceException(), "ERROR log without format msg");
            Console.WriteLine();
        }