Logging: {AppData} not being expanded in FileLogListener configuration

Topics: Issues / bugs
Dec 12, 2014 at 1:30 AM
I'm configuring a FileLogListener in my App.config file:
  <configSections>
    <sectionGroup name="catel">
      <section name="logging" type="Catel.Logging.LoggingConfigurationSection, Catel.Core" />
    </sectionGroup>
  </configSections>

  <catel>
    <logging>
      <listeners>
        <listener type="Catel.Logging.FileLogListener" FilePath="{AppData}\Lexalutions\StateFundingApp\StateFundingApp.log" IgnoreCatelLogging="true"
                  IsDebugEnabled="false" IsInfoEnabled="true" IsWarningEnabled="true" IsErrorEnabled="true"/>
      </listeners>
    </logging>
  </catel>
I took this from the Catel documentation. But, when I run the app and try to log something, I get an IO error that the specified folder is not found. It's trying to create a folder named "{AppData}" in the EXE folder when it should have been using the User's AppData folder.

I was assuming {AppData} would get expanded by the FileLogListener. Was I mistaken? BTW: this folder already exists as the default location for customer data files.

Please let me know if you need additional info.

thanks,
randy
Dec 12, 2014 at 9:38 AM
I am checking out this code:

https://github.com/Catel/Catel/blob/1d8c425279c43ef8ccf0c74557adc9002c8b2451/src/Catel.Core/Catel.Core.Shared/Logging/Listeners/FileLogListener.cs#L78

When setting the FilePath, it should call DetermineFilePath. It should replace AppData on line 192. I also remember that I wrote unit tests around this. Let me think about this.
Dec 12, 2014 at 9:40 AM
Can you write a failing unit test, then I can investigate further. Thanks!
Dec 12, 2014 at 11:31 PM
Thanks for the reply!

I'm on Catel version 3.9. I looked at the FileLogListener code in Reflector and I'm not seeing the DetermineFilePath routine nor it's call in the FilePath setter.

I suspect this is in version 4.0, but I'm not ready to move to that version at this time as we are close to a delivery on this application. There are way too many breaking changes and the async changes are just not necessary for this particular application.

thanks,
randy
Dec 13, 2014 at 9:10 AM
Yes, this is 4.0. I recommend that you look to the 3.9 docs if you are still on 3.9:

https://catelproject.atlassian.net/wiki/display/CTL39/Catel+documentation+Home