XML : Setting a variable in XML document from Word Add-in C# code

I am using log4net in a Word add-in to create log files. The add-in will be deployed to multiple users so the folder path found in the App.config file will need to change for each user. In the add-in initialization I call a function that gets the User Profile folder and sets that as a variable (I believe) for the app.config file.

  public void GetCurrentUser()          {              string user = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);              log4net.GlobalContext.Properties["UserFolder"] = user;              log4net.Config.XmlConfigurator.Configure();          }    

and my app.config xml file looks like this:

  <log4net debug="true">        <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">          <file type="log4net.Util.PatternString" value="%Property{user}\AppData\Local\Temp\logfile.txt" />           <appendToFile value="true" />          <rollingStyle value="Size" />  ...    

but it is not writing to the log when I run the add-in. Can someone please point me in the right direction? Thank you

No comments:

Post a Comment