コード例 #1
0
        public MainWindow()
        {
            this.InitializeComponent();

            var simpleFormatter = new SimpleFormatter();

            ListBox listBox = (ListBox) this.FindName("ListBox");

            var listBoxAppender = new ListBoxAppender(simpleFormatter, listBox);
            var fileAppender = new FileAppender(simpleFormatter, "simple.txt");
            this.logger = new Logger(fileAppender, listBoxAppender);

            this.KeyDown += this.MainWindow_KeyDown;
        }
コード例 #2
0
        public static void Main()
        {
            var simpleFormatter = new SimpleFormatter();
            var xmlFormatter = new XmlFormatter();
            // Create own formatter
            var jsonFormatter = new JsonFormatter();

            var fileAppender = new FileAppender(jsonFormatter, "log.txt");
            var consoleAppender = new ConsoleAppender(xmlFormatter);
            // Create own appender
            var sqlAppender = new SqlAppender(jsonFormatter);

            Logger logger = new Logger(consoleAppender, fileAppender);

            logger.Critical("Out of memory");
            logger.Info("Unused local variable 'name'");

            fileAppender.Close();
        }