This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch asf-staging
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx-site.git
The following commit(s) were added to refs/heads/asf-staging by this push:
new 6305ee76 Update 1.2.0 site
6305ee76 is described below
commit 6305ee76c1c4cd1d8eb0ecf3bc61e5c1d7465808
Author: Stephen Webb <[email protected]>
AuthorDate: Tue Jul 25 15:19:48 2023 +1000
Update 1.2.0 site
---
1.2.0/{usage.html => concepts.html} | 10 +-
1.2.0/concepts_8md.html | 113 ++++++++++++
1.2.0/quick-start.html | 331 ++++++++++++++++++++++++++++++++++++
3 files changed, 449 insertions(+), 5 deletions(-)
diff --git a/1.2.0/usage.html b/1.2.0/concepts.html
similarity index 99%
rename from 1.2.0/usage.html
rename to 1.2.0/concepts.html
index dc728a1f..79e6740d 100644
--- a/1.2.0/usage.html
+++ b/1.2.0/concepts.html
@@ -26,7 +26,7 @@
<tbody>
<tr id="projectrow">
<td id="projectalign">
- <div id="projectname">Apache Log4cxx<span id="projectnumber"> Version
1.1.0</span>
+ <div id="projectname">Apache Log4cxx<span id="projectnumber"> Version
1.2.0</span>
</div>
</td>
</tr>
@@ -64,7 +64,7 @@ $(function() {
</div>
<script type="text/javascript">
/* @license
magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt
MIT */
-$(document).ready(function(){initNavTree('usage.html',''); initResizable(); });
+$(document).ready(function(){initNavTree('concepts.html',''); initResizable();
});
/* @license-end */
</script>
<div id="doc-content">
@@ -118,7 +118,7 @@ $(document).ready(function(){initNavTree('usage.html','');
initResizable(); });
</li>
</ul>
</div>
-<div class="textblock"><p><a class="anchor"
id="md_src_site_markdown_usage"></a></p>
+<div class="textblock"><p><a class="anchor"
id="md_src_site_markdown_concepts"></a></p>
<p>Log4cxx has three main components: <em>loggers</em>, <em>appenders</em> and
<em>layouts</em>. These three types of components work together to enable
developers to log messages according to message type and level, and to control
at runtime how these messages are formatted and where they are reported.</p>
<p>Configuration of the Log4cxx environment is typically done at application
initialization. The preferred way is by reading a configuration file. This
approach will be discussed shortly.</p>
<h1><a class="anchor" id="loggers"></a>
@@ -268,7 +268,7 @@ Levels</h2>
<p>A logging request is said to be <em>enabled</em> if its level is higher
than or equal to the level of its logger. Otherwise, the request is said to be
<em>disabled</em>. A logger without an assigned level will inherit one from the
hierarchy. This rule is summarized below.</p>
<h3><a class="anchor" id="level-inheritance"></a>
Level Inheritance</h3>
-<p>The <em>effective level</em> for a given logger <em>C</em>, is equal to the
first assigned in the logger hierarchy, starting at <em>C</em> and proceeding
upwards in the hierarchy towards the <em>root</em> logger.</p>
+<p>The <em>effective level</em> for a given logger <em>X.Y.Z</em>, is equal to
the first assigned in the logger hierarchy, starting at <em>X.Y.Z</em> and
proceeding upwards in the hierarchy towards the <em>root</em> logger.</p>
<p>To ensure that all loggers can eventually inherit a level, the root logger
always has an assigned level.</p>
<p>Below are four tables with various assigned level values and the resulting
effective levels according to the above rule.</p>
<table class="markdownTable">
@@ -443,7 +443,7 @@ Pattern 4</h2>
<li class="navelem"><a class="el" href="usage-overview.html">Usage</a></li>
<li class="footer">Generated by
<a href="http://www.doxygen.org/index.html">
- <img class="footer" src="https://www.doxygen.nl/images/doxygen.png"
alt="Doxygen"/></a> 1.9.6 on Mon Jul 24 2023 </li>
+ <img class="footer" src="https://www.doxygen.nl/images/doxygen.png"
alt="Doxygen"/></a> 1.9.6 on Tue Jul 25 2023 </li>
<li class="center">
Copyright © 2003-2023 <a href="https://www.apache.org/">Apache Software
Foundation</a>. All Rights Reserved. <a
href="https://privacy.apache.org/policies/privacy-policy-public.html">Privacy
Policy</a><br/>
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, and the
Apache Logging project logo are trademarks of The Apache Software
Foundation.<br/>
diff --git a/1.2.0/concepts_8md.html b/1.2.0/concepts_8md.html
new file mode 100644
index 00000000..394e265f
--- /dev/null
+++ b/1.2.0/concepts_8md.html
@@ -0,0 +1,113 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
+<head>
+<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
+<meta http-equiv="X-UA-Compatible" content="IE=11"/>
+<meta name="generator" content="Doxygen 1.9.6"/>
+<meta name="viewport" content="width=device-width, initial-scale=1"/>
+<title>Apache Log4cxx: concepts.md File Reference</title>
+<link href="tabs.css" rel="stylesheet" type="text/css"/>
+<script type="text/javascript" src="jquery.js"></script>
+<script type="text/javascript" src="dynsections.js"></script>
+<link href="navtree.css" rel="stylesheet" type="text/css"/>
+<script type="text/javascript" src="resize.js"></script>
+<script type="text/javascript" src="navtreedata.js"></script>
+<script type="text/javascript" src="navtree.js"></script>
+<link href="search/search.css" rel="stylesheet" type="text/css"/>
+<script type="text/javascript" src="search/searchdata.js"></script>
+<script type="text/javascript" src="search/search.js"></script>
+<link href="doxygen.css" rel="stylesheet" type="text/css" />
+<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
+</head>
+<body>
+<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
+<div id="titlearea">
+<table cellspacing="0" cellpadding="0">
+ <tbody>
+ <tr id="projectrow">
+ <td id="projectalign">
+ <div id="projectname">Apache Log4cxx<span id="projectnumber"> Version
1.2.0</span>
+ </div>
+ </td>
+ </tr>
+ </tbody>
+</table>
+</div>
+<!-- end header part -->
+<!-- Generated by Doxygen 1.9.6 -->
+<script type="text/javascript">
+/* @license
magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt
MIT */
+var searchBox = new SearchBox("searchBox", "search/",'.html');
+/* @license-end */
+</script>
+<script type="text/javascript" src="menudata.js"></script>
+<script type="text/javascript" src="menu.js"></script>
+<script type="text/javascript">
+/* @license
magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt
MIT */
+$(function() {
+ initMenu('',true,false,'search.php','Search');
+ $(document).ready(function() { init_search(); });
+});
+/* @license-end */
+</script>
+<div id="main-nav"></div>
+</div><!-- top -->
+<div id="side-nav" class="ui-resizable side-nav-resizable">
+ <div id="nav-tree">
+ <div id="nav-tree-contents">
+ <div id="nav-sync" class="sync"></div>
+ </div>
+ </div>
+ <div id="splitbar" style="-moz-user-select:none;"
+ class="ui-resizable-handle">
+ </div>
+</div>
+<script type="text/javascript">
+/* @license
magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt
MIT */
+$(document).ready(function(){initNavTree('concepts_8md.html','');
initResizable(); });
+/* @license-end */
+</script>
+<div id="doc-content">
+<!-- window showing the filter options -->
+<div id="MSearchSelectWindow"
+ onmouseover="return searchBox.OnSearchSelectShow()"
+ onmouseout="return searchBox.OnSearchSelectHide()"
+ onkeydown="return searchBox.OnSearchSelectKey(event)">
+</div>
+
+<!-- iframe showing the search results (closed by default) -->
+<div id="MSearchResultsWindow">
+<div id="MSearchResults">
+<div class="SRPage">
+<div id="SRIndex">
+<div id="SRResults"></div>
+<div class="SRStatus" id="Loading">Loading...</div>
+<div class="SRStatus" id="Searching">Searching...</div>
+<div class="SRStatus" id="NoMatches">No Matches</div>
+</div>
+</div>
+</div>
+</div>
+
+<div class="header">
+ <div class="headertitle"><div class="title">concepts.md File
Reference</div></div>
+</div><!--header-->
+<div class="contents">
+</div><!-- contents -->
+</div><!-- doc-content -->
+<!-- HTML footer for doxygen 1.8.13-->
+<!-- start footer part -->
+<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
+ <ul>
+ <li class="navelem"><a class="el"
href="concepts_8md.html">concepts.md</a></li>
+ <li class="footer">Generated by
+ <a href="http://www.doxygen.org/index.html">
+ <img class="footer" src="https://www.doxygen.nl/images/doxygen.png"
alt="Doxygen"/></a> 1.9.6 on Tue Jul 25 2023 </li>
+ <li class="center">
+Copyright © 2003-2023 <a href="https://www.apache.org/">Apache Software
Foundation</a>. All Rights Reserved. <a
href="https://privacy.apache.org/policies/privacy-policy-public.html">Privacy
Policy</a><br/>
+Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, and the
Apache Logging project logo are trademarks of The Apache Software
Foundation.<br/>
+ </li>
+ </ul>
+</div>
+</body>
+</html>
diff --git a/1.2.0/quick-start.html b/1.2.0/quick-start.html
new file mode 100644
index 00000000..ef301a04
--- /dev/null
+++ b/1.2.0/quick-start.html
@@ -0,0 +1,331 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
+<head>
+<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
+<meta http-equiv="X-UA-Compatible" content="IE=11"/>
+<meta name="generator" content="Doxygen 1.9.6"/>
+<meta name="viewport" content="width=device-width, initial-scale=1"/>
+<title>Apache Log4cxx: Quick Start</title>
+<link href="tabs.css" rel="stylesheet" type="text/css"/>
+<script type="text/javascript" src="jquery.js"></script>
+<script type="text/javascript" src="dynsections.js"></script>
+<link href="navtree.css" rel="stylesheet" type="text/css"/>
+<script type="text/javascript" src="resize.js"></script>
+<script type="text/javascript" src="navtreedata.js"></script>
+<script type="text/javascript" src="navtree.js"></script>
+<link href="search/search.css" rel="stylesheet" type="text/css"/>
+<script type="text/javascript" src="search/searchdata.js"></script>
+<script type="text/javascript" src="search/search.js"></script>
+<link href="doxygen.css" rel="stylesheet" type="text/css" />
+<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
+</head>
+<body>
+<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
+<div id="titlearea">
+<table cellspacing="0" cellpadding="0">
+ <tbody>
+ <tr id="projectrow">
+ <td id="projectalign">
+ <div id="projectname">Apache Log4cxx<span id="projectnumber"> Version
1.2.0</span>
+ </div>
+ </td>
+ </tr>
+ </tbody>
+</table>
+</div>
+<!-- end header part -->
+<!-- Generated by Doxygen 1.9.6 -->
+<script type="text/javascript">
+/* @license
magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt
MIT */
+var searchBox = new SearchBox("searchBox", "search/",'.html');
+/* @license-end */
+</script>
+<script type="text/javascript" src="menudata.js"></script>
+<script type="text/javascript" src="menu.js"></script>
+<script type="text/javascript">
+/* @license
magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt
MIT */
+$(function() {
+ initMenu('',true,false,'search.php','Search');
+ $(document).ready(function() { init_search(); });
+});
+/* @license-end */
+</script>
+<div id="main-nav"></div>
+</div><!-- top -->
+<div id="side-nav" class="ui-resizable side-nav-resizable">
+ <div id="nav-tree">
+ <div id="nav-tree-contents">
+ <div id="nav-sync" class="sync"></div>
+ </div>
+ </div>
+ <div id="splitbar" style="-moz-user-select:none;"
+ class="ui-resizable-handle">
+ </div>
+</div>
+<script type="text/javascript">
+/* @license
magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt
MIT */
+$(document).ready(function(){initNavTree('quick-start.html','');
initResizable(); });
+/* @license-end */
+</script>
+<div id="doc-content">
+<!-- window showing the filter options -->
+<div id="MSearchSelectWindow"
+ onmouseover="return searchBox.OnSearchSelectShow()"
+ onmouseout="return searchBox.OnSearchSelectHide()"
+ onkeydown="return searchBox.OnSearchSelectKey(event)">
+</div>
+
+<!-- iframe showing the search results (closed by default) -->
+<div id="MSearchResultsWindow">
+<div id="MSearchResults">
+<div class="SRPage">
+<div id="SRIndex">
+<div id="SRResults"></div>
+<div class="SRStatus" id="Loading">Loading...</div>
+<div class="SRStatus" id="Searching">Searching...</div>
+<div class="SRStatus" id="NoMatches">No Matches</div>
+</div>
+</div>
+</div>
+</div>
+
+<div><div class="header">
+ <div class="headertitle"><div class="title">Quick Start </div></div>
+</div><!--header-->
+<div class="contents">
+<div class="toc"><h3>Table of Contents</h3>
+<ul><li class="level1"><a href="#example1">A Simple Example</a></li>
+<li class="level1"><a href="#example2">A Less Simple Example</a></li>
+<li class="level1"><a href="#configuration">Runtime Configuration</a></li>
+</ul>
+</div>
+<div class="textblock"><p><a class="anchor"
id="md_src_site_markdown_example_programs"></a></p>
+<p>Creating useful log information requires a fair amount of planning and
effort. Observation shows that approximately 4 percent of code is dedicated to
logging. Consequently, even moderately sized applications will have thousands
of logging statements embedded within their code. Given their number, it
becomes imperative to manage these log statements without the need to modify
them manually.</p>
+<p>Let us give a taste of how this is done with the help of an imaginary
application <em>MyApp</em> that uses Log4cxx.</p>
+<h1><a class="anchor" id="example1"></a>
+A Simple Example</h1>
+<p>In order to start using Log4cxx, a simple example program is shown below.
This program does nothing useful, but it shows the basics of how to start using
Log4cxx. Using the <a class="el"
href="classlog4cxx_1_1BasicConfigurator.html">BasicConfigurator</a> class, we
are able to quickly configure the library to output DEBUG, INFO, etc level
messages to standard output. </p><div class="fragment"><div class="line"><span
class="preprocessor">#include <<a class="code" href="logger_8h.html [...]
+<div class="line"><span class="preprocessor">#include <<a class="code"
href="basicconfigurator_8h.html">log4cxx/basicconfigurator.h</a>></span></div>
+<div class="line"> </div>
+<div class="line"><span class="keyword">static</span> <span
class="keyword">auto</span> logger = <a class="code hl_function"
href="classlog4cxx_1_1Logger.html#ab2d1e6be52dbe1bc81e01fd70a755a63">log4cxx::Logger::getLogger</a>(<span
class="stringliteral">"MyApp"</span>);</div>
+<div class="line"> </div>
+<div class="line"><span class="keywordtype">void</span> foo() {</div>
+<div class="line"> <span class="comment">// Get a logger that is a child of
the statically declared logger</span></div>
+<div class="line"> <span class="keyword">auto</span> fooLogger = <a
class="code hl_function"
href="classlog4cxx_1_1Logger.html#ab2d1e6be52dbe1bc81e01fd70a755a63">log4cxx::Logger::getLogger</a>(<span
class="stringliteral">"MyApp.foo"</span>);</div>
+<div class="line"> <a class="code hl_define"
href="group__LoggingMacros.html#ga806900dd7eafb458d0472d9c8f84594b">LOG4CXX_TRACE</a>(fooLogger,
<span class="stringliteral">"Doing foo at trace level"</span>);</div>
+<div class="line"> <a class="code hl_define"
href="group__LoggingMacros.html#gae1bc2ab20d5f2d7660995ea8244d3a26">LOG4CXX_DEBUG</a>(fooLogger,
<span class="stringliteral">"Doing foo at debug level"</span>);</div>
+<div class="line"> <a class="code hl_define"
href="group__LoggingMacros.html#ga61dfed4f5eca82725a90a331f37857d3">LOG4CXX_INFO</a>(fooLogger,
<span class="stringliteral">"Doing foo at info level"</span>);</div>
+<div class="line"> <a class="code hl_define"
href="group__LoggingMacros.html#ga530190bc1766b89d1f69ad572509aed2">LOG4CXX_WARN</a>(fooLogger,
<span class="stringliteral">"Doing foo at warn level"</span>);</div>
+<div class="line"> <a class="code hl_define"
href="group__LoggingMacros.html#gaa2dd8d775aa30be2d9a51df615918b50">LOG4CXX_ERROR</a>(fooLogger,
<span class="stringliteral">"Doing foo at error level"</span>);</div>
+<div class="line"> <a class="code hl_define"
href="group__LoggingMacros.html#ga7aca8ae1ffa1cf893f1e8f362c53fc01">LOG4CXX_FATAL</a>(fooLogger,
<span class="stringliteral">"Doing foo at fatal level"</span>);</div>
+<div class="line">}</div>
+<div class="line"> </div>
+<div class="line"><span class="keywordtype">int</span> main(<span
class="keywordtype">int</span> argc, <span class="keywordtype">char</span>
**argv) {</div>
+<div class="line"> <span class="comment">// Log to standard
output.</span></div>
+<div class="line"> <a class="code hl_function"
href="classlog4cxx_1_1BasicConfigurator.html#a3fa54f4589f908a886576c1bba3f113d">log4cxx::BasicConfigurator::configure</a>();</div>
+<div class="line"> <a class="code hl_define"
href="group__LoggingMacros.html#ga61dfed4f5eca82725a90a331f37857d3">LOG4CXX_INFO</a>(logger,
<span class="stringliteral">"Entering application."</span>);</div>
+<div class="line"> foo();</div>
+<div class="line"> <a class="code hl_define"
href="group__LoggingMacros.html#ga61dfed4f5eca82725a90a331f37857d3">LOG4CXX_INFO</a>(logger,
<span class="stringliteral">"Exiting application."</span>);</div>
+<div class="line"> <span class="keywordflow">return</span>
EXIT_SUCCESS;</div>
+<div class="line">}</div>
+<div class="ttc" id="abasicconfigurator_8h_html"><div class="ttname"><a
href="basicconfigurator_8h.html">basicconfigurator.h</a></div></div>
+<div class="ttc"
id="aclasslog4cxx_1_1BasicConfigurator_html_a3fa54f4589f908a886576c1bba3f113d"><div
class="ttname"><a
href="classlog4cxx_1_1BasicConfigurator.html#a3fa54f4589f908a886576c1bba3f113d">log4cxx::BasicConfigurator::configure</a></div><div
class="ttdeci">static void configure(const LayoutPtr
&layout=LayoutPtr())</div><div class="ttdoc">Add a ConsoleAppender to the
root logger that formats output using layout.</div></div>
+<div class="ttc"
id="aclasslog4cxx_1_1Logger_html_ab2d1e6be52dbe1bc81e01fd70a755a63"><div
class="ttname"><a
href="classlog4cxx_1_1Logger.html#ab2d1e6be52dbe1bc81e01fd70a755a63">log4cxx::Logger::getLogger</a></div><div
class="ttdeci">static LoggerPtr getLogger(const std::string
&name)</div><div class="ttdoc">Retrieve a logger by name in current
encoding.</div></div>
+<div class="ttc"
id="agroup__LoggingMacros_html_ga530190bc1766b89d1f69ad572509aed2"><div
class="ttname"><a
href="group__LoggingMacros.html#ga530190bc1766b89d1f69ad572509aed2">LOG4CXX_WARN</a></div><div
class="ttdeci">#define LOG4CXX_WARN(logger, message)</div><div
class="ttdoc">Add a new logging event containing message to attached
appender(s) if logger is enabled for WARN even...</div><div
class="ttdef"><b>Definition:</b> logger.h:2175</div></div>
+<div class="ttc"
id="agroup__LoggingMacros_html_ga61dfed4f5eca82725a90a331f37857d3"><div
class="ttname"><a
href="group__LoggingMacros.html#ga61dfed4f5eca82725a90a331f37857d3">LOG4CXX_INFO</a></div><div
class="ttdeci">#define LOG4CXX_INFO(logger, message)</div><div
class="ttdoc">Add a new logging event containing message to attached
appender(s) if logger is enabled for INFO even...</div><div
class="ttdef"><b>Definition:</b> logger.h:2141</div></div>
+<div class="ttc"
id="agroup__LoggingMacros_html_ga7aca8ae1ffa1cf893f1e8f362c53fc01"><div
class="ttname"><a
href="group__LoggingMacros.html#ga7aca8ae1ffa1cf893f1e8f362c53fc01">LOG4CXX_FATAL</a></div><div
class="ttdeci">#define LOG4CXX_FATAL(logger, message)</div><div
class="ttdoc">Add a new logging event containing message to attached
appender(s) if logger is enabled for FATAL eve...</div><div
class="ttdef"><b>Definition:</b> logger.h:2268</div></div>
+<div class="ttc"
id="agroup__LoggingMacros_html_ga806900dd7eafb458d0472d9c8f84594b"><div
class="ttname"><a
href="group__LoggingMacros.html#ga806900dd7eafb458d0472d9c8f84594b">LOG4CXX_TRACE</a></div><div
class="ttdeci">#define LOG4CXX_TRACE(logger, message)</div><div
class="ttdoc">Add a new logging event containing message to attached
appender(s) if logger is enabled for TRACE eve...</div><div
class="ttdef"><b>Definition:</b> logger.h:2105</div></div>
+<div class="ttc"
id="agroup__LoggingMacros_html_gaa2dd8d775aa30be2d9a51df615918b50"><div
class="ttname"><a
href="group__LoggingMacros.html#gaa2dd8d775aa30be2d9a51df615918b50">LOG4CXX_ERROR</a></div><div
class="ttdeci">#define LOG4CXX_ERROR(logger, message)</div><div
class="ttdoc">Add a new logging event containing message to attached
appender(s) if logger is enabled for ERROR eve...</div><div
class="ttdef"><b>Definition:</b> logger.h:2209</div></div>
+<div class="ttc"
id="agroup__LoggingMacros_html_gae1bc2ab20d5f2d7660995ea8244d3a26"><div
class="ttname"><a
href="group__LoggingMacros.html#gae1bc2ab20d5f2d7660995ea8244d3a26">LOG4CXX_DEBUG</a></div><div
class="ttdeci">#define LOG4CXX_DEBUG(logger, message)</div><div
class="ttdoc">Add a new logging event containing message to attached
appender(s) if logger is enabled for DEBUG eve...</div><div
class="ttdef"><b>Definition:</b> logger.h:2073</div></div>
+<div class="ttc" id="alogger_8h_html"><div class="ttname"><a
href="logger_8h.html">logger.h</a></div></div>
+</div><!-- fragment --><p>The above application does nothing useful except to
show how to initialize logging with the BasicConfigurator and do logging with
different loggers. Note that file based configurations are also possible - see
<a class="el"
href="classlog4cxx_1_1xml_1_1DOMConfigurator.html#ac11013f451d4db8aa5b876f191d8ccec">DOMConfigurator</a>
and <a class="el"
href="classlog4cxx_1_1PropertyConfigurator.html#af9559ce6a84ed4b556b14171a8736a53">PropertyConfigurator</a>.</p>
+<p>Configuring Log4cxx in the main function has the limitation that any
logging statements in static initialization code will not generate output.
Log4cxx must be configured before it is used and in this example Log4cxx is not
configured until the main() function starts.</p>
+<h1><a class="anchor" id="example2"></a>
+A Less Simple Example</h1>
+<p>In this example we use a <em>getLogger()</em> wrapper function which
configures Log4cxx on the first usage. The advantages of this approach are:</p>
+<ul>
+<li>Log4cxx configuration can be reused in multiple applications.</li>
+<li>The structure exhibits better <a
href="https://en.wikipedia.org/wiki/Separation_of_concerns">separation of
concerns</a>.</li>
+<li>Log statements in static initialization code will generate output.</li>
+</ul>
+<p>This program (<em>MyApp</em>) begins by including the file that defines the
com::foo::getLogger() function. It obtains a logger named <em>MyApp</em> (which
in this example is the fully qualified name) from the com::foo::getLogger()
function.</p>
+<p><em>MyApp</em> uses the <em>com::foo::Bar</em> class defined in header file
<em>com/foo/bar.h</em>. </p><div class="fragment"><div class="line"><span
class="preprocessor">#include "com/foo/config.h"</span></div>
+<div class="line"><span class="preprocessor">#include
"com/foo/bar.h"</span></div>
+<div class="line"> </div>
+<div class="line"><span class="keywordtype">int</span> main(<span
class="keywordtype">int</span> argc, <span class="keywordtype">char</span>
**argv) {</div>
+<div class="line"> <span class="keywordtype">int</span> result =
EXIT_SUCCESS;</div>
+<div class="line"> <span class="keywordflow">try</span> {</div>
+<div class="line"> <span class="keyword">auto</span> logger =
com::foo::getLogger(<span class="stringliteral">"MyApp"</span>);</div>
+<div class="line"> <a class="code hl_define"
href="group__LoggingMacros.html#ga61dfed4f5eca82725a90a331f37857d3">LOG4CXX_INFO</a>(logger,
<span class="stringliteral">"Entering application."</span>);</div>
+<div class="line"> com::foo::Bar bar;</div>
+<div class="line"> bar.doIt();</div>
+<div class="line"> <a class="code hl_define"
href="group__LoggingMacros.html#ga61dfed4f5eca82725a90a331f37857d3">LOG4CXX_INFO</a>(logger,
<span class="stringliteral">"Exiting application."</span>);</div>
+<div class="line"> }</div>
+<div class="line"> <span
class="keywordflow">catch</span>(std::exception&) {</div>
+<div class="line"> result = EXIT_FAILURE;</div>
+<div class="line"> }</div>
+<div class="line"> <span class="keywordflow">return</span> result;</div>
+<div class="line">}</div>
+</div><!-- fragment --><p>The <em>com::foo::Bar</em> class is defined in
header file <em>com/foo/bar.h</em>. </p><div class="fragment"><div
class="line"><span class="preprocessor">#ifndef COM_FOO_BAR_H_</span></div>
+<div class="line"><span class="preprocessor">#define
COM_FOO_BAR_H_</span></div>
+<div class="line"><span class="preprocessor">#include
"com/foo/config.h"</span></div>
+<div class="line"><span class="keyword">namespace </span>com { <span
class="keyword">namespace </span>foo {</div>
+<div class="line"> </div>
+<div class="line"><span class="keyword">class </span>Bar {</div>
+<div class="line"> <span class="keyword">static</span> LoggerPtr
m_logger;</div>
+<div class="line"> <span class="keyword">public</span>:</div>
+<div class="line"> <span class="keywordtype">void</span> doIt();</div>
+<div class="line">};</div>
+<div class="line"> </div>
+<div class="line">} } <span class="comment">// namespace com::foo</span></div>
+<div class="line"><span class="preprocessor">#endif </span><span
class="comment">// COM_FOO_BAR_H_</span></div>
+</div><!-- fragment --><p>The <em>com::foo::Bar</em> class is implemented in
the file <em>com/foo/bar.cpp</em>. </p><div class="fragment"><div
class="line"><span class="preprocessor">#include
"com/foo/bar.h"</span></div>
+<div class="line"> </div>
+<div class="line"><span class="keyword">using namespace </span>com::foo;</div>
+<div class="line"> </div>
+<div class="line">LoggerPtr Bar::m_logger(getLogger(<span
class="stringliteral">"com.foo.bar"</span>));</div>
+<div class="line"> </div>
+<div class="line"><span class="keywordtype">void</span> Bar::doIt() {</div>
+<div class="line"> <a class="code hl_define"
href="group__LoggingMacros.html#gae1bc2ab20d5f2d7660995ea8244d3a26">LOG4CXX_DEBUG</a>(m_logger,
<span class="stringliteral">"Did it again!"</span>);</div>
+<div class="line">}</div>
+</div><!-- fragment --><p>The header file <em>com/foo/config.h</em> defines
the com::foo::getLogger() function and a <em>LoggerPtr</em> type for
convenience. </p><div class="fragment"><div class="line"><span
class="preprocessor">#ifndef COM_FOO_CONFIG_H_</span></div>
+<div class="line"><span class="preprocessor">#define
COM_FOO_CONFIG_H_</span></div>
+<div class="line"><span class="preprocessor">#include <<a class="code"
href="logger_8h.html">log4cxx/logger.h</a>></span></div>
+<div class="line"> </div>
+<div class="line"><span class="keyword">namespace </span>com { <span
class="keyword">namespace </span>foo {</div>
+<div class="line"> </div>
+<div class="line"><span class="keyword">using </span>LoggerPtr = <a
class="code hl_typedef"
href="namespacelog4cxx.html#acd073adf77cc8545b10ac024a474be0d">log4cxx::LoggerPtr</a>;</div>
+<div class="line"> </div>
+<div class="line"><span class="keyword">extern</span> <span
class="keyword">auto</span> getLogger(<span class="keyword">const</span>
std::string& name = std::string()) -> LoggerPtr;</div>
+<div class="line"> </div>
+<div class="line">} } <span class="comment">// namespace com::foo</span></div>
+<div class="line"><span class="preprocessor">#endif </span><span
class="comment">// COM_FOO_CONFIG_H_</span></div>
+<div class="ttc"
id="anamespacelog4cxx_html_acd073adf77cc8545b10ac024a474be0d"><div
class="ttname"><a
href="namespacelog4cxx.html#acd073adf77cc8545b10ac024a474be0d">log4cxx::LoggerPtr</a></div><div
class="ttdeci">std::shared_ptr< Logger > LoggerPtr</div><div
class="ttdef"><b>Definition:</b> defaultloggerfactory.h:27</div></div>
+</div><!-- fragment --><p>The file <em>com/foo/config.cpp</em> which
implements the com::foo::getLogger() function defines <em>initAndShutdown</em>
as a <em>static struct</em> so its constructor is invoked on the first call to
the com::foo::getLogger() function and its destructor is automatically called
during application exit. </p><div class="fragment"><div class="line"><span
class="preprocessor">#include "com/foo/config.h"</span></div>
+<div class="line"><span class="preprocessor">#include <<a class="code"
href="basicconfigurator_8h.html">log4cxx/basicconfigurator.h</a>></span></div>
+<div class="line"><span class="preprocessor">#include <<a class="code"
href="logmanager_8h.html">log4cxx/logmanager.h</a>></span></div>
+<div class="line"> </div>
+<div class="line"><span class="keyword">namespace </span>com { <span
class="keyword">namespace </span>foo {</div>
+<div class="line"> </div>
+<div class="line"><span class="keyword">auto</span> getLogger(<span
class="keyword">const</span> std::string& name) -> LoggerPtr {</div>
+<div class="line"> <span class="keyword">static</span> <span
class="keyword">struct </span>log4cxx_initializer {</div>
+<div class="line"> log4cxx_initializer() {</div>
+<div class="line"> <span class="comment">// Set up a simple
configuration that logs on the console.</span></div>
+<div class="line"> <a class="code hl_function"
href="classlog4cxx_1_1BasicConfigurator.html#a3fa54f4589f908a886576c1bba3f113d">log4cxx::BasicConfigurator::configure</a>();</div>
+<div class="line"> }</div>
+<div class="line"> ~log4cxx_initializer() {</div>
+<div class="line"> <a class="code hl_function"
href="classlog4cxx_1_1LogManager.html#ad8845f4e8c6c840c7825bde2c9ce7e7c">log4cxx::LogManager::shutdown</a>();</div>
+<div class="line"> }</div>
+<div class="line"> } initAndShutdown;</div>
+<div class="line"> <span class="keywordflow">return</span>
name.empty()</div>
+<div class="line"> ? <a class="code hl_function"
href="classlog4cxx_1_1LogManager.html#a653a8b4b1548f75d9e12615dd4a677f7">log4cxx::LogManager::getRootLogger</a>()</div>
+<div class="line"> : <a class="code hl_namespace"
href="namespacelog4cxx.html">log4cxx</a>::LogManager::getLogger(name);</div>
+<div class="line">}</div>
+<div class="line"> </div>
+<div class="line">} } <span class="comment">// namespace com::foo</span></div>
+<div class="ttc"
id="aclasslog4cxx_1_1LogManager_html_a653a8b4b1548f75d9e12615dd4a677f7"><div
class="ttname"><a
href="classlog4cxx_1_1LogManager.html#a653a8b4b1548f75d9e12615dd4a677f7">log4cxx::LogManager::getRootLogger</a></div><div
class="ttdeci">static LoggerPtr getRootLogger()</div><div
class="ttdoc">Retrieve the root logger from the LoggerRepository.</div></div>
+<div class="ttc"
id="aclasslog4cxx_1_1LogManager_html_ad8845f4e8c6c840c7825bde2c9ce7e7c"><div
class="ttname"><a
href="classlog4cxx_1_1LogManager.html#ad8845f4e8c6c840c7825bde2c9ce7e7c">log4cxx::LogManager::shutdown</a></div><div
class="ttdeci">static void shutdown()</div><div class="ttdoc">Safely close and
remove all appenders in all loggers including the root logger.</div></div>
+<div class="ttc" id="alogmanager_8h_html"><div class="ttname"><a
href="logmanager_8h.html">logmanager.h</a></div></div>
+<div class="ttc" id="anamespacelog4cxx_html"><div class="ttname"><a
href="namespacelog4cxx.html">log4cxx</a></div><div
class="ttdef"><b>Definition:</b> configuration.h:25</div></div>
+</div><!-- fragment --><p>The invocation of the <a class="el"
href="classlog4cxx_1_1BasicConfigurator.html#a3fa54f4589f908a886576c1bba3f113d">BasicConfigurator::configure</a>
method creates a rather simple Log4cxx setup. This method is hardwired to add
to the root logger a <a class="el"
href="classlog4cxx_1_1ConsoleAppender.html">ConsoleAppender</a>. The output
will be formatted using a <a class="el"
href="classlog4cxx_1_1PatternLayout.html">PatternLayout</a> set to the pattern
<code>%r [...]
+<p>Note that by default, the root logger is assigned a <em>DEBUG</em>
level.</p>
+<p>The output of MyApp is:</p>
+<div class="fragment"><div class="line">0 [12345] INFO MyApp null - Entering
application.</div>
+<div class="line">0 [12345] DEBUG com.foo.Bar null - Did it again!</div>
+<div class="line">0 [12345] INFO MyApp null - Exiting application.</div>
+</div><!-- fragment --><h1><a class="anchor" id="configuration"></a>
+Runtime Configuration</h1>
+<p>The Log4cxx environment is fully configurable programmatically. However, it
is far more flexible to configure Log4cxx using configuration files. Currently,
configuration files can be written in XML or in Java properties (key=value)
format.</p>
+<p>The previous example always outputs the same log information. Fortunately,
it is easy to modify <em>config.cpp</em> so that the log output can be
controlled at runtime. Here is a slightly modified version. </p><div
class="fragment"><div class="line"><span class="preprocessor">#include
"com/foo/config.h"</span></div>
+<div class="line"><span class="preprocessor">#include <<a class="code"
href="propertyconfigurator_8h.html">log4cxx/propertyconfigurator.h</a>></span></div>
+<div class="line"><span class="preprocessor">#include <<a class="code"
href="logmanager_8h.html">log4cxx/logmanager.h</a>></span></div>
+<div class="line"> </div>
+<div class="line"><span class="keyword">namespace </span>com { <span
class="keyword">namespace </span>foo {</div>
+<div class="line"> </div>
+<div class="line"><span class="keyword">auto</span> getLogger(<span
class="keyword">const</span> std::string& name) -> LoggerPtr {</div>
+<div class="line"> <span class="keyword">static</span> <span
class="keyword">struct </span>log4cxx_initializer {</div>
+<div class="line"> log4cxx_initializer() {</div>
+<div class="line"> <a class="code hl_function"
href="classlog4cxx_1_1PropertyConfigurator.html#af9559ce6a84ed4b556b14171a8736a53">log4cxx::PropertyConfigurator::configure</a>(<span
class="stringliteral">"MyApp.properties"</span>);</div>
+<div class="line"> }</div>
+<div class="line"> ~log4cxx_initializer() {</div>
+<div class="line"> <a class="code hl_function"
href="classlog4cxx_1_1LogManager.html#ad8845f4e8c6c840c7825bde2c9ce7e7c">log4cxx::LogManager::shutdown</a>();</div>
+<div class="line"> }</div>
+<div class="line"> } initAndShutdown;</div>
+<div class="line"> <span class="keywordflow">return</span>
name.empty()</div>
+<div class="line"> ? <a class="code hl_function"
href="classlog4cxx_1_1LogManager.html#a653a8b4b1548f75d9e12615dd4a677f7">log4cxx::LogManager::getRootLogger</a>()</div>
+<div class="line"> : <a class="code hl_namespace"
href="namespacelog4cxx.html">log4cxx</a>::LogManager::getLogger(name);</div>
+<div class="line">}</div>
+<div class="line"> </div>
+<div class="line">} } <span class="comment">// namespace com::foo</span></div>
+<div class="ttc"
id="aclasslog4cxx_1_1PropertyConfigurator_html_af9559ce6a84ed4b556b14171a8736a53"><div
class="ttname"><a
href="classlog4cxx_1_1PropertyConfigurator.html#af9559ce6a84ed4b556b14171a8736a53">log4cxx::PropertyConfigurator::configure</a></div><div
class="ttdeci">static spi::ConfigurationStatus configure(const File
&configFilename)</div><div class="ttdoc">Read configuration options from
file configFilename.</div></div>
+<div class="ttc" id="apropertyconfigurator_8h_html"><div class="ttname"><a
href="propertyconfigurator_8h.html">propertyconfigurator.h</a></div></div>
+</div><!-- fragment --><p>This version of <em>config.cpp</em> instructs <a
class="el"
href="classlog4cxx_1_1PropertyConfigurator.html#af9559ce6a84ed4b556b14171a8736a53">PropertyConfigurator</a>
to use the <em>MyApp.properties</em> file to configure Log4cxx. A more
realistic approach would (for example) use the current module name to select
the configuration file (see the <a class="el"
href="com_2foo_2config3_8cpp-example.html">com/foo/config3.cpp</a> file for how
to do this).</p>
+<p>Here is a sample <em>MyApp.properties</em> configuration file that results
in exactly same output as the previous <a class="el"
href="classlog4cxx_1_1BasicConfigurator.html#a3fa54f4589f908a886576c1bba3f113d">BasicConfigurator::configure</a>
based example.</p>
+<div class="fragment"><div class="line"># Set root logger level to DEBUG and
its only appender to A1.</div>
+<div class="line">log4j.rootLogger=DEBUG, A1</div>
+<div class="line"> </div>
+<div class="line"># A1 is set to be a ConsoleAppender.</div>
+<div class="line">log4j.appender.A1=org.apache.log4j.ConsoleAppender</div>
+<div class="line"> </div>
+<div class="line"># A1 uses PatternLayout.</div>
+<div class="line">log4j.appender.A1.layout=org.apache.log4j.PatternLayout</div>
+<div class="line">log4j.appender.A1.layout.ConversionPattern=%r [%t] %-5p %c
%x - %m%n</div>
+</div><!-- fragment --><p>It can be noticed that the PropertyConfigurator file
format is the same as log4j.</p>
+<p>Suppose we are no longer interested in seeing the output of any component
belonging to the <em>com::foo</em> package. The following configuration file
shows one possible way of achieving this.</p>
+<div class="fragment"><div class="line">log4j.rootLogger=DEBUG, A1</div>
+<div class="line">log4j.appender.A1=org.apache.log4j.ConsoleAppender</div>
+<div class="line">log4j.appender.A1.layout=org.apache.log4j.PatternLayout</div>
+<div class="line"> </div>
+<div class="line"># Print the date in ISO 8601 format</div>
+<div class="line">log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c -
%m%n</div>
+<div class="line"> </div>
+<div class="line"># Print only messages of level WARN or above in the package
com.foo.</div>
+<div class="line">log4j.logger.com.foo=WARN</div>
+</div><!-- fragment --><p>The output of <em>MyApp</em> configured with this
file is shown below.</p>
+<div class="fragment"><div class="line">2022-12-13 11:01:45,091 [12345] INFO
MyApp - Entering application.</div>
+<div class="line">2022-12-13 11:01:45,091 [12345] INFO MyApp - Exiting
application.</div>
+</div><!-- fragment --><p>As the logger <em>com.foo.Bar</em> does not have an
assigned level, it inherits its level from <em>com.foo</em>, which was set to
WARN in the configuration file. The log statement from the <em>Bar::doIt</em>
method has the level <em>DEBUG</em>, lower than the logger level WARN.
Consequently, <em>doIt()</em> method's log request is suppressed.</p>
+<p>Here is another configuration file that uses multiple appenders. </p><div
class="fragment"><div class="line"># Append log events onto stdout and R</div>
+<div class="line">log4j.rootLogger=DEBUG, stdout, R</div>
+<div class="line"> </div>
+<div class="line">log4j.appender.stdout=org.apache.log4j.ConsoleAppender</div>
+<div
class="line">log4j.appender.stdout.layout=org.apache.log4j.PatternLayout</div>
+<div class="line"> </div>
+<div class="line"># Pattern to output the caller's file name and line
number.</div>
+<div class="line">log4j.appender.stdout.layout.ConversionPattern=%5p [%t]
(%f:%L) - %m%n</div>
+<div class="line"> </div>
+<div class="line">log4j.appender.R=org.apache.log4j.RollingFileAppender</div>
+<div class="line">log4j.appender.R.File=example.log</div>
+<div class="line"> </div>
+<div class="line"># Move example.log to example.log.1 at 100 KB in size</div>
+<div class="line">log4j.appender.R.MaxFileSize=100KB</div>
+<div class="line"># Keep one backup file</div>
+<div class="line">log4j.appender.R.MaxBackupIndex=1</div>
+<div class="line"> </div>
+<div class="line">log4j.appender.R.layout=org.apache.log4j.PatternLayout</div>
+<div class="line">log4j.appender.R.layout.ConversionPattern=%p %t %c -
%m%n</div>
+</div><!-- fragment --><p>Calling the enhanced MyApp with the this
configuration file will output the following on the console.</p>
+<div class="fragment"><div class="line"> INFO [12345] (MyApp.cpp:8) - Entering
application.</div>
+<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>
+</div></div><!-- contents -->
+</div><!-- PageDoc -->
+</div><!-- doc-content -->
+<!-- HTML footer for doxygen 1.8.13-->
+<!-- start footer part -->
+<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
+ <ul>
+ <li class="navelem"><a class="el" href="usage-overview.html">Usage</a></li>
+ <li class="footer">Generated by
+ <a href="http://www.doxygen.org/index.html">
+ <img class="footer" src="https://www.doxygen.nl/images/doxygen.png"
alt="Doxygen"/></a> 1.9.6 on Tue Jul 25 2023 </li>
+ <li class="center">
+Copyright © 2003-2023 <a href="https://www.apache.org/">Apache Software
Foundation</a>. All Rights Reserved. <a
href="https://privacy.apache.org/policies/privacy-policy-public.html">Privacy
Policy</a><br/>
+Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, and the
Apache Logging project logo are trademarks of The Apache Software
Foundation.<br/>
+ </li>
+ </ul>
+</div>
+</body>
+</html>