public static void Main()
        {
            var simpleLayout = new SimpleLayout();
            var consoleAppender = new ConsoleAppender(simpleLayout);
            var fileAppender = new FileAppender(simpleLayout);
            fileAppender.File = "../../log.txt";
            fileAppender.ReportLevel = ReportLevel.Warning;
            consoleAppender.ReportLevel = ReportLevel.Error;

            var logger = new Logger(consoleAppender, fileAppender);

            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");
        }
Exemple #2
0
        public static void Main()
        {
            var simpleLayout    = new SimpleLayout();
            var consoleAppender = new ConsoleAppender(simpleLayout);

            // The only reason this is not set in the constructor is because of the example in the task.
            // The syntax there requires it.
            consoleAppender.ReportLevel = ReportLevel.Error;

            var logger = new 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");

            // First example. (you will need to import _01.Logger.Contracts for this one)
            ////ILayout simpleLayout = new SimpleLayout();
            ////IAppender consoleAppender =
            ////     new ConsoleAppender(simpleLayout);
            ////ILogger logger = new Logger(consoleAppender);

            ////logger.Error("Error parsing JSON.");
            ////logger.Info($"User {"Pesho"} successfully registered.");

            // Second example.
            ////var simpleLayout = new SimpleLayout();

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

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

            // Third one.
            ////var xmlLayout = new XmlLayout();
            ////var consoleAppender = new ConsoleAppender(xmlLayout);
            ////var logger = new Logger(consoleAppender);

            ////logger.Fatal("mscorlib.dll does not respond");
            ////logger.Critical("No connection string found in App.config");
        }
        static void Main(string[] args)
        {
            //ILayout simpleLayout = new SimpleLayout();
            //IAppender consoleAppender =
            //     new ConsoleAppender(simpleLayout);
            //ILogger logger = new Entities.Logger(consoleAppender);

            //logger.Error("3/26/2015 2:08:11 PM", "Error parsing JSON.");
            //logger.Info("3/26/2015 2:08:11 PM", "User Pesho successfully registered.");

            //var simpleLayout = new SimpleLayout();
            //var consoleAppender = new ConsoleAppender(simpleLayout);

            //var file = new LogFile();
            //var fileAppender = new FileAppender(simpleLayout);
            //fileAppender.File = file;

            //var logger = new Entities.Logger(consoleAppender, fileAppender);
            //logger.Error("3/26/2015 2:08:11 PM", "Error parsing JSON.");
            //logger.Info("3/26/2015 2:08:11 PM", "User Pesho successfully registered.");

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

            //logger.Fatal("3/31/2015 5:23:54 PM", "mscorlib.dll does not respond");
            //logger.Critical("3/31/2015 5:23:54 PM", "No connection string found in App.config");

            var simpleLayout    = new SimpleLayout();
            var consoleAppender = new ConsoleAppender(simpleLayout);

            consoleAppender.ReportLevel = ReportLevel.Error;

            var logger = new Entities.Logger(consoleAppender);

            logger.Info("3/31/2015 5:33:07 PM", "Everything seems fine");
            logger.Warn("3/31/2015 5:33:07 PM", "Warning: ping is too high - disconnect imminent");
            logger.Error("3/31/2015 5:33:07 PM", "Error parsing request");
            logger.Critical("3/31/2015 5:33:07 PM", "No connection string found in App.config");
            logger.Fatal("3/31/2015 5:33:07 PM", "mscorlib.dll does not respond");
        }