You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2015/08/09 02:44:17 UTC

logging-log4j2 git commit: [LOG4J2-1090] Add Core Configurator APIs to change a logger's level.

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 44943fd5d -> 62b47cb51


[LOG4J2-1090] Add Core Configurator APIs to change a logger's level.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/62b47cb5
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/62b47cb5
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/62b47cb5

Branch: refs/heads/master
Commit: 62b47cb51fac740b5abec501a4436f7875a98e9b
Parents: 44943fd
Author: ggregory <gg...@apache.org>
Authored: Sat Aug 8 17:44:15 2015 -0700
Committer: ggregory <gg...@apache.org>
Committed: Sat Aug 8 17:44:15 2015 -0700

----------------------------------------------------------------------
 src/site/xdoc/faq.xml | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/62b47cb5/src/site/xdoc/faq.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/faq.xml b/src/site/xdoc/faq.xml
index 37bea76..44359cb 100644
--- a/src/site/xdoc/faq.xml
+++ b/src/site/xdoc/faq.xml
@@ -34,6 +34,7 @@
       <li><a href="#config_sep_appender_level">How do I send log messages with different levels to different appenders?</a></li>
       <li><a href="#troubleshooting">How do I debug my configuration?</a></li>
       <li><a href="#separate_log_files">How do I dynamically write to separate log files?</a></li>
+      <li><a href="#reconfig_level_from_code">How do I set a logger's level programmatically?</a></li>      
       <!--
       <li><a href="#custom_plugin">How do I get log4j2 to recognize my custom plugin?</a></li>
       -->
@@ -226,6 +227,17 @@ Configurator.shutdown(context);</pre>
   </Routes>
 </Routing>]]></pre>
 
+        <a name="reconfig_level_from_code" />
+        <h4>How do I set a logger's level programmatically?</h4>
+        <p>You can set a logger's level with the class Configurator from Core module.
+         Be aware that the Configuration class is not part of the public API.</p>
+        <pre class="prettyprint linenums">// org.apache.logging.log4j.core.config.Configurator;
+
+Configurator.setLevel("com.example.Foo", Level.DEBUG);
+
+// You can also set the root logger:
+Configurator.setRootLevel(Level.DEBUG);
+</pre>
 
         <!--
 		<a name="custom_plugin" />