The FileAppender needs a layout object to format the log message for output.
Before f.ActivateOptions(); add the following: f.Layout = new log4net.Layout.PatternLayout(); // use DefaultConversionPattern ((log4net.Core.IOptionHandler)f.Layout).ActivateOptions(); Cheers, Nicko > -----Original Message----- > From: Ori - Gmail [mailto:[EMAIL PROTECTED] > Sent: 17 October 2006 09:49 > To: [email protected] > Subject: what's wrong with my application? > > 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"); > > } > > } > > } > >
