E
Enter The
I'm trying to learn the use log4net.
When I set the configuration in the attached class, I get a load of
INFO messages from a component that I have installed (Nesper).
Why does my code affect Nesper's logging? i only want the logging to
log stuff that I tell it to. but for some reason the configuration
affects the logging of an external component over which I have no
control.
i.e. I only want it to log stuff when I call MyLogger.Debug("Helllo
World");
And to ignore all the stuff that's already in place.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;
using log4net.Config;
namespace WindowsFormsApplication1
{
class MyLogger
{
//http://www.csharptocsharp.com/log4net-configuration-for-
rockin-loggin-part-2
private static log4net.ILog llog;
static MyLogger()
{
Console.WriteLine("Making static logger class");
/*
System.IO.FileInfo fi = new System.IO.FileInfo("c:\\Users\
\hal\\Documents\\Visual Studio 2008\\Projects\
\WindowsFormsApplication1\\WindowsFormsApplication1\
\WindowsFormsApplication1.exe.cfg");
fi.Open(System.IO.FileMode.Open);
DOMConfigurator.Configure(
fi
);
*/
log4net.Appender.RollingFileAppender rfa = new
log4net.Appender.RollingFileAppender();
rfa.AppendToFile = true;
rfa.RollingStyle =
log4net.Appender.RollingFileAppender.RollingMode.Size;
rfa.MaxSizeRollBackups = 10;
rfa.MaximumFileSize = "1MB";
rfa.StaticLogFileName = true;
rfa.Layout = new log4net.Layout.PatternLayout(@"{%level}
%date{MM/dd HH:mm:ss} - %message%newline");
rfa.File="c:\\log.log";
rfa.ActivateOptions();
;
log4net.Config.BasicConfigurator.Configure(rfa);
llog.Logger.Repository.
llog = log4net.LogManager.GetLogger(typeof(Form1));
//log4net.Filter.
llog.Debug("Logger hello world");
}
public static void Debug(string s){
llog.Debug(s);
}
}
}
When I set the configuration in the attached class, I get a load of
INFO messages from a component that I have installed (Nesper).
Why does my code affect Nesper's logging? i only want the logging to
log stuff that I tell it to. but for some reason the configuration
affects the logging of an external component over which I have no
control.
i.e. I only want it to log stuff when I call MyLogger.Debug("Helllo
World");
And to ignore all the stuff that's already in place.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;
using log4net.Config;
namespace WindowsFormsApplication1
{
class MyLogger
{
//http://www.csharptocsharp.com/log4net-configuration-for-
rockin-loggin-part-2
private static log4net.ILog llog;
static MyLogger()
{
Console.WriteLine("Making static logger class");
/*
System.IO.FileInfo fi = new System.IO.FileInfo("c:\\Users\
\hal\\Documents\\Visual Studio 2008\\Projects\
\WindowsFormsApplication1\\WindowsFormsApplication1\
\WindowsFormsApplication1.exe.cfg");
fi.Open(System.IO.FileMode.Open);
DOMConfigurator.Configure(
fi
);
*/
log4net.Appender.RollingFileAppender rfa = new
log4net.Appender.RollingFileAppender();
rfa.AppendToFile = true;
rfa.RollingStyle =
log4net.Appender.RollingFileAppender.RollingMode.Size;
rfa.MaxSizeRollBackups = 10;
rfa.MaximumFileSize = "1MB";
rfa.StaticLogFileName = true;
rfa.Layout = new log4net.Layout.PatternLayout(@"{%level}
%date{MM/dd HH:mm:ss} - %message%newline");
rfa.File="c:\\log.log";
rfa.ActivateOptions();
;
log4net.Config.BasicConfigurator.Configure(rfa);
llog.Logger.Repository.
llog = log4net.LogManager.GetLogger(typeof(Form1));
//log4net.Filter.
llog.Debug("Logger hello world");
}
public static void Debug(string s){
llog.Debug(s);
}
}
}