Setting Up Logging and Event Sharing for an Application¶
This topic describes how to set up logging and event sharing to troubleshoot an installed application.
This topic provides information on setting up logging and event sharing as a provider. Refer to Enabling Logging and Event Sharing for an Application for the consumer requirements for configuring this feature.
Logging and trace events allow you to collect information about an application to troubleshoot errors. Using logging and trace events, you can also get a better idea of how your application runs and improve your application later.
Workflow for Setting Up Logging and Event Sharing as a Provider¶
As a provider, you can set up logging and event sharing for an application by performing the following:
After the consumer installs an application and enables logging and event sharing, you can view logging and event information shared by the installed application:
Considerations for Using Logging and Event Sharing¶
Before using logging and event sharing for an application, you must consider the following:
You are responsible for all costs associated with event sharing on the provider side, including data ingestion and storage.
You must have an account to store shared events in each region where you want to support event sharing.
You must define the default log level and trace level for an application in the manifest file.
Configuring Logging and Trace Events In Functions and Procedures¶
The Native Apps Framework requires an event table to store log messages and trace events generated from functions and stored procedures in an application.
If the consumer of your application does not set up an event table and make it the active table before installing the application, event and logging data are discarded.
An account can have multiple event tables, but only one of them can be set as the active event table for a Snowflake account at a time. Without an active event table, log messages and trace events generated by the application are not captured. This is true even if the functions and procedures in an application call the logging and trace event APIs.
After code has recorded log messages and trace events, you can query recorded data.
For information about recording and querying log and trace data, refer to the following:
Setting the Log and Trace Level in the Manifest File¶
To set the default log and trace event levels for a version of an application, set the
trace_level parameters in the manifest file as shown in the following example:
artifacts: setup_script: setup.sql configuration: trace_level: OFF log_level: DEBUG
When a provider enables tracing, a Snowflake Native App automatically captures the start and end times for all queries and stored procedure calls.
Publishing a Snowflake Native App with the
trace_level property set to a value other than
might expose calls to hidden stored procedures to any user in the consumer account who can view
the event table.
When the Snowflake Native App is initially installed, it uses the log levels defined in the manifest file. If the log level is changed in a subsequent upgrade, the new log level takes effect after the upgrade process completes.
Similarly, any session level settings for the logging level are ignored by the application.
Viewing the Logging and Trace Event Levels Defined in an Application Package¶
Use the DESCRIBE APPLICATION command to view the logging level of an installed application, as shown in the following command:
DESC APPLICATION HelloSnowflake;
Use the SHOW VERSIONS command to view the logging level the application versions defined in an application package, as shown in the following example:
SHOW VERSIONS IN APPLICATION PACKAGE HelloSnowflake;