Usage of logging

Hello tangoers,
reading the tango doc on Logging, I made a few tests and have a few questions:

  1. Logging properties for Starter should be set in jive in Device tab, and then in dserver/Starter/COMPUTERNAME and not in Starter/COMPUTERNAME/Starter then tango/admin/COMPUTERNAME

Am I right ?
If not, when should we add Logging properties into dserver or Starter (and more generally, into DeviceServerName) ?
If yes, this could be confusing, but I did not find anything on it into the doc

  1. I did not really find anything on Current logging level and Current logging target properties.

Did I miss something into the doc?
Regards

[quote=“philippeg”]Hello tangoers,
reading the tango doc on Logging, I made a few tests and have a few questions:

  1. Logging properties for Starter should be set in jive in Device tab, and then in dserver/Starter/COMPUTERNAME and not in Starter/COMPUTERNAME/Starter then tango/admin/COMPUTERNAME

Am I right ?
[/quote]

That does not sound right to me. How did you come to this conclusion from your tests?
If you want to get some logging about what’s going on in the cppTango library, you indeed need to enable the logs in DEBUG level on the admin device, this is where you’ll get the logs coming from the cpptango library. The logs specific to the device of the Starter class (logs from the Starter class code) should be in the logs configured for tango/admin/COMPUTERNAME device.

[quote=“philippeg”]
If not, when should we add Logging properties into dserver or Starter (and more generally, into DeviceServerName) ?[/quote]

You add logging properties for the dserver (admin) device if you want to see what’s going on with the admin device or if you want to see the logs coming from the cppTango library (you have to be in DEBUG mode to see these logs and they will be associated to dserver/Starter/COMPUTERNAME device).

You add logging properties for the Starter device (tango/admin/COMPUTERNAME) if you want to see the logs coming from the Starter class code.

[quote=“philippeg”]
2. I did not really find anything on Current logging level and Current logging target properties.

Did I miss something into the doc?
Regards[/quote]

Maybe it’s not in the doc. The doc can always be improved. Many thanks for all the doc improvements suggestions you made by the way.
The Current logging level corresponds to the current logging level (Surprise! :wink: ). If you change it, it will change the current logging level for the associated device but if the device (or device server) is restarted, the current logging level will be reset to the value in logging level property.
Same principle for the Current logging target, this affects only the current logging target for the current session. If you restart your device or device server, this will be lost and the logging target property will be used to set the logging target during the device server initialization.

So basically, as far as I have understood, the Current logging xxx properties are just temporary properties which will be lost/overwritten at the next restart of the device or device server.
I think they are not even real properties but jive provide this as a way to change the current logging level and current logging target but the Current logging xxx are not saved in the Tango Database.
logging target and logging level properties are the ones used to configure the logging during the device initialization in a persistent way.

Sorry, I probably misunderstood the behaviour while looking at the upcase bug.

[quote=“Reynald”]
So basically, as far as I have understood, the Current logging xxx properties are just temporary properties which will be lost/overwritten at the next restart of the device or device server.
I think they are not even real properties but jive provide this as a way to change the current logging level and current logging target but the Current logging xxx are not saved in the Tango Database.
logging target and logging level properties are the ones used to configure the logging during the device initialization in a persistent way.[/quote]

It’s interesting, thank you for those details.

I understand that “Current logging…” is more a read-only property for information, and that if it is modified while the device is running, it will not modify the way logging will be done for this session.

Am I right?

[quote=“philippeg”]I understand that “Current logging…” is more a read-only property for information, and that if it is modified while the device is running, it will not modify the way logging will be done for this session.

Am I right? [/quote]

No. Sorry. If you modify the current logging … properties in jive, it will modify the logging for the current session but these new logging parameters will be lost if the device server/device is restarted.

[quote=“Reynald”][quote=“philippeg”]I understand that “Current logging…” is more a read-only property for information, and that if it is modified while the device is running, it will not modify the way logging will be done for this session.

Am I right? [/quote]

No. Sorry. If you modify the current logging … properties in jive, it will modify the logging for the current session but these new logging parameters will be lost if the device server/device is restarted.[/quote]
Don’t be sorry, it allows me to better understand.
So it allows to dynamically modify the logging behaviour for current session, even better :sunglasses:

