Apache log4cxx Version 0.13.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
21#if defined(_MSC_VER)
22 #pragma warning (push)
23 #pragma warning ( disable: 4231 4251 4275 4786 )
24#endif
25
26
28#include <log4cxx/logstring.h>
30#include <map>
31
32#include <log4cxx/file.h>
33
34namespace log4cxx
35{
36class Logger;
37typedef std::shared_ptr<Logger> LoggerPtr;
38
39class Appender;
40typedef std::shared_ptr<Appender> AppenderPtr;
41
42namespace helpers
43{
44class Properties;
45}
46
47
48namespace spi
49{
50class LoggerFactory;
51}
52
53class PropertyWatchdog;
92class 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
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:
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
An abstract representation of file and directory path names.
Definition: file.h:46
Allows the configuration of log4cxx from an external file.
Definition: propertyconfigurator.h:95
std::map< LogString, AppenderPtr > * registry
Used internally to keep track of configured appenders.
Definition: propertyconfigurator.h:101
std::shared_ptr< spi::LoggerFactory > loggerFactory
Used to create new instances of logger.
Definition: propertyconfigurator.h:106
base class for java-like objects.
Definition: object.h:102
Implemented by classes capable of configuring log4j using a URL.
Definition: configurator.h:33
Definition: messagehandler.h:23
std::basic_string< logchar > LogString
Definition: logstring.h:66
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:153
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:147
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:39
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:141