C# how to specify the appData file path in the app.config file

I don't believe that you can do what you want, there is a method for custom parsing areas of the app.config file so that you could add your own token that you could replace with the correct value, but I don't see how that would work inside the log4net section.

However, everything that is set up for log4net inside the config can also be set in code. I think you're best option would be to set the property for the appender in code just after application start.


Ahh, never mind a quick search has revealed my ignorance. From here and here it appears that something similar to this:

<file value="${APPDATA}\log-file.txt" />

Will do what you want. I haven't tested this myself, so I'll leave my first answer up too - but I'd be interested to know if you have any luck with it.

Tags:

C#

App Config