views:

79

answers:

1

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?

+3  A: 

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

<file value="${LOCALAPPDATA}\GojiSoft\GojiLog\log.txt" />
chibacity
is this syntax log4net specific? will it work in other settings?
Jader Dias
@Jader This is specifically implemented in log4net.
chibacity
While your example works fine, ${PROGRAMDATA} doesn't work. But I think it's some kind of permission problem.
Jader Dias
@Jader The owner of the process needs to have permission to write to the specified location.
chibacity