Improved KB on logging levels. authored by Gianluca Chiozzi's avatar Gianluca Chiozzi
......@@ -935,118 +935,54 @@ Probably you have called close() on the CiiConfigClient instance somewhere, mayb
### KB: Getting More Logs \[MAL\]
**Problem**
>
>
> **Problem**
>
>
>
> The MAL seems to misbehave. How can I get more log messages from the MAL used in my application?
>
>
>
>
>
> **Solution A**
>
>
>
>
>
> Java
>
>
>
> From MAL 1.1.0, edit the MAL log4j config xml
>
>
>
> and specify the MAL log levels:
The MAL seems to misbehave. How can I get more log messages from the MAL used in my application?
**Solution A**
Java
From MAL 1.1.0, edit the MAL log4j config xml and specify the MAL log levels:
| \<Logger name="elt.mal" level="TRACE" /> |
|------------------------------------------|
>
>
>
>
> Cpp
>
>
>
> Example for **Zpb.** For other middlewares, see below
>
>
Cpp
1. Put a log-config file into your file system:
Example for **Zpb.** For other middlewares, see below
>
1. Put a log-config file into your file system:
<table><colgroup><col style="width: 78%" /><col style="width: 21%" /></colgroup><thead><tr class="header"><th><p>log4cplus.rootLogger=TRACE, stdout</p><p> </p><p>log4cplus.logger.malDds=TRACE, MyFileAppender</p><p>log4cplus.logger.malDdsBasePubSub=TRACE, MyFileAppender</p><p>log4cplus.logger.malDdsPublisher=TRACE, MyFileAppender</p><p>log4cplus.logger.malDdsInstancePublisher=TRACE, MyFileAppender</p><p>log4cplus.logger.malDdsSubscriptionManager=TRACE, MyFileAppender</p><p>log4cplus.logger.malDdsSubscriptionReaderListener=TRACE, MyFileAppender</p><p>log4cplus.logger.malDdsSubscriber=TRACE, MyFileAppender</p><p>log4cplus.logger.malDdsMrvSubscriber=TRACE, MyFileAppender</p><p>log4cplus.logger.malDdsRequesterImpl=TRACE, MyFileAppender</p><p> </p><p>log4cplus.additivity.malDds=True</p><p>log4cplus.additivity.malDdsBasePubSub=True</p><p>log4cplus.additivity.malDdsPublisher=True</p><p>log4cplus.additivity.malDdsInstancePublisher=True</p><p>log4cplus.additivity.malDdsSubscriptionManager=True</p><p>log4cplus.additivity.malDdsSubscriptionReaderListener=True</p><p>log4cplus.additivity.malDdsSubscriber=True</p><p>log4cplus.additivity.malDdsMrvSubscriber=True</p><p>log4cplus.additivity.malDdsRequesterImpl=True</p><p> </p><p> </p><p>log4cplus.logger.malZpb=TRACE, MyFileAppender</p><p>log4cplus.logger.malZpbBasePubSub=TRACE, MyFileAppender</p><p>log4cplus.logger.malZpbPublisher=TRACE, MyFileAppender</p><p>log4cplus.logger.malZpbInstancePublisher=TRACE, MyFileAppender</p><p>log4cplus.logger.malZpbSubscriber=TRACE, MyFileAppender</p><p>log4cplus.logger.malZpbMrvSubscriber=TRACE, MyFileAppender</p><p>log4cplus.logger.malZpbServer=TRACE, MyFileAppender</p><p>log4cplus.logger.malZpbClientAsyncImpl=TRACE, MyFileAppender</p><p> </p><p>log4cplus.additivity.malZpb=True</p><p>log4cplus.additivity.malZpbBasePubSub=True</p><p>log4cplus.additivity.malZpbPublisher=True</p><p>log4cplus.additivity.malZpbInstancePublisher=True</p><p>log4cplus.additivity.malZpbSubscriber=True</p><p>log4cplus.additivity.malZpbMrvSubscriber=True</p><p>log4cplus.additivity.malZpbServer=True</p><p>log4cplus.additivity.malZpbClientAsyncImpl=True</p><p> </p><p> </p><p>log4cplus.logger.malOpcua=TRACE, MyFileAppender</p><p>log4cplus.logger.malOpcuaBasePubSub=TRACE, MyFileAppender</p><p>log4cplus.logger.malOpcuaPublisher=TRACE, MyFileAppender</p><p>log4cplus.logger.malOpcuaInstancePublisher=TRACE, MyFileAppender</p><p>log4cplus.logger.malOpcuaSubscriber=TRACE, MyFileAppender</p><p>log4cplus.logger.malOpcuaMrvSubscriber=TRACE, MyFileAppender</p><p>log4cplus.logger.malOpcuaMrvDataMonitor=TRACE, MyFileAppender</p><p>log4cplus.logger.malOpcuaDataPoller=TRACE, MyFileAppender</p><p>log4cplus.logger.malOpcuaDataMonitor=TRACE, MyFileAppender</p><p>log4cplus.logger.malOpcuaClient=TRACE, MyFileAppender</p><p>log4cplus.logger.malOpcuaClientEventLoop=TRACE, MyFileAppender</p><p> </p><p>log4cplus.additivity.malOpcua=True</p><p>log4cplus.additivity.malOpcuaBasePubSub=True</p><p>log4cplus.additivity.malOpcuaPublisher=True</p><p>log4cplus.additivity.malOpcuaInstancePublisher=True</p><p>log4cplus.additivity.malOpcuaSubscriber=True</p><p>log4cplus.additivity.malOpcuaMrvSubscriber=True</p><p>log4cplus.additivity.malOpcuaMrvDataMonitor=True</p><p>log4cplus.additivity.malOpcuaDataPoller=True</p><p>log4cplus.additivity.malOpcuaDataMonitor=True</p><p>log4cplus.additivity.malOpcuaClient=True</p><p>log4cplus.additivity.malOpcuaClientEventLoop=True</p><p> </p><p> </p><p>log4cplus.appender.stdout=log4cplus::ConsoleAppender</p><p>log4cplus.appender.stdout.layout=log4cplus::PatternLayout</p><p>log4cplus.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n</p><p> </p><p>log4cplus.appender.MyFileAppender=log4cplus::RollingFileAppender</p><p>log4cplus.appender.MyFileAppender.File=/tmp/elt-mal-cpp-trace.log</p><p>log4cplus.appender.MyFileAppender.layout=log4cplus::PatternLayout</p><p>log4cplus.appender.MyFileAppender.layout.ConversionPattern=[%-5p][%D{%Y/%m/%d %H:%M:%S:%q}][%-l][%t] %m%n</p></th><th><p> </p><p>&lt;&lt;mal-log4cplus.conf&gt;&gt;</p><p> </p></th></tr></thead><tbody></tbody></table>
>
>
>
2. Pass the path to the log-config to MAL:
>
>
> MAL logging is initialized from a configuration file, the path of which is read from mal properties with key mal::PROP_LOG_CONFIG_FILENAME. When loading mal, use set mal::PROP_LOG_CONFIG_FILENAME in mal properties.
>
>
>
> For example:
MAL logging is initialized from a configuration file, the path of which is read from mal properties with key mal::PROP_LOG_CONFIG_FILENAME. When loading mal, use set mal::PROP_LOG_CONFIG_FILENAME in mal properties.
For example:
<table><colgroup><col style="width: 100%" /></colgroup><thead><tr class="header"><th><p>auto zpbMal = mal::loadMal("zpb",</p><p>mal::Mal::Properties{{mal::PROP_LOG_CONFIG_FILENAME,"/path/to/mal-log4cplus.conf"}}</p><p>);</p></th></tr></thead><tbody></tbody></table>
>
>
> or in python:
or in python:
<table><colgroup><col style="width: 100%" /></colgroup><thead><tr class="header"><th><p>import elt.pymal as mal</p><p>zpbMal = mal.loadMal ("zpb",</p><p>{"zpb.log4cplus.filename":"/path/to/mal-log4cplus.conf"})</p></th></tr></thead><tbody></tbody></table>
>
>
>
>
>
>
>
>
> **Solution B**
>
>
>
> 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:
>
> ::elt::mal::util::logging::setLogLevelForLoggers( ... )
>
>
>
> 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
**Solution B**
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:
::elt::mal::util::logging::setLogLevelForLoggers( ... )
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
......@@ -1064,9 +1000,7 @@ Probably you have called close() on the CiiConfigClient instance somewhere, mayb
- malZpbBasePubSub
>
>
> Loggers for mal-dds
Loggers for mal-dds
- malDds
......@@ -1086,9 +1020,7 @@ Probably you have called close() on the CiiConfigClient instance somewhere, mayb
- malDdsInstancePublisher
>
>
> Loggers for mal-opcua
Loggers for mal-opcua
- malOpcua
......@@ -1112,14 +1044,6 @@ Probably you have called close() on the CiiConfigClient instance somewhere, mayb
- malOpcuaClientEventLoop
>
>
>
>
>
### KB: Change Log Levels at Run-time
......
......