Logging in Bonita components
Learn how to view and configure logging of Bonita components.
How components produce log messages
Bonita components have their own ways to produce logs, as described below.
Bonita Runtime
The Bonita Runtime has two components :
-
Bonita Engine, which uses SLF4J in order to write log messages.
-
Bonita Rest APIs, which use Java Url Logging (JUL)
Bonita Studio
The Studio uses a logging service provided by the Eclipse platform. Modification of the Studio logging configuration is not very common except for debugging the Studio itself.
The Bonita Studio provides direct access to the log written by the embedded Runtime. You can access this log from the Bonita Studio Help menu Show Engine log option (Engine log also contains UI designer logs).
Logging configuration
Bonita Runtime
Bonita Engine uses SLF4J to create the logs as well as some Bonita dependencies such as Quartz and Ehcache.
SLF4J is a facade for various logging frameworks, and a logging framework must be available as the back-end. By default, Bonita uses JUL (Java Util Logging) as a the back-end to SLF4J.
By default in the Bonita Runtime, all logs are sent to the JUL framework. To configure what is logged and where it is stored, edit the logging.properties file located in conf
folder (see the Apache Tomcat logging documentation) of the Bonita Bundle.
For the Bonita Runtime embedded in the Bonita Studio, the JUL configuration file is located in the Studio installation folder under
workspace/tomcat/conf
. After editing this file, restart Bonita by going to the Server menu and selecting the Restart web server option.
Here is an example of the JUL configuration for the logger used in the example below:
# Set log level to "finest" for newly created connector
org.mycompany.connector.level = FINEST
# Set log level to "finest" for Groovy script
org.bonitasoft.groovy.script.level = FINEST
How to use a Logger in your development on Bonita
When you write Groovy scripts or Java code to be included in a process (for example, to create a new connector implementation), logging is usually required. The recommended option is to use SLF4J in order to log messages. SLF4J API is included in the Bonita dependencies so you can use it without adding extra dependencies.
This is an example of how to log debug information in a Groovy script. Note that we recommend that you use a logger name that starts with "org.bonitasoft", so that the default Bonita logging configuration is applied to your logger. Also, ending your logger name with a name similar to the Groovy script will be helpful to identify source of the message.
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Logger logger = LoggerFactory.getLogger("org.bonitasoft.groovy.script.my_int_init_script");
logger.debug("Set initial value of process variable using Groovy script");
return Integer.valueOf(3 + 5);
This is an example of how to use logging in a connector:
private static final Logger LOGGER = LoggerFactory.getLogger(SumImpl.class);
@Override
protected void executeBusinessLogic() throws ConnectorException {
LOGGER.debug("Trying to sum {} and {}.", getIntegerA(), getIntegerB());
int sum = getIntegerA() + getIntegerB();
LOGGER.debug("The sum is: {}", sum);
setSum(sum);
}
View log content
Bonita Studio
In Bonita Studio you have access to the following log files :
-
The Studio log file includes information about Studio execution. Look at this file if you see incorrect behavior of the Studio. To view the file, go to the Help menu and choose Show Studio log. The file is located in the
workspace/.metadata
folder and is named.log
. -
The Runtime log file receives all log messages produced by the Bonita Platform embedded in the Studio. When you test your processes by running them from the Studio you will find valuable debugging information in this file. To view the file, go to the Help menu and choose Show Engine log. The file is located in
workspace/tomcat/log
and is namedbonita-yyyy-mm-dd.log
.