I have a DLL project in my solution responsible for logging events in my other projects. Right now I'm facing the problem on where to save the log file. I would like to save it in user app data (c:\users\\AppData\Local\.....)
How can I access that location in log4net.config file?
I have this in my dll project:
static Log()
{
log4net.GlobalContext.Properties["LogFileName"] = @"d:\fileRelease2"; //log file path
#if DEBUG
log4net.GlobalContext.Properties["LogFileName"] = @"d:\fileDebug2"; //log file path
#endif
FileInfo configFileInfo = new FileInfo("log4net.config");
log4net.Config.XmlConfigurator.ConfigureAndWatch(configFileInfo);
log = LogManager.GetLogger(typeof(Log));
}
Thanks in advance.
Regards,
===========EDIT 2==========
I've managed to put my log4net.config like this:
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="DEBUG" />
<levelMax value="OFF" />
</filter>
<param name="AppendToFile" value="true"/>
<file value="${AppData}\AppName\Logs\log" />
<staticLogFileName value="false"/>
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value=" yyyy-MM-dd".txt""/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger: %message%newline"/>
</layout>
</appender>
The problem I'm facing now is that in the IDE (VS2013 ultimate) the folder is created. When I install the application (using a visual studio project installer) the folder/file is not created.
If I start the application with admin privileges it creates the folder/file...
Any ideas why?