Apache Log4cxx  Version 1.2.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>
22#include <map>
23#include <log4cxx/appender.h>
24#include <log4cxx/layout.h>
25#include <log4cxx/logger.h>
29#include <log4cxx/spi/filter.h>
32#include <log4cxx/file.h>
34
35#if LOG4CXX_HAS_DOMCONFIGURATOR
36
37extern "C" {
38 struct apr_xml_doc;
39 struct apr_xml_elem;
40}
41
42namespace LOG4CXX_NS
43{
44
45namespace xml
46{
47class XMLWatchdog;
48
64class LOG4CXX_EXPORT DOMConfigurator :
65 virtual public spi::Configurator
66{
67 public:
69
70 protected:
71 typedef std::map<LogString, AppenderPtr> AppenderMap;
76 LOG4CXX_NS::helpers::Pool& p,
77 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
78 apr_xml_elem* elem,
79 apr_xml_doc* doc,
80 const LogString& appenderName,
81 AppenderMap& appenders);
82
87 LOG4CXX_NS::helpers::Pool& p,
88 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
89 apr_xml_elem* appenderRef,
90 apr_xml_doc* doc,
91 AppenderMap& appenders);
92
97 LOG4CXX_NS::helpers::Pool& p,
98 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
99 apr_xml_elem* appenderElement,
100 apr_xml_doc* doc,
101 AppenderMap& appenders);
102
107 LOG4CXX_NS::helpers::Pool& p,
108 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
109 apr_xml_elem* element,
110 AppenderPtr& appender,
111 apr_xml_doc* doc,
112 AppenderMap& appenders);
113
118 LOG4CXX_NS::helpers::Pool& p,
119 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
120 apr_xml_elem* element,
121 std::vector<LOG4CXX_NS::spi::FilterPtr>& filters);
122
127 LOG4CXX_NS::helpers::Pool& p,
128 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
129 apr_xml_elem* loggerElement,
130 apr_xml_doc* doc,
131 AppenderMap& appenders);
132
137 LOG4CXX_NS::helpers::Pool& p,
138 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
139 apr_xml_elem* factoryElement);
140
144 LOG4CXX_NS::helpers::ObjectPtr parseTriggeringPolicy(
145 LOG4CXX_NS::helpers::Pool& p,
146 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
147 apr_xml_elem* factoryElement);
148
152 LOG4CXX_NS::rolling::RollingPolicyPtr parseRollingPolicy(
153 LOG4CXX_NS::helpers::Pool& p,
154 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
155 apr_xml_elem* factoryElement);
156
160 void parseRoot(LOG4CXX_NS::helpers::Pool& p,
161 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
162 apr_xml_elem* rootElement, apr_xml_doc* doc, AppenderMap& appenders);
163
168 LOG4CXX_NS::helpers::Pool& p,
169 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
170 apr_xml_elem* catElement,
171 LoggerPtr logger, bool isRoot,
172 apr_xml_doc* doc,
173 AppenderMap& appenders );
174
179 LOG4CXX_NS::helpers::Pool& p,
180 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
181 apr_xml_elem* layout_element);
182
187 LOG4CXX_NS::helpers::Pool& p,
188 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
189 apr_xml_elem* element,
190 LoggerPtr logger, bool isRoot);
191
193 LOG4CXX_NS::helpers::Pool& p,
194 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
195 apr_xml_elem* elem,
196 LOG4CXX_NS::config::PropertySetter& propSetter);
197
202 void parse(
203 LOG4CXX_NS::helpers::Pool& p,
204 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
205 apr_xml_elem* element,
206 apr_xml_doc* doc,
207 AppenderMap& appenders);
208
209 public:
211
214 LOG4CXX_CAST_ENTRY(spi::Configurator)
216
217 DOMConfigurator(LOG4CXX_NS::helpers::Pool& p);
218
222 static spi::ConfigurationStatus configure(const std::string& filename);
223#if LOG4CXX_WCHAR_T_API
227 static spi::ConfigurationStatus configure(const std::wstring& filename);
228#endif
229#if LOG4CXX_UNICHAR_API || LOG4CXX_LOGCHAR_IS_UNICHAR
233 static spi::ConfigurationStatus configure(const std::basic_string<UniChar>& filename);
234#endif
235#if LOG4CXX_CFSTRING_API
240#endif
247 static spi::ConfigurationStatus configureAndWatch(const std::string& configFilename);
248#if LOG4CXX_WCHAR_T_API
255 static spi::ConfigurationStatus configureAndWatch(const std::wstring& configFilename);
256#endif
257#if LOG4CXX_UNICHAR_API || LOG4CXX_LOGCHAR_IS_UNICHAR
264 static spi::ConfigurationStatus configureAndWatch(const std::basic_string<UniChar>& configFilename);
265#endif
266#if LOG4CXX_CFSTRING_API
274#endif
290 static spi::ConfigurationStatus configureAndWatch(const std::string& configFilename,
291 long delay);
292#if LOG4CXX_WCHAR_T_API
296 static spi::ConfigurationStatus configureAndWatch(const std::wstring& configFilename,
297 long delay);
298#endif
299#if LOG4CXX_UNICHAR_API || LOG4CXX_LOGCHAR_IS_UNICHAR
303 static spi::ConfigurationStatus configureAndWatch(const std::basic_string<UniChar>& configFilename,
304 long delay);
305#endif
306#if LOG4CXX_CFSTRING_API
311 long delay);
312#endif
313
322 spi::LoggerRepositoryPtr repository) override;
323
324 protected:
326 LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder,
327 apr_xml_elem*,
328 const std::string& attrName);
329
330 LogString subst(const LogString& value);
331
332 private:
333 // prevent assignment or copy statements
335 DOMConfigurator& operator=(const DOMConfigurator&);
336 static XMLWatchdog* xdog;
337
338 LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(DOMConfiguratorPrivate, m_priv)
339};
341} // namespace xml
342} // namespace log4cxx
343
344#endif /* LOG4CXX_HAS_DOMCONFIGURATOR */
345
346#endif // _LOG4CXX_XML_DOM_CONFIGURATOR_H
An abstract representation of file and directory path names.
Definition: file.h:41
Implemented by classes capable of configuring log4j using a URL.
Definition: configurator.h:39
Use this class to initialize the log4cxx environment using a DOM tree.
Definition: domconfigurator.h:66
spi::ConfigurationStatus doConfigure(const File &filename, spi::LoggerRepositoryPtr repository) override
Interpret the XML file pointed by filename 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.
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 std::string& configFilename, long delay)
static spi::ConfigurationStatus configureAndWatch(const CFStringRef &configFilename)
Like configureAndWatch(const std::string& configFilename, long delay) except that the default delay a...
static spi::ConfigurationStatus configureAndWatch(const std::basic_string< UniChar > &configFilename)
Like configureAndWatch(const std::string& configFilename, long delay) except that the default delay a...
std::map< LogString, AppenderPtr > AppenderMap
Definition: domconfigurator.h:71
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 configureAndWatch(const std::string &configFilename)
Like configureAndWatch(const std::string& configFilename, long delay) except that the default delay a...
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.
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 std::string& configFilename, long delay)
static spi::ConfigurationStatus configureAndWatch(const std::basic_string< UniChar > &configFilename, long delay)
Refer configureAndWatch(const std::string& configFilename, 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 std::string& configFilename, long delay) except that the default delay a...
const struct __CFString * CFStringRef
Definition: logstring.h:30
std::shared_ptr< LoggerRepository > LoggerRepositoryPtr
Definition: optionconverter.h:33
ConfigurationStatus
Definition: configurator.h:30
std::basic_string< logchar > LogString
Definition: logstring.h:60
std::shared_ptr< Layout > LayoutPtr
Definition: appender.h:42
LOG4CXX_PTR_DEF(Appender)
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:158
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:152
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:43
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:146