Hi all new to log4net. My boss is forcing me to use it and I have an openmind to it. However i m struggling to find a configuration version that allows me to log to the special folders. I have found some solutions but I cannot seem to make them work.
I can do it programmatically but defeats the point. I have seen a post of using %envFolderPath but apparently is not available in the latest version but only in their current code.
Can somebody post a console demo logging to a special folder using config file? I would really appreciate it.
My c# code that I want to throw away is this
public void ExampleLog
{
XmlConfigurator.Configure();
var fileName = GetFileName();
var appender = new log4net.Appender.RollingFileAppender
{
Layout = new log4net.Layout.PatternLayout("%d - %m%n"),
File = fileName,
MaxSizeRollBackups = 10,
MaximumFileSize = "100MB",
AppendToFile = true,
Threshold = Level.Debug
};
appender.ActivateOptions();
BasicConfigurator.Configure(appender);
}
private static string GetFileName()
{
const string subPath = "MySubFolder";
var path = String.Format(@"{0}\{1}", Environment.GetFolderPath (Environment.SpecialFolder.CommonApplicationData), subPath);
const string logName = "Log.txt";
return Path.Combine(path, logName);
}
Any suggestion how to achieve the same via config file?
thanks for your time!