How to specify log file path using folder locations in Windows with log4net xml configurator?

Jader Dias picture Jader Dias · Jul 26, 2010 · Viewed 14.7k times · Source

In my app.config I put

<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
  <file value="%programdata%/log-file.txt"/>

but it didn't work. Any ideas?

Answer

Tim Lloyd picture Tim Lloyd · Jul 26, 2010

The log4net syntax for expanding environment variables is "${Variable}" e.g.

<file value="${LOCALAPPDATA}\GojiSoft\GojiLog\log.txt" />