Logging

Availability table

Controller availability

Module

Available

module.scripts

Supported feature

module.keycloak

Supported feature

log controller

Allow scripts to log messages into docker container and services logs. You can consult logs using portainer interface or docker command.

Available service logs:

  • trace

  • debug

  • info

  • warn

  • error

communications.sendStaticNotification(
    log.info("Starting script.");
    let message = { test: 1 };
    log.warn("Message with parameter part {}", message);

Warning

Logging an array

   log.info("my list [{}]", [1, 2, 3]);


will give you
   15:13:35.184 [Test worker] INFO script.logger.test -- my list [1]


which is not the expected result
   15:13:35.184 [Test worker] INFO script.logger.test -- my list [[1, 2, 3]]


This is due to a limitation when converting the object between ``javascript`` and ``java``, a workaround is to warp the array with ``JSON.stringify``.
log.info("my list [{}]", JSON.stringify([1, 2, 3]));
log.debug(message: string, arguments?: any[])

Log a message with severity debug.

Arguments:
  • message

  • arguments

log.error(message: string, arguments?: any[])

Log a message with severity error.

Arguments:
  • message

  • arguments

log.info(message: string, arguments?: any[])

Log a message with severity info.

Arguments:
  • message

  • arguments

log.trace(message: string, arguments?: any[])

Log a message with severity trace.

Arguments:
  • message

  • arguments

log.warn(message: string, arguments?: any[])

Log a message with severity warn.

Arguments:
  • message

  • arguments