Apache Log4cxx  Version 1.3.1
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 protected:
253
257 std::map<LogString, AppenderPtr>* registry;
258
262 LOG4CXX_DECLARE_PRIVATE_MEMBER(spi::LoggerFactoryPtr, loggerFactory)
263
264 public:
267#if 15 < LOG4CXX_ABI_VERSION
270#else
272#endif
274
289 spi::ConfigurationStatus doConfigure
290 ( const File& configFileName
291#if LOG4CXX_ABI_VERSION <= 15
292 , spi::LoggerRepositoryPtr repository
293#else
295#endif
296 ) override;
297
302 static spi::ConfigurationStatus configure(const File& configFilename);
303
304#if LOG4CXX_ABI_VERSION <= 15
312 static spi::ConfigurationStatus configureAndWatch(const File& configFilename);
313#endif
329 static spi::ConfigurationStatus configureAndWatch(const File& configFilename,
330 long delay = 0);
331
339
346 spi::LoggerRepositoryPtr hierarchy);
347
348 // --------------------------------------------------------------------------
349 // Internal stuff
350 // --------------------------------------------------------------------------
351 protected:
361
363 spi::LoggerRepositoryPtr& hierarchy);
364
369 spi::LoggerRepositoryPtr& hierarchy);
370
375 LoggerPtr& cat, const LogString& loggerName);
376
381 helpers::Properties& props, LoggerPtr& logger,
382 const LogString& optionKey, const LogString& loggerName,
383 const LogString& value, bool additivity);
384
386 helpers::Properties& props, const LogString& appenderName);
387
388 void registryPut(const AppenderPtr& appender);
390
391 private:
394 static PropertyWatchdog* pdog;
395}; // class PropertyConfigurator
396} // namespace log4cxx
397
398
399#endif //_LOG4CXX_PROPERTY_CONFIGURATOR_H
An abstract representation of file and directory path names.
Definition: file.h:41
Allows the configuration of log4cxx from an external file.
Definition: propertyconfigurator.h:251
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:257
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)
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
Implemented by classes capable of configuring log4j using a URL.
Definition: configurator.h:39
std::shared_ptr< LoggerRepository > LoggerRepositoryPtr
Definition: optionconverter.h:33
ConfigurationStatus
Definition: configurator.h:30
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