Apache log4cxx  Version 0.12.0
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 
21 #if defined(_MSC_VER)
22  #pragma warning (push)
23  #pragma warning ( disable: 4231 4251 4275 4786 )
24 #endif
25 
26 
27 #include <log4cxx/helpers/object.h>
28 #include <log4cxx/logstring.h>
30 #include <map>
31 
32 #include <log4cxx/file.h>
33 
34 namespace log4cxx
35 {
36 class Logger;
37 typedef std::shared_ptr<Logger> LoggerPtr;
38 
39 class Appender;
40 typedef std::shared_ptr<Appender> AppenderPtr;
41 
42 namespace helpers
43 {
44 class Properties;
45 }
46 
47 
48 namespace spi
49 {
50 class LoggerFactory;
51 }
52 
53 class PropertyWatchdog;
92 class LOG4CXX_EXPORT PropertyConfigurator :
93  virtual public spi::Configurator,
94  virtual public helpers::Object
95 {
96  protected:
97 
101  std::map<LogString, AppenderPtr>* registry;
102 
106  std::shared_ptr<spi::LoggerFactory> loggerFactory;
107 
108  public:
111  LOG4CXX_CAST_ENTRY(spi::Configurator)
113 
115  virtual ~PropertyConfigurator();
292  void doConfigure(const File& configFileName,
293  spi::LoggerRepositoryPtr hierarchy);
294 
298  static void configure(const File& configFilename);
299 
307  static void configureAndWatch(const File& configFilename);
308 
320  static void configureAndWatch(const File& configFilename,
321  long delay);
322 
328  static void configure(helpers::Properties& properties);
329 
335  void doConfigure(helpers::Properties& properties,
336  spi::LoggerRepositoryPtr hierarchy);
337 
338  // --------------------------------------------------------------------------
339  // Internal stuff
340  // --------------------------------------------------------------------------
341  protected:
351  void configureLoggerFactory(helpers::Properties& props);
352 
353  void configureRootLogger(helpers::Properties& props,
354  spi::LoggerRepositoryPtr& hierarchy);
355 
359  void parseCatsAndRenderers(helpers::Properties& props,
360  spi::LoggerRepositoryPtr& hierarchy);
361 
365  bool parseAdditivityForLogger(helpers::Properties& props,
366  LoggerPtr& cat, const LogString& loggerName);
367 
371  void parseLogger(
372  helpers::Properties& props, LoggerPtr& logger,
373  const LogString& optionKey, const LogString& loggerName,
374  const LogString& value, bool additivity);
375 
376  AppenderPtr parseAppender(
377  helpers::Properties& props, const LogString& appenderName);
378 
379  void registryPut(const AppenderPtr& appender);
380  AppenderPtr registryGet(const LogString& name);
381 
382  private:
383  PropertyConfigurator(const PropertyConfigurator&);
384  PropertyConfigurator& operator=(const PropertyConfigurator&);
385  static PropertyWatchdog* pdog;
386 }; // class PropertyConfigurator
387 } // namespace log4cxx
388 
389 #if defined(_MSC_VER)
390  #pragma warning (pop)
391 #endif
392 
393 
394 #endif //_LOG4CXX_PROPERTY_CONFIGURATOR_H
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:148
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:142
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:136
std::shared_ptr< spi::LoggerFactory > loggerFactory
Used to create new instances of logger.
Definition: propertyconfigurator.h:106
Allows the configuration of log4cxx from an external file.
Definition: propertyconfigurator.h:92
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:39
base class for java-like objects.
Definition: object.h:101
std::shared_ptr< LoggerRepository > LoggerRepositoryPtr
Definition: defaultconfigurator.h:27
std::shared_ptr< Appender > AppenderPtr
Definition: basicconfigurator.h:28
std::map< LogString, AppenderPtr > * registry
Used internally to keep track of configured appenders.
Definition: propertyconfigurator.h:101
Implemented by classes capable of configuring log4j using a URL.
Definition: configurator.h:32
std::shared_ptr< Logger > LoggerPtr
Definition: defaultloggerfactory.h:26
An abstract representation of file and directory path names.
Definition: file.h:45
Definition: appender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:66