Will try to add some details into the doc on this topic.

Thank you again Reynald!

I noticed another behaviour I do not understand: sys/databaseds/2 is configured with Logging level=ERROR and has been restarted with

/usr/sbin/service tango-db restart

However, Current logging level is set to WARNING.

I set it manually to ERROR but I wonder how to restart this device.

Hi Philippe,

I cannot explain what you’re seeing but I can see the same behaviour with the first tests I’ve done with the DatabaseDS.
This device server is really special so there might be some hard coded values for the logging of this DS?
If you consider this as an issue that you would like to be solved, please create an issue on the TangoDatabase gitlab repository.

Kind regards,
Reynald

Hi Philippe,

I had a deeper look at what you observed.

What you observed is really a specificity of the Tango Database server which is different than the other devices.

What you are seeing is coming from the fact that the Tango Database server is using the Tango C++ library as if there was no Tango Database: See main.cpp · Database-Release-5.16 · tango-controls / TangoDatabase · GitLab

So it is not looking in the Tango Database for the logging configuration of its Tango device.
So if the ‘-v’ option was not used at the command line, DeviceImpl::init_logger returns without having set any logging level (See cppapi/server/devicelog.cpp · 9.4.0 · tango-controls / cppTango · GitLab).
So it’s using the default logging level in this use case, which is set to WARNING (See cppapi/server/devicelog.cpp · 9.4.0 · tango-controls / cppTango · GitLab)

All the other devices (when configured to use the Tango DB) will try to get their logging configuration from the Tango Database and if no logging config is present in the Tango DB and -v option was not use at the command line, the logging level is set to OFF in this use case (See cppapi/server/devicelog.cpp · 9.4.0 · tango-controls / cppTango · GitLab and cppapi/server/devicelog.cpp · 9.4.0 · tango-controls / cppTango · GitLab).

If you consider this Tango Database server specificity is an issue, please create an issue in the TangoDatabase Gitlab repository.

Kind regards,
Reynald

Hi Reynald,
thank you for this detailed answer.
It’s interesting to understand the behaviour and it does not need an issue in my opinion.
I’ll thnik about it if it needs a doc evolve and if I can make a merge request.

Regards.

Hello,
I have another question:

in TdbArchiver (ArchivingRoot device), I defined Logging_target to file::/tmp/tango-tango/tdbarchiver/01/01.log.
However, it writes its login another directory (/var/archivage/tdb/01 defined in dsPath, dbPath and diaryPath).

Is it a normal behaviour?

Regards

Hi Philippe,

logging_target property is a Tango system property. (you see it in jive in your device properties only if Edit menu → Show system property is ticked).
This is a property which can be defined for any Tango device.
When you change the “Logging target” on the “Logging” node of your device in jive, this will write this “logging_target” system property for your device in the Tango Database.
So “logging_target” is a Tango specific system device property, not specific to the TdbArchiver.
dsPath and dbPath are probably some TdbArchiver device properties and are probably specific to the tdbArchiver class.
You should probably refer to tdbArchiver class documentation to get more details about what these properties are doing.

Hoping this helps a bit.
Reynald

Thank you for your fast & detailed answer Reynald, this is always interesting (and happy new year) :slight_smile:

I just ticked Show system property, but after a few tests, I saw the Logging_target property whatever the “Show system property” is ticked or not (however, the device is stopped).

It is not in the ArchivingRoot doc, but I’ll contact development just in case…

[quote=“Reynald”]
Hoping this helps a bit.
Reynald[/quote]
Indeed, I didn’t noticed the “show system property” until now. :slight_smile:
By chance, is it described somewhere in the doc?

A more general question: can “Logging_target” be rewritten by the device? I mean is it possible that whatever is the value of Logging_target, the content of logging file is written somewhere else by the device?

Happy new year Philippe!

I think it is possible.
One can always invoke AddLoggingTarget command on the admin device when it is running to add a file logging target.
It can be done programmatically with the Tango::Logging::add_logging_target() methods as well I think.

https://tango-controls.gitlab.io/cppTango/classTango_1_1Logging.html#a6da309691c22fb4ebe3a82d790b61d05

Hoping this helps.
Reynald