/supabase-tutorials

How to enable logs in Supabase?

Learn to enable logs in Supabase with our step-by-step guide. Access your dashboard, set up log destinations, enable PostgreSQL extensions, and verify your configuration.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to enable logs in Supabase?

 

Step 1: Access the Supabase Dashboard

 

To begin enabling logs in Supabase, access your Supabase project dashboard. Navigate to the Supabase website, log in with your credentials, and select the project for which you want to enable logs.

 

Step 2: Set Up a Log Destination

 

To enable logs, you must first set up a destination to where your logs will be sent. Supabase uses established PostgreSQL extensions for logging.

 

Step 3: Enable Extensions for Logging

 

You need to enable specific extensions in your database that can handle logging.

  1. Navigate to the SQL editor in your Supabase dashboard.
  2. Run the following SQL commands, which will enable extensions that might be helpful for logging:

-- To enable the pg_stat_statements extension which helps in logging query statistics
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;

-- Optionally, you can enable other extensions based on your logging needs:
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE EXTENSION IF NOT EXISTS pgaudit;

Ensure each command runs successfully before proceeding.

 

Step 4: Configure PostgreSQL for Logging

 

Supabase allows you to modify PostgreSQL parameters using the 'Database settings' within your dashboard. To configure your database for logging:

  1. Go to the 'Settings' section in your Supabase project dashboard.
  2. Under the 'Database' tab, find the 'Configuration' section.
  3. Look for options like log_statement and log_duration. These settings allow you to log various activities:
  • log_statement can be set to none, ddl, mod, or all depending on what you need to log (DDL statements, modifications, or all statements).

 

Step 5: Customize Logging Behavior

 

Modify logging settings in the SQL editor according to your requirements:


-- For logging all statements
ALTER SYSTEM SET log\_statement = 'all';

-- For logging only DDL and modifications
ALTER SYSTEM SET log\_statement = 'mod';

-- For logging statement durations (query execution times)
ALTER SYSTEM SET log\_duration = 'on';

After setting these, reload the configurations by running:


SELECT pg_reload_conf();

 

Step 6: Verify Logging Setup

 

It's important to verify if your configurations have been applied correctly. You can do this by querying for recent log entries.

  1. Use the pg_stat_statements view to check for recent queries and their statistics.

SELECT \* FROM pg_stat_statements ORDER BY calls DESC LIMIT 10;
  1. If necessary, consult application logs to ensure statements are being logged as expected.

 

Step 7: Manage and Monitor Logs Regularly

 

Regular monitoring and management of logs are crucial to maintaining database health. Set up alerts or periodically review logs to identify issues or optimize query performance.

 

By following these steps, you should be able to enable and configure logging within Supabase, allowing you to monitor database activity effectively.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022