Christoph Brückmann
Christoph Brückmann

Reputation: 1373

Define variables inside app.config

Is it possible to define variables inside the app.config file?

Maybe like that:

<xsl:variable name="folder">
  C:\Data\Log\
</xsl:variable>

... and use it in the app.config in this way:

<file value="$folder\ErrorLog.txt" />

I have some different folders inside my app.config and won't change every path one by one.

Upvotes: 0

Views: 2423

Answers (2)

KMoraz
KMoraz

Reputation: 14164

You can define LogBaseDir as an environment variable and consume it in the app.config:

<appender name="RollingFileError" type="log4net.Appender.RollingFileAppender">
  <file value="${LogBaseDir}\ErrorLog.txt" />
  <!-- ... -->
</appender>

Upvotes: 0

Joe L.
Joe L.

Reputation: 1908

You can right-click on the Project in Visual Studio, and select Properties. Then go to Settings to add settings of different data types (eg. string) there.

Also, if you're looking for a log4net-specific solution, this question/answer may help: stackoverflow.com/questions/1535736

Upvotes: 1

Related Questions