Пример #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter a file name");
            var filename      = Console.ReadLine();
            var filelogwriter = new FileLogWriter(filename);

            filelogwriter.LogInfo("Message for Info");
            filelogwriter.LogWarning("Message for Warning");
            filelogwriter.LogError("Message for Error");

            var consolelogwriter = new ConsoleLogWriter();

            consolelogwriter.LogInfo("Message for Info");
            consolelogwriter.LogWarning("Message for Warning");
            consolelogwriter.LogError("Message for Error");
            Console.WriteLine("");
            var miltipleogriter = new MiltipleLogWriter(consolelogwriter, filelogwriter);

            miltipleogriter.LogInfo("Message for Info");
            miltipleogriter.LogWarning("Message for Warning");
            miltipleogriter.LogError("Message for Error");

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
Пример #2
0
        static void Main(string[] args)
        {
            var consoleLogWriter  = new ConsoleLogWriter();
            var fileLogWriter     = new FileLogWriter();
            var multipleLogWriter = new MultipleLogWriter(new ILogerWriter[] { consoleLogWriter, fileLogWriter });

            consoleLogWriter.LogInfo("LogInfo");
            consoleLogWriter.LogWarning("LogWarning");
            consoleLogWriter.LogError("LogError");

            fileLogWriter.LogInfo("LogInfo");
            fileLogWriter.LogWarning("LogWarning");
            fileLogWriter.LogError("LogError");
        }
Пример #3
0
        static void Main(string[] args)
        {
            var fileLogWriter = new FileLogWriter("log1.log");

            fileLogWriter.LogWarning("Warning!");

            var consoleLogWriter = new ConsoleLogWriter();

            consoleLogWriter.LogInfo("Information.");

            var multipleLogWriter = new MultipleLogWriter(
                new ConsoleLogWriter(),
                new ConsoleLogWriter(),
                new ConsoleLogWriter(),
                new ConsoleLogWriter(),
                new FileLogWriter("log1.log"),
                new FileLogWriter("log2.log")
                );

            multipleLogWriter.LogError("Some Error!");

            Console.ReadKey();
        }