[Contents] [TitleIndex] [WordIndex

Getting an Xcos useful backtrace

Xcos use the commons-logging API to enable developers getting useful backtrace from users. This page explain how to enable a maximum tracing level for the Xcos components.

From a Scilab script (simplest way)

At the start of Scilab, execute the following script which will create a logging.properties file and set it the default logging configuration file.

// Create a property file containing useful settings
settings = [ 'handlers=java.util.logging.ConsoleHandler java.util.logging.FileHandler';..
             '';..
             '.level=SEVERE';..
             'org.scilab.modules.xcos.level=FINEST';..
             'org.scilab.modules.graph.level=FINEST';..
             '';..
             'java.util.logging.ConsoleHandler.level=FINEST';..
             'java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter';..
             'java.util.logging.FileHandler.level=FINEST';..
             'java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter';..
             'java.util.logging.FileHandler.pattern=%t/xcos.log'];

filename = TMPDIR + '/' + 'logging.properties';
fd = mopen (filename, 'wt');
mputl(settings, fd);
mclose(fd);

// set log system property
system_setproperty('java.util.logging.config.file', filename);

// tell the user the file to post
messagebox(msprintf('<html><body>The log file is : ""%s""', TMPDIR + '/xcos.log'));

// set the console visible
if getos() == 'Windows' then
        consolebox('on');
end

At the end of the execution, start Xcos normally (using xcos() or from the menu shortcut).

Before the launch of Scilab (hard way)

This procedure does exactly the same as the above point. All the operation have to be done manually.

Enable the console (Windows only)

To get a terminal for the process who launched Scilab, use the setconsolebox('on') command.

Setup a logging configuration

First we have to configure the logging framework. We have to select the logged packages/classes and choose a Logger (Console, File, etc...) for these packages. To configure these properties we use a logging.properties file containing the following text.

handlers=java.util.logging.ConsoleHandler java.util.logging.FileHandler

.level=SEVERE
org.scilab.modules.xcos.level=ALL
org.scilab.modules.graph.level=ALL

java.util.logging.ConsoleHandler.level=ALL
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level=ALL
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter

Set the java environment variable

To enable logging on the Java part of Scilab we have to export a specific environment variable called _JAVA_OPTIONS.

On windows, an a command terminal (cmd.exe):

set _JAVA_OPTIONS="-Djava.util.logging.config.file=PATH/logging.properties"

On Linux:

export _JAVA_OPTIONS="-Djava.util.logging.config.file=PATH/logging.properties"

then launch Scilab (bin/scilab on linux and wscilex on windows) on the same terminal.


CategoryXcos


2022-09-08 09:27