title: How to change root logging level programmatically for logback
body: <p>I have the following logback.xml file:</p>
  
  <pre><code>&lt;configuration debug="true"&gt; 
  
  &lt;appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"&gt; 
  &lt;encoder&gt;
    &lt;pattern&gt;%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n&lt;/pattern&gt;
  &lt;/encoder&gt;
  &lt;/appender&gt;
  
  &lt;root level="debug"&gt;
    &lt;appender-ref ref="STDOUT" /&gt;
  &lt;/root&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Now, upon the occurrence of a specific event, I want to programmatically change the level of the root logger from <em>debug</em> to <em>error</em>. I can't use variable substitution, it is mandatory that I do this within the code.</p>
  
  <p>How can it be done ? Thanks.</p>