Tango Logging Service in Java

Hello Team,

I am exploring the usage of Tango Logging Service with Java device servers.

In section 6.1.7.2 of Tango manual(9.1) it is mentioned that certain commands of DServer class like AddLoggingTarget, RemoveLoggingTarget, GetLoggingTarget, GetLoggingLevel, SetLoggingLevel, StopLogging, StartLogging are valid only for C++ device server only. This commands allows to configure logging service dynamically.

How can this functionality be extended for Java device servers?

Kind regards,
Jyotin

“We are what we repeatedly do. Excellence, then, is not an act, but a habit” - Aristotle
Hi,

All commands like AddLoggingTarget, RemoveLoggingTarget, GetLoggingTarget, GetLoggingLevel, SetLoggingLevel, StopLogging, StartLogging are already available on the Java API.

Best Regards,

Gwenaëlle.
Dear Tango Experts,

Wish you all and your family a memorable new year.

I've been playing with the Tango Logging Service (mostly for Java Device Server). My objective is to understand the working of the dynamic configuration of logging level and logging target (for Java Device Servers).

I've created a Tango Class LogTester which implements a command, named LogInfo, to log information on invocation. The information is log at each possible log level in the LogInfo command as shown below


@Command(name="LogInfo", inTypeDesc="", outTypeDesc="")
public void LogInfo() throws DevFailed {
        xlogger.entry();
	/*—– PROTECTED REGION ID(LogTester.logInfo) ENABLED START —–*/
		
	//	Put command code here
	logger.error("Error level log");
	xlogger.error("Xlogger error level log");

	logger.warn("Warn Level Log");
	xlogger.warn("Xlogger warn level log");

	logger.info("Info level log");
	xlogger.info("Xlogger info level log");

	logger.debug("Debug Level Log");
	xlogger.debug("Xlogger debug level log");

	logger.trace("Trace Level Log");
	xlogger.trace("Xlogger trace level log");

	/*—– PROTECTED REGION END —–*/	//	LogTester.logInfo
	xlogger.exit();
}

I've created a Tango Device Server which exports one device (instance) of the LogTester Class. When I start the Tango Device Server, Current logging level property is set to ERROR and there is Current logging target is empty. I've attached a snapshot (Snapshot 1) of it.

Then I opened the admin device and add a file (file::C:\LogFolder\testLog.txt) as a logging target. As a result, Current logging level property is automatically set to DEBUG and Current logging target becomes "file::C:\LogFolder\testLog.txt". I've attached the snapshot (Snapshot 2) for it as well.

Then I execute the LogInfo command. Even though the current logging level is DEBUG, only ERROR level logs are written to the file. In fact even if I change the logging level to INFO, only ERROR level logs are written to the file.

Can someone please verify my findings. I'm using JTango-9.0.3.jar. I've attached the code for LogTester Class.

Also what is the difference between Xlogger and Logger ?

Regards,
Vatsal Trivedi

Dear Tango Experts,

I think I now understand the mistake which I made. As I was not using configuration file for logback, logging service was getting configured on the basis of the logback.xml file present in the Tango Jar. logback.xml file present in the Tango Jar sets "ERROR" log level for root logger and logger named "org.tango". All the descendant loggers of "org.tango" are assigned the "ERROR" log-level as they are not explicitly assigned any log-level.

Logger and XLogger created in the LogTester class are also a descendants of "org.tango" and hence they are also assigned "ERROR" log level at the startup. So all log statements of level less than "ERROR" are disabled.

"SetLoggingLevel" command available in the admin device changes the logging level of the Device and File appenders attached to the Device. Device and File appenders additionally filters the generated logs on the basis of their own log-level.

The reason why, I got only "ERROR" level logs is because the logger is configured at the "ERROR" log level. I misunderstood that "SetLoggingLevel" changes the logging level of the logger.

The only way to change the logging level of the logger at runtime is to instruct logback to scan for changes in its configuration file and to automatically re-configure itself.

Requesting Tango Experts to verify my understanding.

Regards,
Vatsal Trivedi
Hello,
I have a question on the methods "AddLoggingTarget" and "SetLoggingLevel" available in the framework. From what I understood, it seems that you can add as many target you want but when you set the logging level you set it for all of them. Is that correct?
All I wanted to do is having two logviewer referring to the same device in the same domain with two different level (like INFO and DEBUG).

Thanks,
Matteo Di Carlo.

Hi Matteo,

Your understanding is correct. The Tango framework does not allow controlling Log Level at target level, i.e. "SetLoggingLevel" command will set the logging level for all the log targets.

Below is the note from Section 6.3.2 (Page 117) of the Tango Control System Manual 9.1:

The logging level can’t be controlled at target level. The device’s targets shared the same device logging level.

If my memory serves me right, in the SKA LMC Harmonization meeting at Edinburgh in one of the slides or document it was specified that different logging levels for appenders (log targets) can be selected by enabling the APPENDERS_HAVE_LEVEL_THRESHOLD flag when building the Tango Control source code. Although I've never tested it.

Regards,
Vatsal Trivedi
Hi Vatsal,
I know it is possible in C++ and I was thinking it was a bug in the java library. Unfortunately, the documentation clarifies that it is not.

Thanks.

Matteo.
 
Register or login to create to post a reply.