Apache Log4cxx  Version 1.8.0
Loading...
Searching...
No Matches
propertyconfigurator.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_PROPERTY_CONFIGURATOR_H
19#define _LOG4CXX_PROPERTY_CONFIGURATOR_H
20
22#include <log4cxx/logstring.h>
24#include <map>
25
26#include <log4cxx/file.h>
27
28namespace LOG4CXX_NS
29{
30class Logger;
31typedef std::shared_ptr<Logger> LoggerPtr;
32
33class Appender;
34typedef std::shared_ptr<Appender> AppenderPtr;
35
36namespace helpers
37{
38class Properties;
39}
40
41
42namespace spi
43{
44class LoggerFactory;
45typedef std::shared_ptr<LoggerFactory> LoggerFactoryPtr;
46}
47
48class PropertyWatchdog;
248class LOG4CXX_EXPORT PropertyConfigurator
249#if LOG4CXX_ABI_VERSION <= 15
250 : virtual public spi::Configurator
251 , virtual public helpers::Object
252#else
253 : public spi::Configurator
254#endif
255{
256#if 15 < LOG4CXX_ABI_VERSION
257 private:
258 LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(PrivateData, m_priv)
259#else
260 protected:
261
265 std::map<LogString, AppenderPtr>* registry;
266
270 LOG4CXX_DECLARE_PRIVATE_MEMBER(spi::LoggerFactoryPtr, loggerFactory)
271#endif
272 public:
275#if 15 < LOG4CXX_ABI_VERSION
278#else
280#endif
282
297 spi::ConfigurationStatus doConfigure
298 ( const File& configFileName
299#if LOG4CXX_ABI_VERSION <= 15
300 , spi::LoggerRepositoryPtr repository
301#else
303#endif
304 ) override;
305
310 static spi::ConfigurationStatus configure(const File& configFilename);
311
312#if LOG4CXX_ABI_VERSION <= 15
320 static spi::ConfigurationStatus configureAndWatch(const File& configFilename);
321#endif
337 static spi::ConfigurationStatus configureAndWatch(const File& configFilename,
338 long delay = 0);
339
347
354 spi::LoggerRepositoryPtr hierarchy);
355
356 // --------------------------------------------------------------------------
357 // Internal stuff
358 // --------------------------------------------------------------------------
359 protected:
369
371 spi::LoggerRepositoryPtr& hierarchy);
372
377 spi::LoggerRepositoryPtr& hierarchy);
378
383 LoggerPtr& cat, const LogString& loggerName);
384
389 helpers::Properties& props, LoggerPtr& logger,
390 const LogString& optionKey, const LogString& loggerName,
391 const LogString& value, bool additivity);
392
394 helpers::Properties& props, const LogString& appenderName);
395
396 void registryPut(const AppenderPtr& appender);
398
399 private:
402}; // class PropertyConfigurator
403} // namespace log4cxx
404
405
406#endif //_LOG4CXX_PROPERTY_CONFIGURATOR_H
An abstract representation of file and directory path names.
Definition file.h:41
spi::ConfigurationStatus doConfigure(helpers::Properties &properties, spi::LoggerRepositoryPtr hierarchy)
Read configuration options from properties.
static spi::ConfigurationStatus configure(helpers::Properties &properties)
Read configuration options from properties.
void registryPut(const AppenderPtr &appender)
static spi::ConfigurationStatus configureAndWatch(const File &configFilename)
Like configureAndWatch(const File& configFilename, long delay) except that the default delay as defin...
void configureLoggerFactory(helpers::Properties &props)
Check the provided Properties object for a LoggerFactory entry specified by log4j....
std::map< LogString, AppenderPtr > * registry
Used internally to keep track of configured appenders.
Definition propertyconfigurator.h:265
spi::ConfigurationStatus doConfigure(const File &configFileName, spi::LoggerRepositoryPtr repository) override
Read configuration from configFileName.
bool parseAdditivityForLogger(helpers::Properties &props, LoggerPtr &cat, const LogString &loggerName)
Parse the additivity option for a non-root logger.
static spi::ConfigurationStatus configureAndWatch(const File &configFilename, long delay=0)
Read configuration options from configFilename (if it exists).
AppenderPtr registryGet(const LogString &name)
void configureRootLogger(helpers::Properties &props, spi::LoggerRepositoryPtr &hierarchy)
AppenderPtr parseAppender(helpers::Properties &props, const LogString &appenderName)
PropertyConfigurator()
Used to create new instances of logger.
void parseCatsAndRenderers(helpers::Properties &props, spi::LoggerRepositoryPtr &hierarchy)
Parse non-root elements, such non-root categories and renderers.
void parseLogger(helpers::Properties &props, LoggerPtr &logger, const LogString &optionKey, const LogString &loggerName, const LogString &value, bool additivity)
This method must work for the root logger as well.
static spi::ConfigurationStatus configure(const File &configFilename)
Read configuration options from file configFilename.
base class for java-like objects.
Definition object.h:102
Definition properties.h:33
An abstract base for classes capable of configuring Log4cxx.
Definition configurator.h:40
static helpers::Properties & properties()
The key value pairs used when expanding ${varname} instances in a configuration file.
Definition appender.h:30
std::shared_ptr< LoggerRepository > LoggerRepositoryPtr
Definition optionconverter.h:33
ConfigurationStatus
Definition configurator.h:31
std::shared_ptr< LoggerFactory > LoggerFactoryPtr
Definition logmanager.h:34
std::basic_string< logchar > LogString
Definition logstring.h:60
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 LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition object.h:160
#define BEGIN_LOG4CXX_CAST_MAP()
Definition object.h:142