Skip to content


Platform 6 logging Consumer receives and filters log4j events.

log4j is the logging framework used by platform6. Other logging frameworks such as jdk, slf4j and commons are also redirected to log4j as are stdout and stderr streams. This means that nearly everything logged or written to an output stream by core p6 code, third-party libraries or Groovy scripts is captured.

For more information about log4j 1.2 see this:

A custom log4j appender called ‘platform6’ is defined in the file:

log4j.appender.platform6 = io.platform6.core.impl.logging.Platform6Appender

This appender will generate events via the p6log component and allows low level filtering by logger Level and Logger Name

Common Usage Scenarios

Email Errors to an Operator

All ERROR level logs are captured, stored and sent as xml to an route endpoint where they are filtered and used to generate an Active Routing Order by the p6route component.

The routing order is typically configured to transform the xml to an html document that is sent as an email body to an operator via the SMTP service

Send log messages to an ELK server

All ERROR and WARN logs are captured in JSON format and posted as strings to the ELASTICSEARCH audit provider

Configuration Attributes

Event Queue

There is an internal queue used to store log events awaiting processing. The size of this queue can be controlled by the following conf attribute:

  • p6.camel.p6log.LogConsumer.QueueSize default: “64”


It is very easy to introduce recursion to your p6log routes especially if the scripts called as a result of an event generate ERRORs! To protect against an out of control recursion a limiter is used.

By default, this ensures no more than one log event can be processed within any five-second period (additional events will be discarded).

The following conf attributes can be modified to change this default behaviour:

  • p6.camel.p6log.LogConsumer.limiter.capacity default:”1”
  • p6.camel.p6log.LogConsumer.limiter.duration default:”5”


For additional safety it is strongly recommended that the camel throttle is also used in your route definitions to ensure you never flood the error notification system:

URI Format



The P6log component supports three options which are described below.

Name Description Default Type
level log4j logger Level >= ERROR string
nameRegex Match required on ‘Logger Name’ string
format Log formatting, either: json, xml or map xml string
persistXml true to store xml in LOG partition false string

Example of an xml formatted log event

This format is historical in design and mirrors the logging events generated by the B2BOX product.

    <time>2018-09-11 17:37:22.950 CEST</time>
    <logger>GROOVYSCRIPT: Simons_MacBook_Pro_local_ScriptModule__GENERATE_ERROR</logger>
    <message>this is an error!</message>


Template: BaseRoute.groovy

${addRoutes} :=

    .description('JSON ERROR Log Listener')
    .to( "p6cmb://scripts?platform6.request.action=execute&id=ErrorLogger" )

Template: BaseRoute.groovy

${addRoutes} :=

    .description('Xml ERROR Log Listener')

.description('Xml ERROR Log Routing Rule')
        .setHeader( 'platform6.request.action').constant('execute')
        .to( 'p6route://scripts')

    .throwException(io.platform6.common.util.P6Exception,'No matching rule found for item!')


Script ErrorLogger:

// Always catch and log errors from error notification scripts 
try {
    def jsonLogError = p6.pipeline.get('body')'myerrorindex', jsonLogError)
} catch(Exception e) {
    // Cannot use log.error() as it would generate a new notification! 
    p6.log.warn("ERROR: Failed to audit error notification!",e)

Script XmlErrorTest:

// Always catch and log errors from error notification scripts 
try {
    def htmlToEmail = p6.xslt.process("LoggingEvent", resource.get('LoggingEvent'), p6.transaction.getUsingPipelineRequest())

    if ('',
            ['subject': '[DEV P6] localhost - Logging Event'], null)) {

        // Remove the stored logging_event after you processed it
        def item = p6.transaction.remove(p6.transaction.getPKUsingPipelineRequest())
        assert item != null
} catch(Exception e) {
    // Cannot use log.error() as it would generate a new notification! 
    p6.log.warn("ERROR: Failed to send error notification email!",e)