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 Log4j2 logger. To configure what is logged and where it is stored, edit the log4j2-loggers.xml
and log4j2-appenders.xml
file located in conf
folder of the Bonita Bundle.
See Log4j website
For the Bonita Runtime embedded in the Bonita Studio, the Log4j2 configuration files are located in the Studio installation folder under
workspace/tomcat/conf
. After editing this file, Log4j2 should automatically reload the configuration without having to restart.
Here is an example of the Log4j2 configuration for the logger used in the example below:
<!-- Set log level to "TRACE" for newly created connector -->
<Logger name="org.mycompany.connector" level="TRACE"/>
<!-- Set log level to "TRACE" for Groovy script -->
<Logger name="org.bonitasoft.groovy.script" level="TRACE"/>
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
.