logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicko Cadell" <ni...@neoworks.com>
Subject RE: what's wrong with my application?
Date Sat, 28 Oct 2006 22:08:00 GMT
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:oorrii@gmail.com] 
> Sent: 17 October 2006 09:49
> To: log4net-user@logging.apache.org
> 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");            
> 
>         }
> 
>     }
> 
> }
> 
> 

Mime
View raw message