Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bob Banks 16 posts 36 karma points
    Mar 27, 2014 @ 17:32
    Bob Banks
    0

    Configure log4net in web.config instead of separate file?

    Using v6.1.6, has anyone successfully configured log4net via web.config section instead of using the /config/log4net.config file?  My goal is to use web.config transformations.  

    I've moved the section into web.config and removed the "log4net.Config" appSetting.  After turning on log4net debugging, I've confirmed it doesn't load any config at all.  

    I've noticed that Umbraco.Web.UI takes the unusual approach of configuring log4net via an assembly attribute in AssemblyInfo.cs.  According to the log4net docs tho, this should still pick up an application-specific config file (web.config).

     

     

  • Jan Vanuytrecht 32 posts 80 karma points
    Apr 10, 2015 @ 10:53
    Jan Vanuytrecht
    0

    Hi Bob,

     

    We ran into the same issue.

     

    The solution is to set the appsetting "log4net.config" to this:

    <add key="log4net.Config" value="web.config" />

     

    And change  the element:  <log4net configSource="config\log4net.config" />

    to to your liking. 

    We used these transformations:

     <add key="log4net.Config" value="web.config" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
    <log4net xdt:Transform="Replace">    
    ... your entire new log4net setup ...
    </log4net>
    
Please Sign in or register to post replies

Write your reply to:

Draft