Search code examples
logginglog4jroslog4cxx

ROS rosconsole.config logging configuration file in common XML?


Is it possible to also use commonly known XML-format for the ROS logging configuration file?

Such as:

<Configuration>
  <filter  ... />
  <Appenders>
    <appender ... >
      <filter  ... />
    </appender>
    ...
  </Appenders>
  <Loggers>
    <Logger name="name1">
      <filter  ... />
    </Logger>
    ...
    <Root level="level">
      <AppenderRef ref="name"/>
    </Root>
  </Loggers>
</Configuration>

instead of the standard properties-format, which looks like this for instance:

appender.stdout.type = Console
# ... other appender properties
appender.file.type = File
# ... other appender properties
logger.app = INFO, stdout, file
logger.app.name = com.example.app
 
# is equivalent to:
# appender.stdout.type = Console
# appender.stdout.name = stdout
# ...
appender.file.type = File
appender.file.name = file
# ...
logger.app.name = com.example.app
logger.app.level = INFO
logger.app.appenderRef.$1.ref = stdout
logger.app.appenderRef.$2.ref = file

(c.f. link)


Solution

  • You already recognized, that log4cxx is used by ROS under the hood which may also supports the XML-format you've mentioned.

    log4cxx differences between the PropertyConfigurator for the known ROS format and the DOMConfigurator for the XML format mentioned by you.

    Unfortunately, ROS does not forseen a way to use the DOMConfigurator, since a look inside the implementation (log4cxx::PropertyConfigurator::configure(config_file);) shows, that the PropertyConfigurator is used hard coded here.

    This means: Without changing it manually and recompiling ROS, there is no way around the PropertyConfigurator.