Apache Log4cxx  Version 1.2.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;
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
286 spi::ConfigurationStatus doConfigure(const File& configFileName,
287 spi::LoggerRepositoryPtr hierarchy) override;
288
292 static spi::ConfigurationStatus configure(const File& configFilename);
293
301 static spi::ConfigurationStatus configureAndWatch(const File& configFilename);
302
318 static spi::ConfigurationStatus configureAndWatch(const File& configFilename,
319 long delay);
320
326 static spi::ConfigurationStatus configure(helpers::Properties& properties);
327
333 spi::ConfigurationStatus doConfigure(helpers::Properties& properties,
334 spi::LoggerRepositoryPtr hierarchy);
335
336 // --------------------------------------------------------------------------
337 // Internal stuff
338 // --------------------------------------------------------------------------
339 protected:
348 void configureLoggerFactory(helpers::Properties& props);
349
350 void configureRootLogger(helpers::Properties& props,
351 spi::LoggerRepositoryPtr& hierarchy);
352
356 void parseCatsAndRenderers(helpers::Properties& props,
357 spi::LoggerRepositoryPtr& hierarchy);
358
362 bool parseAdditivityForLogger(helpers::Properties& props,
363 LoggerPtr& cat, const LogString& loggerName);
364
368 void parseLogger(
369 helpers::Properties& props, LoggerPtr& logger,
370 const LogString& optionKey, const LogString& loggerName,
371 const LogString& value, bool additivity);
372
373 AppenderPtr parseAppender(
374 helpers::Properties& props, const LogString& appenderName);
375
376 void registryPut(const AppenderPtr& appender);
377 AppenderPtr registryGet(const LogString& name);
378
379 private:
382 static PropertyWatchdog* pdog;
383}; // class PropertyConfigurator
384} // namespace log4cxx
385
386
387#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:106
Implemented by classes capable of configuring log4j using a URL.
Definition: configurator.h:39
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 BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:146