I wrote a very simple c# application to try writing to log file, and it doesn’t work. The log stays empty.

Can someone please tell me why?

 

The application code:

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using log4net;

using log4net.Appender;

 

namespace Log4netTry

{

    public partial class Form1 : Form

    {       

        static ILog log;

        public Form1()

        {

            InitializeComponent();

            FileAppender f = new FileAppender();

            f.ImmediateFlush = true;           

            f.File = "text.log";

            f.ActivateOptions();

            log4net.Config.BasicConfigurator.Configure(f);

            log = LogManager.GetLogger("MyLog");                       

        }

 

        private void Form1_Load(object sender, EventArgs e)

        {

            log.Error("Moony");

            log.Debug("ddsdsds");           

        }

    }

}

Reply via email to