I wanted to write logs in two different files using log4net, one in the global log file while the other for particular user file, for this I set the param in appender like this
<param name="File" value="D:\Projects\Web\Web\Services\Log\%property{LogFileName}" />
And defined a function like this
public void AddInfo(string message)
{
log4net.GlobalContext.Properties["LogFileName"] = this.UserId + ".txt";
log4net.Config.XmlConfigurator.Configure();
Logger.Info(message);
log4net.GlobalContext.Properties["LogFileName"] = "ServiceLog.txt";
log4net.Config.XmlConfigurator.Configure();
Logger.Info(message);
}
This all is working find, every log is written in two different files successfully.
My concern is, is the approach correct if we think about performance?
For each and every log it will configure log4net two times, will it affect performance negatively?