Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 299
Jader Dias Avatar asked Jul 26 '10 19:07

Jader Dias


2 Answers

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

<file value="${LOCALAPPDATA}\GojiSoft\GojiLog\log.txt" />
like image 187
Tim Lloyd Avatar answered Nov 18 '22 05:11

Tim Lloyd


Resurrecting an old thread here, but I encountered the same issue and thought I'd share.

${PROGRAMDATA}, as discussed in the comment thread of the other answer, didn't work for me (same as for OP). However, I saw a comment somewhere about it being case sensitive. Tried ${ProgramData} and sure enough, it worked fine.

like image 21
teleute00 Avatar answered Nov 18 '22 04:11

teleute00