Beispiel #1
0
        public void TestAppendersIsIAppender()
        {
            var simpleLayout = new SimpleLayout();
            var xmlLayout = new XmlLayout();

            var fileAppender = new FileAppender(simpleLayout);
            IAppender fileAppenderXml = new FileAppender(xmlLayout);

            Assert.IsInstanceOfType(fileAppender, typeof(IAppender), "This fileAppender is not IAppender.");
            Assert.IsInstanceOfType(fileAppenderXml, typeof(IAppender), "This fileAppenderXml is not IAppender.");
        }
Beispiel #2
0
        public void TestAppendersMissingFilePath()
        {
            var pathTxt = string.Empty;
            var pathXml = string.Empty;

            var simpleLayout = new SimpleLayout();
            var xmlLayout = new XmlLayout();

            var fileAppender = new FileAppender(simpleLayout);
            IAppender fileAppenderXml = new FileAppender(xmlLayout);

            fileAppender.File = pathTxt;
            fileAppenderXml.File = pathXml;
        }
Beispiel #3
0
        public void TestAppendersFilePath()
        {
            string pathTxt = "../../log.txt";
            string pathXml = "../../log.xml";

            var simpleLayout = new SimpleLayout();
            var xmlLayout = new XmlLayout();

            var fileAppender = new FileAppender(simpleLayout);
            IAppender fileAppenderXml = new FileAppender(xmlLayout);
            
            fileAppender.File = pathTxt;
            fileAppenderXml.File = pathXml;

            Assert.AreEqual(pathTxt, fileAppender.File, "This is not same path for log.txt.");
            Assert.AreEqual(pathXml, fileAppenderXml.File, "This is not same path for log.xml.");
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            //ILayout simpleLayout = new SimpleLayout();
            //IAppender consoleAppender =
            //     new ConsoleAppender(simpleLayout);
            //ILogger logger = new Logger.Models.Loggers.Logger(consoleAppender);

            //logger.Error("Error parsing JSON.");
            //logger.Info(string.Format("User {0} successfully registered.", "Pesho"));

            //var simpleLayout = new SimpleLayout();

            //var consoleAppender = new ConsoleAppender(simpleLayout);
            //var fileAppender = new FileAppender(simpleLayout);
            //fileAppender.File = "log.txt";

            //var logger = new Logger.Models.Loggers.Logger(consoleAppender, fileAppender);
            //logger.Error("Error parsing JSON.");
            //logger.Info(string.Format("User {0} successfully registered.", "Pesho"));
            //logger.Warn("Warning - missing files.");

            //var xmlLayout = new XmlLayout();
            //var consoleAppender = new ConsoleAppender(xmlLayout);
            //var logger = new Logger.Models.Loggers.Logger(consoleAppender);

            //logger.Fatal("mscorlib.dll does not respond");
            //logger.Critical("No connection string found in App.config");

            var simpleLayout = new SimpleLayout();
            var consoleAppender = new ConsoleAppender(simpleLayout);
            consoleAppender.ReportLevel = ReportLevel.Error;

            var logger = new Logger.Models.Loggers.Logger(consoleAppender);

            logger.Info("Everything seems fine");
            logger.Warn("Warning: ping is too high - disconnect imminent");
            logger.Error("Error parsing request");
            logger.Critical("No connection string found in App.config");
            logger.Fatal("mscorlib.dll does not respond");
        }
Beispiel #5
0
 public void TestSimpleLayoutIsILayout()
 {
     ILayout simpleLayout = new SimpleLayout();
     Assert.IsInstanceOfType(simpleLayout, typeof(ILayout), "This simpleLayout is not type ILayout.");
 }