Added two articles: OLDB Logs, CII Logs in general authored by Marcus Schilling's avatar Marcus Schilling
......@@ -1298,6 +1298,34 @@ A test application showing its use is here:
### [OLDB]
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
### Less or More Logs [OLDB Log]
**Problem**
You are using the OLDB API, and you are getting more logs than you asked for. For example, simply testing for the existence of a datapoint: `[ERROR] Path not found config exception occurred: Path oldb/datapoints/myroot/somedp, version 1 not found`
or, the OLDB API seems to be misbehaving, and you want more logs.
**Solution**
Please read the article "[Adjust CII Log Levels [Log]](#user-content-adjust-cii-log-levels-log)" in the Log section of this Knowledge Base. The relevant logger names for the OLDB API are:
```
CiiOldb
CiiOldbDirectoryTreeProvider
CiiOldbFactory
CiiOldbRedisDataPointProvider
CiiOldbRemoteDataPointProvider
CiiOldbRemoteFileProvider
```
Example: to turn off ERROR logs for testing the existence of non-existing datapoints, use:
```
log4cplus.logger.CiiOldbRemoteDataPointProvider=FATAL
```
--------------------------------------------------------------------------
......@@ -1740,8 +1768,6 @@ Type "help", "copyright", "credits" or "license" for more information.
### [Log]
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
......@@ -1778,6 +1804,72 @@ elt.log.CiiLogManager.set_log_level(name_or_logger: Union\[str, logging.Logger\]
```
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
### Adjust CII Log Levels [Log]
With plain CII (no application frameworks on top), you define a log config file (myapp.logconfig):
```
log4cplus.rootLogger=INFO, STDOUT
log4cplus.appender.STDOUT=log4cplus::ConsoleAppender
log4cplus.appender.STDOUT.layout=elt::log::layout::CiiSimpleLayout
# other loggers, e.g. OLDB or MAL
log4cplus.logger.CiiOldb=FATAL
```
The name of the log config is your choice, but to comply with the rules of "waf install", best use such a project structure:
```
myapp/
├── resource
│ └── config
│ └── myapp.logconfig
├── src
│ ├── myapp.cpp
└── wscript
```
Then apply the log config from your application (myapp.cpp):
```
#include <ciiLogManager.hpp>
int main(int ac, char *av[]) {
::elt::log::CiiLogManager::Configure("resource/config/myapp.logconfig");
log4cplus::Logger root_logger = ::elt::log::CiiLogManager::GetLogger();
root_logger.log(log4cplus::INFO_LOG_LEVEL, "Message via root logger");
return 0;
}
```
**List of Loggers**
Generally, to learn about all loggers that are active in your application, add this (temporarily) to your application:
```
#include <ciiLogManager.hpp>
[...]
std::cout << "Current loggers (in addition to root logger):" << std::endl;
std::vector<log4cplus::Logger> list = log4cplus::Logger::getCurrentLoggers();
for (int i=0,n=list.size(); i<n; i++) {
log4cplus::Logger elem = list[i];
std::cout << elem.getName() << std::endl;
}
```
Note: With the next version of CII, the logger name will be included in log messages by default.
**Log Format**
To use a different log format (which CII allows, but the Control System guidelines do not), you can modify the above config like this:
```
#log4cplus.appender.STDOUT.layout=elt::log::layout::CiiSimpleLayout
log4cplus.appender.STDOUT.layout=log4cplus::PatternLayout
log4cplus.appender.STDOUT.layout.ConversionPattern=[%-5p][%D{%Y/%m/%d %H:%M:%S:%q}][%-l][%t] %m%n
```
......
......