Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loopback 4: Debug SQL Statements

I'm new to Loopback. I have used Sequelize ORM in the past, and I'm used to seeing Sequelize output the SQL statements to the Console. How can I do the same with Loopback 4? I've done extensive searching on the web, and I found a place where they suggested to add debug: true to the datasource config json file. However, this change had no effect.

Any help is greatly appreciated.

like image 838
Peruz Carlsen Avatar asked Sep 01 '25 02:09

Peruz Carlsen


1 Answers

Hello from the LoopBack team 👋

We use debug module to deal with debug logging and most connectors print SQL statements in their debug log.

You can enable debug logs by setting the environment variable DEBUG. For example, on a Unix system (Unix, MacOS), you can run the following command:

DEBUG=loopback:connector* npm start

On Windows, you have to set the variable in a standalone command.

set DEBUG=loopback:connector*
npm start
like image 72
Miroslav Bajtoš Avatar answered Sep 03 '25 02:09

Miroslav Bajtoš