Apache Log4cxx  Version 1.7.0
Loading...
Searching...
No Matches
domconfigurator.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _LOG4CXX_XML_DOM_CONFIGURATOR_H
19#define _LOG4CXX_XML_DOM_CONFIGURATOR_H
20
21#include <log4cxx/logstring.h>
23#if LOG4CXX_ABI_VERSION <= 15
24#include <log4cxx/appender.h>
25#include <log4cxx/layout.h>
26#include <log4cxx/logger.h>
29#include <log4cxx/spi/filter.h>
33#include <map>
34#endif
35#include <log4cxx/file.h>
36
37#if LOG4CXX_HAS_DOMCONFIGURATOR
38
39extern "C" {
40 struct apr_xml_doc;
41 struct apr_xml_elem;
42}
43
44namespace LOG4CXX_NS
45{
46
47namespace xml
48{
49class XMLWatchdog;
50
66class LOG4CXX_EXPORT DOMConfigurator :
67 virtual public spi::Configurator
68{
69 public:
71
72#if LOG4CXX_ABI_VERSION <= 15
73 protected:
74 typedef std::map<LogString, AppenderPtr> AppenderMap;
79 LOG4CXX_NS::helpers::Pool& p,
80 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
81 apr_xml_elem* elem,
82 apr_xml_doc* doc,
83 const LogString& appenderName,
84 AppenderMap& appenders);
85
90 LOG4CXX_NS::helpers::Pool& p,
91 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
92 apr_xml_elem* appenderRef,
93 apr_xml_doc* doc,
94 AppenderMap& appenders);
95
100 LOG4CXX_NS::helpers::Pool& p,
101 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
102 apr_xml_elem* appenderElement,
103 apr_xml_doc* doc,
104 AppenderMap& appenders);
105
110 LOG4CXX_NS::helpers::Pool& p,
111 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
112 apr_xml_elem* element,
113 AppenderPtr& appender,
114 apr_xml_doc* doc,
115 AppenderMap& appenders);
116
121 LOG4CXX_NS::helpers::Pool& p,
122 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
123 apr_xml_elem* element,
124 std::vector<LOG4CXX_NS::spi::FilterPtr>& filters);
125
130 LOG4CXX_NS::helpers::Pool& p,
131 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
132 apr_xml_elem* loggerElement,
133 apr_xml_doc* doc,
134 AppenderMap& appenders);
135
140 LOG4CXX_NS::helpers::Pool& p,
141 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
142 apr_xml_elem* factoryElement);
143
147 LOG4CXX_NS::helpers::ObjectPtr parseTriggeringPolicy(
148 LOG4CXX_NS::helpers::Pool& p,
149 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
150 apr_xml_elem* factoryElement);
151
155 LOG4CXX_NS::rolling::RollingPolicyPtr parseRollingPolicy(
156 LOG4CXX_NS::helpers::Pool& p,
157 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
158 apr_xml_elem* factoryElement);
159
163 void parseRoot(LOG4CXX_NS::helpers::Pool& p,
164 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
165 apr_xml_elem* rootElement, apr_xml_doc* doc, AppenderMap& appenders);
166
171 LOG4CXX_NS::helpers::Pool& p,
172 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
173 apr_xml_elem* catElement,
174 LoggerPtr logger, bool isRoot,
175 apr_xml_doc* doc,
176 AppenderMap& appenders );
177
182 LOG4CXX_NS::helpers::Pool& p,
183 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
184 apr_xml_elem* layout_element);
185
190 LOG4CXX_NS::helpers::Pool& p,
191 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
192 apr_xml_elem* element,
193 LoggerPtr logger, bool isRoot);
194
196 LOG4CXX_NS::helpers::Pool& p,
197 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
198 apr_xml_elem* elem,
199 LOG4CXX_NS::config::PropertySetter& propSetter);
200
205 void parse(
206 LOG4CXX_NS::helpers::Pool& p,
207 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
208 apr_xml_elem* element,
209 apr_xml_doc* doc,
210 AppenderMap& appenders);
211#endif // LOG4CXX_ABI_VERSION <= 15
212
213 public:
215
220
221#if LOG4CXX_ABI_VERSION <= 15
222 DOMConfigurator(LOG4CXX_NS::helpers::Pool& p);
223
227 static spi::ConfigurationStatus configure(const char* filename) { return configure(std::string(filename)); }
231 static spi::ConfigurationStatus configure(const std::string& filename);
232#if LOG4CXX_WCHAR_T_API
236 static spi::ConfigurationStatus configure(const wchar_t* filename) { return configure(std::wstring(filename)); }
240 static spi::ConfigurationStatus configure(const std::wstring& filename);
241#endif
242#if LOG4CXX_UNICHAR_API || LOG4CXX_LOGCHAR_IS_UNICHAR
246 static spi::ConfigurationStatus configure(const std::basic_string<UniChar>& filename);
247#endif
248#if LOG4CXX_CFSTRING_API
253#endif
260 static spi::ConfigurationStatus configureAndWatch(const std::string& configFilename);
261#if LOG4CXX_WCHAR_T_API
268 static spi::ConfigurationStatus configureAndWatch(const std::wstring& configFilename);
269#endif
270#if LOG4CXX_UNICHAR_API || LOG4CXX_LOGCHAR_IS_UNICHAR
277 static spi::ConfigurationStatus configureAndWatch(const std::basic_string<UniChar>& configFilename);
278#endif
279#if LOG4CXX_CFSTRING_API
287#endif
301 static spi::ConfigurationStatus configureAndWatch(const std::string& configFilename,
302 long delay);
303#if LOG4CXX_WCHAR_T_API
307 static spi::ConfigurationStatus configureAndWatch(const std::wstring& configFilename,
308 long delay);
309#endif
310#if LOG4CXX_UNICHAR_API || LOG4CXX_LOGCHAR_IS_UNICHAR
314 static spi::ConfigurationStatus configureAndWatch(const std::basic_string<UniChar>& configFilename,
315 long delay);
316#endif
317#if LOG4CXX_CFSTRING_API
322 long delay);
323#endif
324#endif // LOG4CXX_ABI_VERSION <= 15
325
339 ( const File& filename
340#if LOG4CXX_ABI_VERSION <= 15
341 , spi::LoggerRepositoryPtr repository
342#else
344#endif
345 ) override;
346
351 static spi::ConfigurationStatus configure(const File& configFilename);
352
367 static spi::ConfigurationStatus configureAndWatch(const File& configFilename, long delay = 0);
368
369#if LOG4CXX_ABI_VERSION <= 15
370 protected:
372 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
373 apr_xml_elem*,
374 const std::string& attrName);
375
376 LogString subst(const LogString& value);
377#endif
378
379 private:
380 // prevent assignment or copy statements
382 DOMConfigurator& operator=(const DOMConfigurator&);
383
384 LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(DOMConfiguratorPrivate, m_priv)
385};
387} // namespace xml
388} // namespace log4cxx
389
390#endif /* LOG4CXX_HAS_DOMCONFIGURATOR */
391
392#endif // _LOG4CXX_XML_DOM_CONFIGURATOR_H
An abstract representation of file and directory path names.
Definition file.h:41
An abstract base for classes capable of configuring Log4cxx.
Definition configurator.h:40
Use this class to initialize the log4cxx environment using a DOM tree.
Definition domconfigurator.h:68
spi::ConfigurationStatus doConfigure(const File &filename, spi::LoggerRepositoryPtr repository) override
Interpret filename as an XML file and set up Log4cxx accordingly.
void parseErrorHandler(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *element, AppenderPtr &appender, apr_xml_doc *doc, AppenderMap &appenders)
Used internally to parse an ErrorHandler element.
void parseLevel(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *element, LoggerPtr logger, bool isRoot)
Used internally to parse a level element.
static spi::ConfigurationStatus configure(const std::basic_string< UniChar > &filename)
A static version of doConfigure.
static spi::ConfigurationStatus configure(const std::wstring &filename)
A static version of doConfigure.
void parseLoggerFactory(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *factoryElement)
Used internally to parse the logger factory element.
AppenderPtr parseAppender(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *appenderElement, apr_xml_doc *doc, AppenderMap &appenders)
Used internally to parse an appender element.
static spi::ConfigurationStatus configureAndWatch(const File &configFilename, long delay=0)
Read configuration options from configFilename (if it exists).
static spi::ConfigurationStatus configure(const char *filename)
A static version of doConfigure.
Definition domconfigurator.h:227
void parseRoot(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *rootElement, apr_xml_doc *doc, AppenderMap &appenders)
Used internally to parse the root logger element.
static spi::ConfigurationStatus configure(const CFStringRef &filename)
A static version of doConfigure.
log4cxx::helpers::ObjectPtr parseTriggeringPolicy(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *factoryElement)
Used internally to parse the logger factory element.
AppenderPtr findAppenderByReference(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *appenderRef, apr_xml_doc *doc, AppenderMap &appenders)
Used internally to parse appenders by IDREF element.
static spi::ConfigurationStatus configureAndWatch(const CFStringRef &configFilename, long delay)
Refer configureAndWatch(const File& filename, long delay)
static spi::ConfigurationStatus configureAndWatch(const CFStringRef &configFilename)
Like configureAndWatch(const File& filename, long delay) except that the default delay as defined by ...
DOMConfigurator(log4cxx::helpers::Pool &p)
static spi::ConfigurationStatus configure(const wchar_t *filename)
A static version of doConfigure.
Definition domconfigurator.h:236
static spi::ConfigurationStatus configureAndWatch(const std::basic_string< UniChar > &configFilename)
Like configureAndWatch(const File& filename, long delay) except that the default delay as defined by ...
std::map< LogString, AppenderPtr > AppenderMap
Definition domconfigurator.h:74
LayoutPtr parseLayout(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *layout_element)
Used internally to parse a layout element.
void setParameter(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *elem, log4cxx::config::PropertySetter &propSetter)
void parseFilters(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *element, std::vector< log4cxx::spi::FilterPtr > &filters)
Used internally to parse a filter element.
static spi::ConfigurationStatus configure(const File &configFilename)
Read configuration options from configFilename.
static spi::ConfigurationStatus configureAndWatch(const std::string &configFilename)
Like configureAndWatch(const File& filename, long delay) except that the default delay as defined by ...
static spi::ConfigurationStatus configureAndWatch(const std::string &configFilename, long delay)
Read the configuration file configFilename if it exists.
void parseChildrenOfLoggerElement(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *catElement, LoggerPtr logger, bool isRoot, apr_xml_doc *doc, AppenderMap &appenders)
Used internally to parse the children of a logger element.
LogString subst(const LogString &value)
AppenderPtr findAppenderByName(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *elem, apr_xml_doc *doc, const LogString &appenderName, AppenderMap &appenders)
Used internally to parse appenders by IDREF name.
void parseLogger(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *loggerElement, apr_xml_doc *doc, AppenderMap &appenders)
Used internally to parse a logger element.
static spi::ConfigurationStatus configure(const std::string &filename)
A static version of doConfigure.
log4cxx::rolling::RollingPolicyPtr parseRollingPolicy(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *factoryElement)
Used internally to parse the logger factory element.
static LogString getAttribute(log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *, const std::string &attrName)
static spi::ConfigurationStatus configureAndWatch(const std::wstring &configFilename, long delay)
Refer configureAndWatch(const File& filename, long delay)
static spi::ConfigurationStatus configureAndWatch(const std::basic_string< UniChar > &configFilename, long delay)
Refer configureAndWatch(const File& filename, long delay)
void parse(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *element, apr_xml_doc *doc, AppenderMap &appenders)
Used internally to configure the log4cxx framework from an in-memory representation of an XML documen...
static spi::ConfigurationStatus configureAndWatch(const std::wstring &configFilename)
Like configureAndWatch(const File& filename, long delay) except that the default delay as defined by ...
const struct __CFString * CFStringRef
Definition logstring.h:30
Definition appender.h:30
std::shared_ptr< LoggerRepository > LoggerRepositoryPtr
Definition optionconverter.h:33
ConfigurationStatus
Definition configurator.h:31
Definition domconfigurator.h:48
LOG4CXX_PTR_DEF(DOMConfigurator)
std::basic_string< logchar > LogString
Definition logstring.h:60
std::shared_ptr< Layout > LayoutPtr
Definition appender.h:42
std::shared_ptr< Appender > AppenderPtr
Definition basicconfigurator.h:29
std::shared_ptr< Logger > LoggerPtr
Definition defaultloggerfactory.h:27
#define LOG4CXX_CAST_ENTRY(Interface)
Definition object.h:154
#define END_LOG4CXX_CAST_MAP()
Definition object.h:148
#define DECLARE_LOG4CXX_OBJECT(object)
Definition object.h:41
#define BEGIN_LOG4CXX_CAST_MAP()
Definition object.h:142