Enable SQL Query Logging

The Fluent drivers log the SQL they generate at the debug log level. This allows you to opt in to seeing the SQL generated without making it too noisy. This also follow the guidance from the SSWG on library logging.

blog.vapor.codes/posts/enable-db-query-logging/

Fluent drivers, such as FluentPostgreSQL, log generated SQL at the debug level by default, aligning with Swift Server Workgroup (SSWG) guidelines to keep logs non-intrusive.

You can configure the log level for specific drivers, like setting FluentPostgreSQL to log at the info level using the sqlLogLevel parameter in the database configuration.

To enable SQL logging across your application, set app.logger.logLevel = .debug in configure.swift, allowing SQL statements to appear in the console during the next build and run. This setup provides flexibility to monitor SQL queries without excessive noise.


Category:

Year: