Logging Messages from Functions and Procedures

You can log messages (such as warning or error messages) from a stored procedure, UDF, or UDTF, including those you write using Snowpark APIs. You can access the logged messages from an event table (a type of predefined table that captures events, including logged messages). For a list of supported handler languages, refer to Supported Languages.

For example, in a Java UDF, you can use the SLF4J API to log messages. Later, you can access those logged messages in an event table.


Before you can begin logging messages, you must set up an event table. For more information, refer to Setting up an Event Table.

Logging Example

The Python code in the following example imports the logging module, gets a logger, and logs a message at the INFO level.


A message logged from a method that processes an input row will be logged for every row processed by the UDF. If the UDF is executed in a large table, this can result in a large number of messages in the event table.

import logging

logger = logging.getLogger("mylog")

def test_logging(self):
    logger.info("This is an INFO test.")

Getting Started

To get started logging from handler code, follow these high-level steps:

  1. Set up an event table.

    Snowflake will use your event table to store messages logged from your handler code. An event table has columns predefined by Snowflake.

  2. Get acquainted with the logging API for the handler language you’ll be using.

    Refer to Supported Languages for a list of handler languages, then view content about how to log from your language.

  3. Add logging code to your handler.

  4. Learn how to retrieve logging data from the event table.

Level for Log Messages

You can manage the level of log event data stored in the event table by setting the log level. Before logging, use this setting to make sure you’re capturing the log message severity.

For more information, refer to Setting log level.

Supported Languages

You can log messages from code written in the following languages, including when handler code is written with Snowpark APIs.

Language / Type






Stored procedure handler

✔ **

Streamlit app

UDF handler (scalar function)

UDTF handler (table function)

✔ *



Scala UDTF handler written in Snowpark.


Snowflake Scripting used to write stored procedures.


Logging is not supported for Request and response translators in external functions.

Handler Code Language Support

To log messages, you can use functions common to your handler code language. Snowflake intercepts messages and stores them in the event table you create.

For example, in a Java UDF, you can use the SLF4J API to log messages. Later, you can access those logged messages in an event table.

If you plan to log messages when errors occur, you should log them from within the construct for handling errors in the language that you are using. For example, in a Java UDF, call the method for logging a message in the catch block where you handle the exception.

The following table lists handler languages supported for logging, along with links to content on logging from code.


Logging Library




Logging Messages in Java


Snowflake JavaScript API snowflake object

Logging Messages in JavaScript


Standard Library logging module

Logging messages in Python



Logging Messages in Scala

Snowflake Scripting

Snowflake SYSTEM$LOG function.

Logging Messages in Snowflake Scripting

Log Message Access

You can access log messages stored in your event table by executing a SELECT command on the event table. For more information, refer to Accessing Logged Message Data.