title: How to change the Logging settings in Web.config on Windows Azure for all Web Roles?
body: <p>ASP.NET application on Windows Azure.
  The application is scalable and runs on 1..N Web role instances.</p>
  
  <p>We have log4net write to the Windows Event log and have Windows Azure Diagnostics consolidate to Azure storage.</p>
  
  <p>At the moment the log4net configuration is stored in Web.config.</p>
  
  <p>For application logging we have the following requirements:</p>
  
  <ol>
  <li><p>Ability to specify a list of one or more types of log entries to write to the log</p></li>
  <li><p>Ability to specify the level at which log entries are written to the log (per log entry)</p></li>
  </ol>
  
  <p>The first requirement is met by the loggers naming convention. Loggers define a hierarchy and give the programmer run-time control on which statements are printed or not.</p>
  
  <pre><code>ILog log = LogManager.GetLogger("Davanti.WMS.Core.Logic.Inventory");
  </code></pre>
  
  <p>The second requirement can be achieved by using the logging levels DEBUG, INFO, WARN, ERROR and FATAL.</p>
  
  <pre><code>log.Debug("Process has completed");
  </code></pre>
  
  <p><strong>Current situation</strong></p>
  
  <p>We have only one log4net configuration in the Web.config file that redirects to the Windows Event log. And control <strong>what</strong> to log (see requirement 1) and the <strong>depth</strong> (level) to log (see requirement 2) in application code base on settings stored in the central database.</p>
  
  <p>This approach will have a negative effect on application performance because the application itself will have to check if certain messages needs to be logged or not (synchronously) instead on the logging framework (asynchronously).</p>
  
  <p><strong>Required situation</strong></p>
  
  <p>We want to control what to log and logging level from the log4net settings. The problem is that we have to apply the log4net settings on <strong>all</strong> Windows Azure Web role instances. What is the best approach for this?</p>
  
  <p>Also we would like to have a more user friendly way to enable logging (for example by a consultant). What are the possibilities?</p>
  
  <p>Like for example using the Enterprise Library Configuration editor.
  A visual representation of the confoguration settings.
  <a href="http://img651.imageshack.us/img651/930/logging.jpg" rel="nofollow">http://img651.imageshack.us/img651/930/logging.jpg</a></p>