Best practises for error reporting when running in batch mode

I want to create a pipeline that runs without the graphical user interface. I already know how to do this (KNIME batch mode). But this pipeline will be invoked from a web frontend by website visitors who are not familiar with the technical details.

I noticed that when running KNIME from the command line, there are messages of the form <message-type><tab><node-type><tab><message>. Is this a general thing? Would it make sense to filter the output so that I keep all lines that start with message-type=ERROR, message-type=WARN or message-type=INFO and then I present them to the user?

What is the idiomatic way to generate these messages from a Java snippet node? Is there a specific class or method I can call?

Or are there other best practises that I could use to report that something has gone wrong during the execution of a batch job?

Logging: I think KNIME uses log4j, there are in-memory/console and DB appenders too.

Logging within Java Snippets: logDebug, logInfo, logWarning, logError are probably what you are looking for.

1 Like

NodeLogger class (which is based on log4j) has getLogger() methods which accept Class or String arguments.  In a snippet you can access via NodeLogger.getLogger("A useful description").  for any given Class or String argument, youwill always return the same Logger Instance, so you can use something like:

NodeLogger logger=NodeLogger.getLogger("My Logger");

//Do stuff..

logger.WARN("Something quite bad");
logger.ERROR("Something really bad");
logger.INFO("Something vaguely informative");

or for a one-off just

NodeLogger.getLogger("My Logger").ERROR("Oops!);

The format is the name of the logger<tab>level<tab>message

Steve