This is an automated email from the ASF dual-hosted git repository. swebb2066 pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/logging-log4cxx-site.git
commit 5b3befc9fbed82518765c5373c690f24215edfa0 Author: Stephen Webb <[email protected]> AuthorDate: Thu Aug 21 17:37:29 2025 +1000 Improve Configuration Samples --- 1.6.0/auto-configured_8xml-example.html | 1 + 1.6.0/configuration-samples.html | 9 +++++++-- 1.6.0/internal-debugging.html | 15 ++++++++------- 1.6.0/quick-start.html | 3 ++- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/1.6.0/auto-configured_8xml-example.html b/1.6.0/auto-configured_8xml-example.html index 1984aee4..9cd4dfac 100644 --- a/1.6.0/auto-configured_8xml-example.html +++ b/1.6.0/auto-configured_8xml-example.html @@ -108,6 +108,7 @@ $(function(){initNavTree('auto-configured_8xml-example.html','',''); }); <div class="headertitle"><div class="title">auto-configured.xml</div></div> </div><!--header--> <div class="contents"> +<p>This is the configuration file used by the <a class="el" href="auto-configured_8cpp-example.html">auto-configured.cpp</a> example.</p> <div class="fragment"><div class="line"><span class="lineno"> 1</span><?<span class="keyword">xml</span> <span class="keyword">version</span>=<span class="stringliteral">"1.0"</span> <span class="keyword">encoding</span>=<span class="stringliteral">"UTF-8"</span> ?></div> <div class="line"><span class="lineno"> 2</span><<span class="keywordtype">log4j:configuration</span> <span class="keyword">xmlns:log4j</span>=<span class="stringliteral">"http://jakarta.apache.org/log4j/"</span>></div> <div class="line"><span class="lineno"> 3</span> <<span class="keywordtype">appender</span> <span class="keyword">name</span>=<span class="stringliteral">"ConsoleAppender"</span> <span class="keyword">class</span>=<span class="stringliteral">"org.apache.log4j.ConsoleAppender"</span>></div> diff --git a/1.6.0/configuration-samples.html b/1.6.0/configuration-samples.html index a2bc0dc2..dddbe6d0 100644 --- a/1.6.0/configuration-samples.html +++ b/1.6.0/configuration-samples.html @@ -117,11 +117,12 @@ Default Initialization Behaviour</h1> <p>To use automatic configuration with a non-standard file name create and use your own wrapper for <a class="el" href="classlog4cxx_1_1LogManager.html#ac1c64a1bd2c15d3018f3a022a059074e">getLogger</a>. A full example can be seen in the <a class="el" href="com_2foo_2config4_8cpp-example.html">com/foo/config4.cpp</a> file.</p> <h1 class="doxsection"><a class="anchor" id="runtime-property-values"></a> Runtime Property Values</h1> -<p>The value of an enviroment variable can be used in a property value. Instances of the form <b>${VarName}</b> will be replaced with the value of the environment variable <b>VarName</b>.</p> +<p>The value of an enviroment variable can be used in a property value. Instances of the form <b>${VarName}</b> will be replaced with the value of the environment variable <b>VarName</b>. A warning message is output to stderr if the closing brace is absent.</p> <p>As of version 1.6, Log4cxx allows you to define configuration variables programmatically. Extra key value pairs may be added prior to loading a configuration file using code such as: </p><div class="fragment"><div class="line"><span class="keyword">auto</span>& props = <a class="code hl_function" href="classlog4cxx_1_1spi_1_1Configurator.html#a34fef1dc93e7b44cfb601f30100a3727">log4cxx::spi::Configurator::properties</a>();</div> <div class="line">props.setProperty(LOG4CXX_STR(<span class="stringliteral">"VarName"</span>), LOG4CXX_STR(<span class="stringliteral">"my-varname-value"</span>));</div> <div class="ttc" id="aclasslog4cxx_1_1spi_1_1Configurator_html_a34fef1dc93e7b44cfb601f30100a3727"><div class="ttname"><a href="classlog4cxx_1_1spi_1_1Configurator.html#a34fef1dc93e7b44cfb601f30100a3727">log4cxx::spi::Configurator::properties</a></div><div class="ttdeci">static helpers::Properties & properties()</div><div class="ttdoc">The key value pairs used when expanding ${varname} instances in a configuration file.</div></div> </div><!-- fragment --><p>Also available in Log4cxx 1.6 are variables that hold the currently executing program file path and the <a href="https://en.cppreference.com/w/cpp/filesystem/path.html">std::filesystem::path</a> decomposition of the currently executing program file path. These allow you to specify a log file location relative to the executable location, not just the current working directory. The variable names are <a class="el" href="classlog4cxx_1_1spi_1_1Configurator.html#a34 [...] +<p>To check the corrent values are used when your configuration file is loaded, use <a href="internal-debugging.html#internal-debugging">Log4cxx internal debugging</a>.</p> <h1 class="doxsection"><a class="anchor" id="properties"></a> Properties Files</h1> <p>Log4cxx may be configured using a Java properties (key=value) type file.</p> @@ -162,12 +163,15 @@ Properties Files</h1> <div class="line">#log4j.logger.MockArm=DEBUG</div> <div class="line">#log4j.logger.MockURController=DEBUG</div> <div class="line">#log4j.logger.URCommunicationPort=DEBUG</div> +<div class="line"> </div> +<div class="line"># Log4cxx internal debugging</div> +<div class="line">#log4j.debug=true</div> </div><!-- fragment --><h1 class="doxsection"><a class="anchor" id="xmlfiles"></a> XML Files</h1> <p>Another way of configuring Log4cxx is with an XML file. The following are some XML configuration examples.</p> <h2 class="doxsection"><a class="anchor" id="xml-example-1"></a> XML Example 1</h2> -<p>This simple example simply writes messages to stdout. If you want to send messages to stderr instead, simply change the 'Target' value to <span class="tt">System.err</span>.</p> +<p>This simple example writes messages to stdout. If you want to send messages to stderr instead, change the 'Target' value to <span class="tt">System.err</span>.</p> <div class="fragment"><div class="line"><?<span class="keyword">xml</span> <span class="keyword">version</span>=<span class="stringliteral">"1.0"</span> <span class="keyword">encoding</span>=<span class="stringliteral">"UTF-8"</span> ?></div> <div class="line"><<span class="keywordtype">log4j:configuration</span> <span class="keyword">xmlns:log4j</span>=<span class="stringliteral">"http://jakarta.apache.org/log4j/"</span>></div> <div class="line"> </div> @@ -236,6 +240,7 @@ XML Example 3</h2> </div><!-- fragment --><p>For this configuration, we have set any logger that is at the <span class="tt">com</span> level or below to be debug. However, we have also set the logger <span class="tt">com.example</span> to have a more verbose <span class="tt">trace</span> level to see more information from that particular logger. The log file will be created in a program data directory where the path uses the program vendor and product name.</p> <p>The following Log4cxx 1.6 configuration file uses the variables added in the <a class="el" href="com_2foo_2config4_8cpp-example.html">com/foo/config4.cpp</a> example.</p> <div class="fragment"><div class="line"><?<span class="keyword">xml</span> <span class="keyword">version</span>=<span class="stringliteral">"1.0"</span> <span class="keyword">encoding</span>=<span class="stringliteral">"UTF-8"</span> ?></div> +<div class="line"><span class="comment"><!--log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true" --></span></div> <div class="line"><<span class="keywordtype">log4j:configuration</span> <span class="keyword">xmlns:log4j</span>=<span class="stringliteral">"http://jakarta.apache.org/log4j/"</span>></div> <div class="line"> </div> <div class="line"> <<span class="keywordtype">appender</span> <span class="keyword">name</span>=<span class="stringliteral">"ConsoleAppender"</span> <span class="keyword">class</span>=<span class="stringliteral">"org.apache.log4j.ConsoleAppender"</span>></div> diff --git a/1.6.0/internal-debugging.html b/1.6.0/internal-debugging.html index 6e5b87ff..27e6d392 100644 --- a/1.6.0/internal-debugging.html +++ b/1.6.0/internal-debugging.html @@ -109,14 +109,15 @@ $(function(){initNavTree('internal-debugging.html','',''); }); </div><!--header--> <div class="contents"> <div class="textblock"><p><a class="anchor" id="md_src_2site_2markdown_2internal-debugging"></a></p> -<p>Because Log4cxx is a logging library, we can't use it to output errors from the library itself. There are several ways to activate internal logging:</p> -<ol type="1"> -<li>Configure the library directly by calling the <a class="el" href="classlog4cxx_1_1helpers_1_1LogLog.html#a4a9ff479866ace05c88c8a167ff2c2fa">LogLog::setInternalDebugging</a> method</li> -<li>If using a properties file, set the value <span class="tt">log4j.debug=true</span> in your configuration file</li> -<li>If using an XML file, set the attribute <span class="tt">internalDebug=true</span> in the root node</li> -<li>From the environment: <span class="tt">LOG4CXX_DEBUG=true</span></li> +<p>Because Log4cxx is a logging library, we can't use it to output errors from the library itself.</p> +<p>There are several ways to activate internal debug logging:</p><ol type="1"> +<li>Setting the environment variable <code>LOG4CXX_DEBUG</code> to the value <code>true</code></li> +<li>If using a properties file, add the line <code>log4j.debug=true</code> to your file</li> +<li>If using an XML file, add the <code>debug="true"</code> attribute in the <code>log4j.configuration</code> element</li> +<li>Configure the library programmatically by calling <a class="el" href="classlog4cxx_1_1helpers_1_1LogLog.html#a4a9ff479866ace05c88c8a167ff2c2fa">LogLog::setInternalDebugging</a></li> </ol> -<p>All error and warning messages are sent to stderr. </p> +<p>To disable all messages, including error and warning messages, call <a class="el" href="classlog4cxx_1_1helpers_1_1LogLog.html#afb245a915971f9daac986b6115390083">LogLog::setQuietMode(true)</a>.</p> +<p>All Log4cxx internal logging messages are sent to stderr, with each line prefixed by <code><a class="el" href="namespacelog4cxx.html">log4cxx</a>:</code>. </p> </div></div><!-- contents --> </div><!-- PageDoc --> </div><!-- doc-content --> diff --git a/1.6.0/quick-start.html b/1.6.0/quick-start.html index 80cb3489..b468c7ba 100644 --- a/1.6.0/quick-start.html +++ b/1.6.0/quick-start.html @@ -288,7 +288,8 @@ Runtime Configuration</h1> <div class="line">DEBUG [12345] (bar.cpp:8) - Did it again!</div> <div class="line"> INFO [12345] (MyApp.cpp:11) - Exiting application.</div> </div><!-- fragment --><p>In addition, as the root logger has been allocated a second appender, output will also be directed to the <em>example.log</em> file. This file will be rolled over when it reaches 100KB. When roll-over occurs, the old version of <em>example.log</em> is automatically moved to <em>example.log.1</em>.</p> -<p>Note that to obtain these different logging behaviors we did not need to recompile code. We could just as easily have logged to a UNIX Syslog daemon, redirected all <em>com.foo</em> output to an NT Event logger, or forwarded logging events to a remote Log4cxx server, which would log according to local server policy, for example by forwarding the log event to a second Log4cxx server. </p> +<p>Note that to obtain these different logging behaviors we did not need to recompile code. We could just as easily have logged to a UNIX Syslog daemon, redirected all <em>com.foo</em> output to an NT Event logger, or forwarded logging events to a remote Log4cxx server, which would log according to local server policy, for example by forwarding the log event to a second Log4cxx server.</p> +<p>For more runtime configuration examples, see <a href="configuration-samples.html">Configuration Samples</a>. </p> </div></div><!-- contents --> </div><!-- PageDoc --> </div><!-- doc-content -->
