title: Java command line tool, verbose output flag
body: <p>I am developing a Java-based command-line tool. I want to leverage <em>slf4j</em>'s logging abstraction.</p>
  
  <p>When the application is regularly invoked</p>
  
  <pre><code>java -jar myapp.jar someparameter
  </code></pre>
  
  <p>then the application shall give "plain" CLI output on <code>stdout</code> such as:</p>
  
  <pre><code>/some/file1
  /some/file2
  </code></pre>
  
  <p><br>
  When instead the application is invoked with an additional  <code>--verbose</code> flag / option</p>
  
  <pre><code>java -jar myapp.jar --verbose someparameter
  </code></pre>
  
  <p>then the application shall give more advanced logging:</p>
  
  <pre><code>16:06:09.031 [main] DEBUG com.example.MyApp - Starting application.
  16:06:09.031 [main] DEBUG com.example.MyApp - Entering directory /some/.
  16:06:09.046 [main] INFO  com.example.MyApp - /some/file1
  16:06:09.046 [main] INFO  com.example.MyApp - /some/file2
  </code></pre>
  
  <p><br>
  While it is is easy to determine whether <code>--verbose</code> was provided (e.g. by using the <em>jCommander</em> CLI library), <em>slf4j</em> does not seem to allow setting the <em>root logger</em> level during runtime, nor does <em>slf4j</em> allow to change the log entry pattern layout during runtime.</p>
  
  <ul>
  <li>Which options for modifying both log level and log entry pattern layout <em>during runtime</em> (or at least <em>during startup</em>) am I left with?</li>
  <li>Shall I refrain from my noble stance of using the <em>slf4j</em> abstraction layer and instead use the actual underlying logging implementation (be it <em>logback</em>, <em>slf4j2</em>, ...)</li>
  <li>How did other Java-based command-line tools solve this challenge?</li>
  </ul>