Apache Log4cxx  Version 1.6.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 virtual public spi::Configurator,
250 virtual public helpers::Object
251{
252#if 15 < LOG4CXX_ABI_VERSION
253 private:
254 struct PrivateData;
255 LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(PrivateData, m_priv)
256#else
257 protected:
258
262 std::map<LogString, AppenderPtr>* registry;
263
267 LOG4CXX_DECLARE_PRIVATE_MEMBER(spi::LoggerFactoryPtr, loggerFactory)
268#endif
269 public:
272#if 15 < LOG4CXX_ABI_VERSION
275#else
277#endif
279
294 spi::ConfigurationStatus doConfigure
295 ( const File& configFileName
296#if LOG4CXX_ABI_VERSION <= 15
297 , spi::LoggerRepositoryPtr repository
298#else
300#endif
301 ) override;
302
307 static spi::ConfigurationStatus configure(const File& configFilename);
308
309#if LOG4CXX_ABI_VERSION <= 15
317 static spi::ConfigurationStatus configureAndWatch(const File& configFilename);
318#endif
334 static spi::ConfigurationStatus configureAndWatch(const File& configFilename,
335 long delay = 0);
336
344
351 spi::LoggerRepositoryPtr hierarchy);
352
353 // --------------------------------------------------------------------------
354 // Internal stuff
355 // --------------------------------------------------------------------------
356 protected:
366
368 spi::LoggerRepositoryPtr& hierarchy);
369
374 spi::LoggerRepositoryPtr& hierarchy);
375
380 LoggerPtr& cat, const LogString& loggerName);
381
386 helpers::Properties& props, LoggerPtr& logger,
387 const LogString& optionKey, const LogString& loggerName,
388 const LogString& value, bool additivity);
389
391 helpers::Properties& props, const LogString& appenderName);
392
393 void registryPut(const AppenderPtr& appender);
395
396 private:
399}; // class PropertyConfigurator
400} // namespace log4cxx
401
402
403#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:262
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:106
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:158
#define END_LOG4CXX_CAST_MAP()
Definition object.h:152
#define DECLARE_LOG4CXX_OBJECT(object)
Definition object.h:43
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition object.h:164
#define BEGIN_LOG4CXX_CAST_MAP()
Definition object.h:146