Update logging articles for log hierarchy in CII 5 (ECII-1011) authored by Marcus Schilling's avatar Marcus Schilling
...@@ -820,98 +820,34 @@ The MAL seems to misbehave. How can I get more log messages from the MAL used in ...@@ -820,98 +820,34 @@ The MAL seems to misbehave. How can I get more log messages from the MAL used in
**Solution A** **Solution A**
**Java** MAL is compatible with CII Logging, meaning if you run an application that uses CII Logging, you can configure MAL's logging as part of your application's log config. To learn how to do that, continue at KB article [Adjust CII Log Levels](https://gitlab.eso.org/ecos/eltsw-docs/-/wikis/KnowledgeBase/CII#adjust-cii-log-levels-log).
From MAL 1.1.0, edit the MAL log4j config xml and specify the MAL log levels: **Solution B**
```plaintext MAL itself does not use CII Logging (CiiLogManager etc.). If you have no application that pulls CII Logging in, you have to configure MAL's logging from scratch, by providing a configuration file and passing that to the MAL instance.
<Logger name="elt.mal" level="TRACE" />
```
**Cpp** **Cpp**
Example for **Zpb.** For other middlewares, see below
1. Put a log-config file into your file system: 1. Put a log-config file into your file system:
```plaintext ```plaintext
log4cplus.rootLogger=TRACE, stdout # Console: Date Level Logger: Message
log4cplus.rootLogger=INFO, stdout
log4cplus.logger.malDds=TRACE, MyFileAppender
log4cplus.logger.malDdsBasePubSub=TRACE, MyFileAppender
log4cplus.logger.malDdsPublisher=TRACE, MyFileAppender
log4cplus.logger.malDdsInstancePublisher=TRACE, MyFileAppender
log4cplus.logger.malDdsSubscriptionManager=TRACE, MyFileAppender
log4cplus.logger.malDdsSubscriptionReaderListener=TRACE, MyFileAppender
log4cplus.logger.malDdsSubscriber=TRACE, MyFileAppender
log4cplus.logger.malDdsMrvSubscriber=TRACE, MyFileAppender
log4cplus.logger.malDdsRequesterImpl=TRACE, MyFileAppender
log4cplus.additivity.malDds=True
log4cplus.additivity.malDdsBasePubSub=True
log4cplus.additivity.malDdsPublisher=True
log4cplus.additivity.malDdsInstancePublisher=True
log4cplus.additivity.malDdsSubscriptionManager=True
log4cplus.additivity.malDdsSubscriptionReaderListener=True
log4cplus.additivity.malDdsSubscriber=True
log4cplus.additivity.malDdsMrvSubscriber=True
log4cplus.additivity.malDdsRequesterImpl=True
log4cplus.logger.malZpb=TRACE, MyFileAppender
log4cplus.logger.malZpbBasePubSub=TRACE, MyFileAppender
log4cplus.logger.malZpbPublisher=TRACE, MyFileAppender
log4cplus.logger.malZpbInstancePublisher=TRACE, MyFileAppender
log4cplus.logger.malZpbSubscriber=TRACE, MyFileAppender
log4cplus.logger.malZpbMrvSubscriber=TRACE, MyFileAppender
log4cplus.logger.malZpbServer=TRACE, MyFileAppender
log4cplus.logger.malZpbClientAsyncImpl=TRACE, MyFileAppender
log4cplus.additivity.malZpb=True
log4cplus.additivity.malZpbBasePubSub=True
log4cplus.additivity.malZpbPublisher=True
log4cplus.additivity.malZpbInstancePublisher=True
log4cplus.additivity.malZpbSubscriber=True
log4cplus.additivity.malZpbMrvSubscriber=True
log4cplus.additivity.malZpbServer=True
log4cplus.additivity.malZpbClientAsyncImpl=True
log4cplus.logger.malOpcua=TRACE, MyFileAppender
log4cplus.logger.malOpcuaBasePubSub=TRACE, MyFileAppender
log4cplus.logger.malOpcuaPublisher=TRACE, MyFileAppender
log4cplus.logger.malOpcuaInstancePublisher=TRACE, MyFileAppender
log4cplus.logger.malOpcuaSubscriber=TRACE, MyFileAppender
log4cplus.logger.malOpcuaMrvSubscriber=TRACE, MyFileAppender
log4cplus.logger.malOpcuaMrvDataMonitor=TRACE, MyFileAppender
log4cplus.logger.malOpcuaDataPoller=TRACE, MyFileAppender
log4cplus.logger.malOpcuaDataMonitor=TRACE, MyFileAppender
log4cplus.logger.malOpcuaClient=TRACE, MyFileAppender
log4cplus.logger.malOpcuaClientEventLoop=TRACE, MyFileAppender
log4cplus.additivity.malOpcua=True
log4cplus.additivity.malOpcuaBasePubSub=True
log4cplus.additivity.malOpcuaPublisher=True
log4cplus.additivity.malOpcuaInstancePublisher=True
log4cplus.additivity.malOpcuaSubscriber=True
log4cplus.additivity.malOpcuaMrvSubscriber=True
log4cplus.additivity.malOpcuaMrvDataMonitor=True
log4cplus.additivity.malOpcuaDataPoller=True
log4cplus.additivity.malOpcuaDataMonitor=True
log4cplus.additivity.malOpcuaClient=True
log4cplus.additivity.malOpcuaClientEventLoop=True
log4cplus.appender.stdout=log4cplus::ConsoleAppender log4cplus.appender.stdout=log4cplus::ConsoleAppender
log4cplus.appender.stdout.layout=log4cplus::PatternLayout log4cplus.appender.stdout.layout=log4cplus::PatternLayout
log4cplus.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n log4cplus.appender.stdout.layout.ConversionPattern=%D %5p %c: %m%n
# Logfile: Date Level Logger [Thread Code]: Message
log4cplus.logger.cii.mal=TRACE, MyFileAppender
log4cplus.appender.MyFileAppender=log4cplus::RollingFileAppender log4cplus.appender.MyFileAppender=log4cplus::RollingFileAppender
log4cplus.appender.MyFileAppender.File=/tmp/elt-mal-cpp-trace.log log4cplus.appender.MyFileAppender.File=/tmp/elt-mal-cpp-trace.log
log4cplus.appender.MyFileAppender.layout=log4cplus::PatternLayout log4cplus.appender.MyFileAppender.layout=log4cplus::PatternLayout
log4cplus.appender.MyFileAppender.layout.ConversionPattern=[%-5p][%D{%Y/%m/%d %H:%M:%S:%q}][%-l][%t] %m%n log4cplus.appender.MyFileAppender.layout.ConversionPattern=%D{%Y/%m/%d %H:%M:%S:%q} %-5p %c [%t %-l]: %m%n
``` ```
If you desire more fine-grained control, see the list of MAL logger names at KB article [Adjust CII Log Levels](https://gitlab.eso.org/ecos/eltsw-docs/-/wikis/KnowledgeBase/CII#adjust-cii-log-levels-log)
2. Configure log4cplus prior to using CII MAL: 2. Configure log4cplus prior to using CII MAL:
```plaintext ```plaintext
...@@ -935,31 +871,32 @@ auto zpbMal = mal::loadMal("zpb", ...@@ -935,31 +871,32 @@ auto zpbMal = mal::loadMal("zpb",
); );
``` ```
or in **python:** **Python**
Since MAL is implemented in C++, also the log config used for Python MAL is targeted at log4cplus.
```plaintext ```plaintext
import elt.pymal as mal import elt.pymal as mal
zpbMal = mal.loadMal ("zpb", {"zpb.log4cplus.filename":"/path/to/mal-log4cplus.conf"}) zpbMal = mal.loadMal ("zpb", {"zpb.log4cplus.filename":"/path/to/mal-log4cplus.conf"})
``` ```
python example with inline config Python example with inline config
```plaintext ```plaintext
import elt.pymal import elt.pymal
with open ("/tmp/mal.log.conf", 'w') as f: with open ("/tmp/mal.log.conf", 'w') as f:
f.write(''' f.write('''
log4cplus.appender.stdout=log4cplus::ConsoleAppender log4cplus.appender.stdout=log4cplus::ConsoleAppender
log4cplus.logger.malDds=TRACE, stdout log4cplus.logger.cii.mal=TRACE, stdout
log4cplus.logger.malDdsBasePubSub=TRACE, stdout
log4cplus.logger.malDdsSubscriber=TRACE, stdout
''') ''')
ddsMalProps = {"dds.log4cplus.filename" : "/tmp/mal.log.conf"} ddsMalProps = {"dds.log4cplus.filename" : "/tmp/mal.log.conf"}
ddsMal = elt.pymal.loadMalForUri("dds.ps://", ddsMalProps) ddsMal = elt.pymal.loadMalForUri("dds.ps://", ddsMalProps)
``` ```
**Solution B** **Solution C**
If your problem is that you want to reconfigure MAL logging while the application is already running:
With [ECII-246](https://jira.eso.org/browse/ECII-246), it is possible to change the log levels of the MAL loggers at run-time via a method call: With [ECII-246](https://jira.eso.org/browse/ECII-246), it is possible to change the log levels of the MAL loggers at run-time via a method call:
```plaintext ```plaintext
...@@ -983,50 +920,6 @@ With [ECII-246](https://jira.eso.org/browse/ECII-246), it is possible to change ...@@ -983,50 +920,6 @@ With [ECII-246](https://jira.eso.org/browse/ECII-246), it is possible to change
``` ```
The allowed logger names are listed below.
**Background**
MAL does not use the Cii Logging System (CiiLogManager etc.) directly. Instead, MAL expects logging to be initialized from a configuration file. Note that the format of the log-config differs per programming language.
List of logger names available in the **Cpp MAL / Python MAL:**
Loggers for **mal-zpb**
- malZpbInstancePublisher
- malZpbPublisher
- malZpbClientAsyncImpl
- malZpbServer
- malZpb
- malZpbSubscriber
- malZpbMrvSubscriber
- malZpbBasePubSub
Loggers for **mal-dds**
- malDds
- malDdsSubscriptionManager
- malDdsSubscriptionReaderListener
- malDdsSubscriber
- malDdsPublisher
- malDdsBasePubSub
- malDdsMrvSubscriber
- malDdsRequesterImpl
- malDdsInstancePublisher
Loggers for **mal-opcua**
- malOpcua
- malOpcuaBasePubSub
- malOpcuaMrvSubscriber
- malOpcuaMrvDataMonitor
- malOpcuaInstancePublisher
- malOpcuaPublisher
- malOpcuaSubscriber
- malOpcuaDataPoller
- malOpcuaDataMonitor
- malOpcuaClient
- malOpcuaClientEventLoop
--- ---
...@@ -1652,26 +1545,7 @@ or, the OLDB API seems to be misbehaving, and you want more logs. ...@@ -1652,26 +1545,7 @@ or, the OLDB API seems to be misbehaving, and you want more logs.
**Solution** **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: Please continue with the article "[Adjust CII Log Levels \[Log\]](#user-content-adjust-cii-log-levels-log)" in the Log section of this Knowledge Base.
```plaintext
CiiOldb
CiiOldbDataPoint
CiiOldbDirectoryTreeProvider
CiiOldbFactory
CiiOldbRedisDataPointProvider
CiiOldbRemoteDataPointProvider
CiiOldbRemoteFileProvider
CiiRedisClient
ThreadSubscriberConsumer
config.CiiConfigClient
```
Example: to turn off ERROR logs for testing the existence of non-existing datapoints, use:
```plaintext
log4cplus.logger.CiiOldbRemoteDataPointProvider=FATAL
```
--- ---
...@@ -2158,7 +2032,8 @@ log4cplus.appender.STDOUT=log4cplus::ConsoleAppender ...@@ -2158,7 +2032,8 @@ log4cplus.appender.STDOUT=log4cplus::ConsoleAppender
log4cplus.appender.STDOUT.layout=elt::log::layout::CiiSimpleLayout log4cplus.appender.STDOUT.layout=elt::log::layout::CiiSimpleLayout
# other loggers, e.g. OLDB or MAL # other loggers, e.g. OLDB or MAL
log4cplus.logger.CiiOldb=FATAL log4cplus.logger.cii.oldb=FATAL
log4cplus.logger.cii.mal=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: The name of the log config is your choice, but to comply with the rules of "waf install", best use such a project structure:
...@@ -2201,21 +2076,120 @@ from elt.log import CiiLogManager ...@@ -2201,21 +2076,120 @@ from elt.log import CiiLogManager
logconf={ logconf={
'log4cplus.appender.STDOUT': 'log4cplus::ConsoleAppender', 'log4cplus.appender.STDOUT': 'log4cplus::ConsoleAppender',
'log4cplus.appender.STDOUT.layout': 'elt::log::layout::CiiSimpleLayout', 'log4cplus.appender.STDOUT.layout': 'elt::log::layout::CiiSimpleLayout',
'log4cplus.logger.CiiOldb': 'DEBUG, STDOUT', 'log4cplus.logger.cii.oldb': 'DEBUG, STDOUT',
'log4cplus.logger.CiiOldbDataPoint': 'DEBUG, STDOUT',
'log4cplus.logger.CiiOldbDirectoryTreeProvider': 'DEBUG, STDOUT',
'log4cplus.logger.CiiOldbFactory': 'TRACE, STDOUT',
'log4cplus.logger.CiiOldbRedisDataPointProvider': 'DEBUG, STDOUT',
'log4cplus.logger.CiiOldbRemoteDataPointProvider': 'DEBUG, STDOUT',
'log4cplus.logger.CiiOldbRemoteFileProvider': 'DEBUG, STDOUT',
'log4cplus.logger.CiiRedisClient': 'DEBUG, STDOUT',
'log4cplus.logger.ThreadSubscriberConsumer': 'DEBUG, STDOUT',
'log4cplus.logger.config.CiiConfigClient': 'TRACE, STDOUT',
} }
CiiLogManager.configure(logconf, cpp_logging=True) CiiLogManager.configure(logconf, cpp_logging=True)
``` ```
**List of Loggers** Generally, to learn about all loggers that are active in your application, add this (temporarily) to your application: **List of CII Loggers**
CII Logger Names as of CII 5
```plaintext
mal
cii.mal
cii.mal.internal
mal-zpb
cii.mal.zpb.api
cii.mal.zpb.internal
cii.mal.zpb.publisher
cii.mal.zpb.subscriber
cii.mal.zpb.client
cii.mal.zpb.server
mal-dds
cii.mal.dds.api
cii.mal.dds.internal
cii.mal.dds.publisher
cii.mal.dds.subscriber
mal-opcua
cii.mal.opcua.api
cii.mal.opcua.internal
cii.mal.opcua.publisher
cii.mal.opcua.subscriber
cii.mal.opcua.client
mal-mudpi
cii.mal.mudpi.api
cii.mal.mudpi.internal
cii.mal.mudpi.publisher
cii.mal.mudpi.subscriber
cii.mal.mudpi.client
cii.mal.mudpi.server
config(-ng)
cii.config.api
oldb
cii.internal.config.api
cii.internal.redis
cii.oldb.api
cii.oldb.dp
cii.oldb.dp.subscriber
cii.oldb.dp.provider
cii.oldb.dp.provider.redis
cii.oldb.dp.provider.memory
cii.oldb.dp.provider.directory
cii.oldb.gui
cii.oldb.admin.tool
calculation engine
cii.oldb.ce.node.main
cii.oldb.ce.node.dp
cii.oldb.ce.node.engine
cii.oldb.ce.sched.main
cii.oldb.ce.sched.handler
alarm system
cii.alarm.mon
cii-services
cii.mgmt.srv.tool
cii.mgmt.srv.functest
cii benchmarks
cii.oldb.benchmark
```
CII Logger Names up to CII 4
```plaintext
mal-zpb
- malZpbInstancePublisher
- malZpbPublisher
- malZpbClientAsyncImpl
- malZpbServer
- malZpb
- malZpbSubscriber
- malZpbMrvSubscriber
- malZpbBasePubSub
mal-dds
- malDds
- malDdsSubscriptionManager
- malDdsSubscriptionReaderListener
- malDdsSubscriber
- malDdsPublisher
- malDdsBasePubSub
- malDdsMrvSubscriber
- malDdsRequesterImpl
- malDdsInstancePublisher
mal-opcua
- malOpcua
- malOpcuaBasePubSub
- malOpcuaMrvSubscriber
- malOpcuaMrvDataMonitor
- malOpcuaInstancePublisher
- malOpcuaPublisher
- malOpcuaSubscriber
- malOpcuaDataPoller
- malOpcuaDataMonitor
- malOpcuaClient
- malOpcuaClientEventLoop
oldb/config
- CiiOldb
- CiiOldbDataPoint
- CiiOldbDirectoryTreeProvider
- CiiOldbFactory
- CiiOldbRedisDataPointProvider
- CiiOldbRemoteDataPointProvider
- CiiOldbRemoteFileProvider
- CiiRedisClient
- ThreadSubscriberConsumer
- config.CiiConfigClient
```
**Tip: Detect Loggers** Generally, to learn about all loggers that are active in your application, add this (temporarily) to your application:
```plaintext ```plaintext
#include <ciiLogManager.hpp> #include <ciiLogManager.hpp>
...@@ -2232,13 +2206,13 @@ for (int i=0,n=list.size(); i<n; i++) { ...@@ -2232,13 +2206,13 @@ for (int i=0,n=list.size(); i<n; i++) {
} }
``` ```
**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: **Tip: Log Format** To use a different log format, you can modify the above config using log4cplus features directly. Be aware that using a custom format will mean various tools of the CII Logging System (Log Viewer, Log Transport) will no longer know how to interpret your logs, i.e. won't be able to process them. Therefore custom formats are mostly only useful for your console output.
```plaintext ```plaintext
#log4cplus.appender.STDOUT.layout=elt::log::layout::CiiSimpleLayout
log4cplus.appender.STDOUT.layout=log4cplus::PatternLayout log4cplus.appender.STDOUT.layout=log4cplus::PatternLayout
log4cplus.appender.STDOUT.layout.ConversionPattern=[%-5p][%D{%Y/%m/%d %H:%M:%S:%q}][%-l][%t] %m%n log4cplus.appender.STDOUT.layout.ConversionPattern=[%-5p][%D{%Y/%m/%d %H:%M:%S:%q}][%-l][%t] %m%n
``` ```
--- ---
--- ---
... ...
......