Logging attributes settings through XML

8 posts / 0 new
Last post
Offline
Last seen: 2 years 8 months ago
Joined: 06/30/2021
Posts: 7
Logging attributes settings through XML

Hello all!

First time posting, tried to search for answer but couldn't find anything, sorry if this is a duplicate.

I have tried the following setps mentioned in https://community.rti.com/kb/enabling-logging-xml-qos-file to set the logging for the publisher but this is unclear how to read the log file in c++ and set the attributes.

Could you please so kind to share some example program to understand better on, how to read the xml file and how to set the log attributes? 

The binary execution

./HelloWorldExample

Error:

2021-06-30 22:49:40.537 [XMLPARSER Error] Not expected tag: 'qos_library' -> Function parseXML
Cannot open XML file
Publisher found
2021-06-30 22:49:40.537 [XMLPARSER Error] Error parsing 'log.xml' -> Function loadXMLFile

AttachmentSize
File log.xml1.1 KB
Keywords:
Howard's picture
Offline
Last seen: 1 day 6 hours ago
Joined: 11/29/2012
Posts: 565

The XML file that you attached worked for me.  LoggerOutput2.txt was created.

Are you sure your application is loading the log.xml file and not some other?

Also, I note that you have 2 profiles in the XML that have been set as   is_default_participant_factory_profile ="true".

That's not a great idea as it's ambiguous as to which one you want to be used as the default participant factory profile.  I suggest removing one.

Offline
Last seen: 2 years 8 months ago
Joined: 06/30/2021
Posts: 7

Hello Howard,
Thanks a lot for your response. Is it possible to get the code snippet, which you have used for testing it?

I have tried but facing the error like "2021-06-30 22:49:40.537 [XMLPARSER Error] Not expected tag: 'qos_library' -> Function parseXML", DId I missed some installation ? and possible to get your code part ?

Howard's picture
Offline
Last seen: 1 day 6 hours ago
Joined: 11/29/2012
Posts: 565

Uh, there is no code to get.  I just ran it with a HelloWorld.  Any helloworld should be able to run with this.

Are you sure that it's loading the file you're expecting it to load?  How are you specifying "log.xml" as an XML file to load?

Also, there should be error messages that direct you to the line number in the XML file where the problem is found.  Does the line number correspond to the one in "log.xml"?

Offline
Last seen: 2 years 8 months ago
Joined: 06/30/2021
Posts: 7

Hi,
I have used the below snipped of the code and not sure this is the correct API to use it and could not find the info which API shall be used.

if(XMLP_ret::XML_OK == xmlparser::XMLProfileManager::loadXMLFile("log.xml"))
{
std::cout <<"logging done"<<std::endl;
}else{
std::cout << "Cannot open XML file "<< std::endl;
}
 
This is loading the correct xml files because the error reported from this xml file
 

ugeshmunirajulu@ubuntu20:~/DDS/DDS_Git/DDS_HandsOn/HelloWorldExample/build$ ./HelloWorldExample
2021-06-30 22:49:40.537 [XMLPARSER Error] Not expected tag: 'qos_library' -> Function parseXML
Cannot open XML file
Publisher found
2021-06-30 22:49:40.537 [XMLPARSER Error] Error parsing 'log.xml' -> Function loadXMLFile

Please kindly check the highlighted lines

 

Howard's picture
Offline
Last seen: 1 day 6 hours ago
Joined: 11/29/2012
Posts: 565
Offline
Last seen: 2 years 8 months ago
Joined: 06/30/2021
Posts: 7

Hi Howard,
sorry again, I could not able to get the info from the link,are you refering the below ?

DDSDomainParticipantFactory *factory =
	DDSDomainParticipantFactory::get_instance();
DDS_DomainParticipantFactoryQos factoryQos;

DDS_ReturnCode_t retcode = factory->get_qos(factoryQos);
if (retcode != DDS_RETCODE_OK) {
	// error
}
const char *url_profiles[2] = { 
	"file://usr/local/default_dds.xml", 
	"file://usr/local/alternative_default_dds.xml" };
factoryQos.profile.url_profile.from_array(url_profiles, 2);

factoryQos.profile.ignore_resource_profile = DDS_BOOLEAN_TRUE;
factory->set_qos(factoryQos);
Howard's picture
Offline
Last seen: 1 day 6 hours ago
Joined: 11/29/2012
Posts: 565

So, if you want to directly configure your app to load specific files in code, then sure, what you have is fine, except that you need to use "file:///usr/ ...", 3 slashes.

But as discussed on the page that I sent you:

https://community.rti.com/static/documentation/connext-dds/6.1.0/doc/manuals/connext_dds_professional/users_manual/index.htm#users_manual/How_to_Load_XML_Specified_QoS_Settings.htm#xmlconfiguration_1275484337_316960%3FTocPath%3DPart%25203%253A%2520Advanced%2520Concepts%7C19.%2520Configuring%2520QoS%2520with%2520XML%7C19.5%2520How%2520to%2520Load%2520XML-Specified%2520QoS%2520Settings%7C_____0

Connext DDS will automatically load files as well use files specified in an environment variable:

Listed in load order:

    • $NDDSHOME/resource/xml/NDDS_QOS_PROFILES.xml
      This file is loaded automatically if it exists (not the default) and ignore_resource_profile in the 9.4.2 PROFILE QosPolicy (DDS Extension) is FALSE (the default). NDDS_QOS_PROFILES.xml does not exist by default. However, NDDS_QOS_PROFILES.example.xml is shipped with the host bundle of the product; you can copy it to NDDS_QOS_PROFILES.xml and modify it for your own use. The file contains the default QoS values that will be used for all entity kinds. (First to be loaded)
    • XML files in NDDS_QOS_PROFILES
      One or more XML files separated by semicolons referenced by the environment variable NDDS_QOS_PROFILES are loaded automatically if they exist and ignore_environment_profile in 9.4.2 PROFILE QosPolicy (DDS Extension) is FALSE (the default).

Semicolons indicate to Connext DDS to load multiple files or strings all at once. For example:

On Linux and macOS systems, with bash:

export NDDS_QOS_PROFILES='file:///usr/local/default_dds_1.xml; file:///usr/local/default_dds_2.xml'

From a Windows command prompt:

set NDDS_QOS_PROFILES=file://D:/Data/ConnextDDSExample/default_dds_1.xml; file://D:/Data/ConnextDDSExample/default_dds_2.xml

Note: The url_profile and string_profile fields are useful for adding profiles programmatically, when you do not want to use an environment variable.