Apache Log4cxx  Version 2.0.0
Loading...
Searching...
No Matches
logmanager.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_LOG_MANAGER_H
19#define _LOG4CXX_LOG_MANAGER_H
20
21#include <log4cxx/logstring.h>
22#include <vector>
23
24namespace LOG4CXX_NS
25{
26class Logger;
27LOG4CXX_PTR_DEF(Logger);
28LOG4CXX_LIST_DEF(LoggerList, LoggerPtr);
29
30namespace spi
31{
32class LoggerFactory;
33LOG4CXX_PTR_DEF(LoggerFactory);
34class RepositorySelector;
38}
39
47class LOG4CXX_EXPORT LogManager
48{
49 private:
50 static void* guard;
51 static spi::RepositorySelectorPtr getRepositorySelector();
52
53 public:
69 static void setRepositorySelector(const spi::RepositorySelectorPtr& selector, void* guard);
70
72
80
89 static LoggerPtr getLogger(const std::string& name,
90 const spi::LoggerFactoryPtr& factory = {});
96 static LoggerPtr exists(const std::string& name);
97#if LOG4CXX_WCHAR_T_API
106 static LoggerPtr getLogger(const std::wstring& name,
107 const spi::LoggerFactoryPtr& factory = {});
113 static LoggerPtr exists(const std::wstring& name);
114#endif
115#if LOG4CXX_CFSTRING_API
125 static LoggerPtr getLogger(const CFStringRef& name,
126 const spi::LoggerFactoryPtr& factory = {});
132 static LoggerPtr exists(const CFStringRef& name);
133#endif
134
144 static LoggerPtr getLoggerLS(const LogString& name,
145 const spi::LoggerFactoryPtr& factory = {});
146
152 static LoggerPtr existsLS(const LogString& name);
153
154 static LoggerList getCurrentLoggers();
155
160 static void shutdown();
161
167 static void resetConfiguration();
168
180 static bool removeLogger(const LogString& name, bool ifNotUsed = true);
181}; // class LogManager
182} // namespace log4cxx
183
184
185#endif //_LOG4CXX_LOG_MANAGER_H
Use the LogManager class to retreive Logger instances or to operate on the current LoggerRepository.
Definition logmanager.h:48
static LoggerPtr getLoggerLS(const LogString &name, const spi::LoggerFactoryPtr &factory={})
Retrieve the name Logger instance from the LoggerRepository using factory to create it if required.
static LoggerPtr exists(const std::wstring &name)
A pointer to the Logger name instance if it exists in the LoggerRepository.
static LoggerPtr existsLS(const LogString &name)
A pointer to the Logger name instance if it exists in the LoggerRepository.
static void setRepositorySelector(const spi::RepositorySelectorPtr &selector, void *guard)
Use selector to source the LoggerRepository, but only if the correct guard is passed as parameter.
static spi::LoggerRepositoryPtr getLoggerRepository()
static bool removeLogger(const LogString &name, bool ifNotUsed=true)
Remove the name Logger from the LoggerRepository.
static LoggerPtr getLogger(const std::wstring &name, const spi::LoggerFactoryPtr &factory={})
Retrieve the name Logger instance from the LoggerRepository using factory to create it if required.
static LoggerPtr getRootLogger()
Retrieve the root logger from the LoggerRepository.
static LoggerPtr getLogger(const CFStringRef &name, const spi::LoggerFactoryPtr &factory={})
Retrieve the name Logger instance from the LoggerRepository using factory to create it if required.
static LoggerList getCurrentLoggers()
static LoggerPtr exists(const CFStringRef &name)
A pointer to the Logger name instance if it exists in the LoggerRepository.
static void resetConfiguration()
Reset all values contained in this current LoggerRepository to their default.
static LoggerPtr getLogger(const std::string &name, const spi::LoggerFactoryPtr &factory={})
Retrieve the name Logger instance from the LoggerRepository using factory to create it if required.
static void shutdown()
Safely close and remove all appenders in all loggers including the root logger.
static LoggerPtr exists(const std::string &name)
A pointer to the Logger name instance if it exists in the LoggerRepository.
A LoggerRepository is used to create and retrieve Loggers.
Definition loggerrepository.h:43
The LogManager uses one (and only one) RepositorySelector implementation to select the LoggerReposito...
Definition repositoryselector.h:43
const struct __CFString * CFStringRef
Definition logstring.h:30
std::shared_ptr< LoggerRepository > LoggerRepositoryPtr
Definition repositoryselector.h:28
LOG4CXX_PTR_DEF(LoggingEvent)
LOG4CXX_LIST_DEF(AppenderList, AppenderPtr)
std::basic_string< logchar > LogString
Definition logstring.h:51
LOG4CXX_PTR_DEF(Appender)
std::shared_ptr< Logger > LoggerPtr
Definition provisionnode.h:28