Apache Log4cxx Version 1.0.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
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;
85class LOG4CXX_EXPORT PropertyConfigurator :
86 virtual public spi::Configurator,
87 virtual public helpers::Object
88{
89 protected:
90
94 std::map<LogString, AppenderPtr>* registry;
95
99 LOG4CXX_DECLARE_PRIVATE_MEMBER(spi::LoggerFactoryPtr, loggerFactory)
100
101 public:
104 LOG4CXX_CAST_ENTRY(spi::Configurator)
106
285 spi::ConfigurationStatus doConfigure(const File& configFileName,
286 spi::LoggerRepositoryPtr hierarchy) override;
287
291 static spi::ConfigurationStatus configure(const File& configFilename);
292
300 static spi::ConfigurationStatus configureAndWatch(const File& configFilename);
301
313 static spi::ConfigurationStatus configureAndWatch(const File& configFilename,
314 long delay);
315
321 static spi::ConfigurationStatus configure(helpers::Properties& properties);
322
328 spi::ConfigurationStatus doConfigure(helpers::Properties& properties,
329 spi::LoggerRepositoryPtr hierarchy);
330
331 // --------------------------------------------------------------------------
332 // Internal stuff
333 // --------------------------------------------------------------------------
334 protected:
343 void configureLoggerFactory(helpers::Properties& props);
344
345 void configureRootLogger(helpers::Properties& props,
346 spi::LoggerRepositoryPtr& hierarchy);
347
351 void parseCatsAndRenderers(helpers::Properties& props,
352 spi::LoggerRepositoryPtr& hierarchy);
353
357 bool parseAdditivityForLogger(helpers::Properties& props,
358 LoggerPtr& cat, const LogString& loggerName);
359
363 void parseLogger(
364 helpers::Properties& props, LoggerPtr& logger,
365 const LogString& optionKey, const LogString& loggerName,
366 const LogString& value, bool additivity);
367
368 AppenderPtr parseAppender(
369 helpers::Properties& props, const LogString& appenderName);
370
371 void registryPut(const AppenderPtr& appender);
372 AppenderPtr registryGet(const LogString& name);
373
374 private:
377 static PropertyWatchdog* pdog;
378}; // class PropertyConfigurator
379} // namespace log4cxx
380
381
382#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:88
std::map< LogString, AppenderPtr > * registry
Used internally to keep track of configured appenders.
Definition: propertyconfigurator.h:94
base class for java-like objects.
Definition: object.h:105
Implemented by classes capable of configuring log4j using a URL.
Definition: configurator.h:39
std::shared_ptr< LoggerFactory > LoggerFactoryPtr
Definition: logmanager.h:34
Definition: configuration.h:25
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:157
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:151
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:42
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:145