Fun with Go Functions: Flexible Oracle Functions Logging to Syslog

Published by Max Jahn on

Oracle recently added a new logging service to their offering. This logging service supports both custom and service logs. The former is your classic “agent-sends-log-to-logserver” type of log service. The latter will finally give access to logs coming from services such as Load Balancers, API Gateways, Events or Functions.

While i really have missed this for most of the services, there still are some situations where i prefer the smooth experience tools like papertrail offer. Especially the immediate visibility of log entries make life so much easier when trying to debug a serverless function that gets triggered by cloud events.

So i see a real need for still being able to use other logging services than the Oracle cloud service.

One big advantage of fnproject being nothing more than a docker image fulfilling a certain contract is that there is nothing that stops you from using a different log service.

For my purposes i created a simple Go function to enable logging to either a syslog destination or the classical STDERR. This can be configured by an environment variable. Maybe you will it or something similar useful for your own projects.


import (
    fdktools ""

logger = fdktools.InitLogger("fn/event-dns-autoregister")

logger.Fatalln("Something went terribly wrong, better exit now.")

When initializing the logger, you need to pass a tag string that will be added as a prefix to the log entries. By default you get standard logger behaviour, i.e. logs will be written to STDERR. But you can as well use a syslog service by adding the parameter FN_LOG_DESTINATION to the configuration of your function.

The value for FN_LOG_DESTINATION should be an URI in the format
protocol:://logerserver:port. Currently only tcp and udp are supported as protocols. An example for a valid destination URI is tcp://


For debugging and development purpose i always would use a service like papertrail that shows the log entries nearly immediate. But if the function is in actual use, i probably want to use the facilites provided out of the box by my cloud environment.