Oracle Cloud Infrastructure Documentation

Storing and Viewing Function Logs

When a function you've deployed to Oracle Functions is invoked, you'll typically want to store the function's logs so that you can review them later. You specify where Oracle Functions stores a function's logs by setting a logging policy for the application containing the function. You can specify that Oracle Functions:

  • Stores logs in Oracle Cloud Infrastructure. Note that until an Oracle Cloud Infrastructure logging service is released, Oracle Functions stores logs as files in a storage bucket in Oracle Cloud Infrastructure Object Storage.
  • Stores logs by exporting them to an external logging destination like Papertrail. Note that to use an external logging destination, you must have set up a VCN with public subnets and an internet gateway (see Create the VCN and Subnets to Use with Oracle Functions, if they don't exist already).

You set application logging policies in the Console.

Using the Console

To store logs for the functions in an application:

  1. Log in to the Console as a functions developer.
  2. In the Console, open the navigation menu. Under Solutions and Platform, go to Developer Services and click Functions.
  3. Select the region you are using with Oracle Functions. Oracle recommends that you use the same region as the Docker registry that's specified in the Fn Project CLI context (see 6. Create an Fn Project CLI Context to Connect to Oracle Cloud Infrastructure).
  4. Select the compartment containing the application with functions for which you want to store the logs.

    The Applications page shows all the applications in the compartment you selected.

  5. To set the logging policy:
    • for a new application, click Create Application and set properties for the new application
    • for an existing application, click the name of the application, and then click Edit Application

    By default, Logging Policy is set to None, so logs are not stored.

  6. To store logs, select one of the following Logging Policy options:

    • Select the Log to Object Storage option to store logs as files in a storage bucket in Oracle Cloud Infrastructure Object Storage.
    • Select the Syslog URL option to store logs in an external logging destination, and enter the syslog URL to which to export the logs. For example, tcp://my.papertrail.com:4242
  7. Click Save.

Whenever a function is invoked in this application, its logs are stored according to the logging policy that you specified.

To view the logs for a function that have been stored in a storage bucket in Oracle Cloud Infrastructure Object Storage:

  1. Log in to the Console as a functions developer.
  2. In the Console, open the navigation menu. Under Solutions and Platform, go to Developer Services and click Functions.
  3. Select the region you are using with Oracle Functions. Oracle recommends that you use the same region as the Docker registry that's specified in the Fn Project CLI context (see 6. Create an Fn Project CLI Context to Connect to Oracle Cloud Infrastructure).
  4. Select the compartment containing the application with the function for which you want to see the logs.

    The Applications page shows all the applications in the compartment you selected.

  5. Click the name of the application containing the function for which you want to see the logs.
  6. On the Application Information tab, click Logs: Object Storage to see the Bucket Details page in a separate browser tab. The Bucket Details page shows a list of files containing the logs for functions in the compartment you selected. Each log file name includes the OCID of the associated function.

    If the storage bucket doesn't contain the log files you're expecting, or you see an error message saying that the storage bucket doesn't exist, note the following:

    • A storage bucket is only created after the first log file has been written.
    • After a function has been invoked, it takes around 15 minutes for the function's log files to be written to Object Storage and appear in a storage bucket. So you won't see a storage bucket for a function until around 15 minutes after the function has been invoked for the first time.
    • If you have waited for longer than 15 minutes and you still don't see a storage bucket for a function, double-check that the function includes log statements.
  7. (Optional) If a large number of log files are shown in the list, enter log/<function-OCID> in the Search field to reduce the list to a manageable size.
  8. Click the name of a log file to download it.