.netwindowslogginglog4netspecial-folders

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


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?


Solution

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

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