RMB log level

RMB log level

RMB based modules provide the PUT /admin/loglevel API that changes the log level at runtime. This API exists since RMB version 0.0.1 released 2016.

This is not tenant specific, it applies to all tenants.

Possible log level are ERROR, WARN, INFO, DEBUG, TRACE.

Examples:

curl -XPUT 'http://mod-x:8081/admin/loglevel?level=WARN&java_package=org.folio.cql2pgjson.CQL2PgJSON' (change for one class only)

curl -XPUT 'http://mod-x:8081/admin/loglevel?level=WARN&java_package=org.folio.rest.persist' (change for all classes in that package)

curl -XPUT 'http://mod-x:8081/admin/loglevel?level=WARN' (change for all classes)

Example for a cron job:

MODULES=" mod-feesfines-19-3-2 mod-inventory-storage-29-0-13 " CLASSES=" org.folio.cql2pgjson.CQL2PgJSON org.folio.rest.persist.cql.CQLWrapper org.folio.rest.tools.utils.LogUtil " for module in $MODULES do for class in $CLASSES do curl -XPUT "http://${module}/admin/loglevel?level=WARN&java_package=${class}" || true done done

PostStart Lifecycle Hooks

Kubernetes, Rancher, Helm Charts, docker-compose, and other tools allow to automatically run a command in the container after it has started.

Before Trillium the PUT /admin/loglevel call has no effect if the class hasn’t logged anything at that time. Therefore a PostStart hook run at container startup needs to make a call that causes the class to log.

Example for mod-feesfines:

sh -c 'for i in `seq 30`; do wget -q -O \dev\null --header X-Okapi-Tenant:diku "localhost:8081/feefines?query=PostStart=1" && break; sleep 1; done; echo -ne "PUT /admin/loglevel?level=WARN&java_package=org.folio.cql2pgjson.CQL2PgJSON HTTP/1.0\r\n\r\n" | nc localhost 8081 || true'

Replace diku with an existing tenant. For other modules replace /feefines with a GET API of that module.

Implementation details: The for loop repeats until the Java code can successfully process requests. The PostStart=1 query triggers some CQL2PgJSON logging. The PUT request is sent via nc because BusyBox' wget doesn’t support PUT. After 30 attempts we ignore failures to allow the container to run without changed log level.