For testing purposes, try changing the location of where your file writes to:
f.File = "c:\\text.log";
Also verify that you can write to that file using normal code:
using (StreamWriter sw = new StreamWriter("c:\\text.txt"))
{
sw.WriteLine("Hello World");
}
----- Original Message ----
From: Ori - Gmail <[EMAIL PROTECTED]>
To: [email protected]
Sent: Tuesday, October 17, 2006 4:49:17 AM
Subject: what's wrong with my application?
<!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal,
div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt;
font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue;
text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed
{color:purple; text-decoration:underline;} span.EmailStyle17 {
font-family:Arial; color:windowtext;} _filtered { margin:1.0in 1.25in 1.0in
1.25in;} div.Section1 {} --> 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");
}
}
}