How to show queries in console log using sails?

血红的双手。 提交于 2019-12-12 08:21:56

问题


I am starting a project with sails and mysql, and I do'nt know how configurate it to show the queries executed in the console.


回答1:


Unfortunately this isn't possible with Sails at this time, although the feature has been requested. Your best bet is to inspect the log file provided by your database:

Postgres: How to log PostgreSQL queries?

MySQL: Log all queries in mysql

MongoDB: MongoDB logging all queries




回答2:


The mysql adapter has a debug variable LOG_QUERIES to send all queries to the console.

LOG_QUERIES=true node myFile.js




回答3:


If you're doing Sails.js development on Mac OS with Postgresql.app, you can enable all query logging as follows:

In a new Terminal, edit ~/Library/Application Support/Postgres/var/postgresql.conf and set:

logging_collector = on
log_directory = 'pg_log'
log_statement = 'all'

Then restart Postgresql.app (click on menubar icon, Quit, then use Spotlight to relaunch).

Then tail the log with:

tail -F ~/Library/Application\ Support/Postgres/var/pg_log/postgresql-2014-10-30_104957.log 

You'll have to find the newest postgresql-*log to tail and substitute that above.




回答4:


My answer might me very late but just found a solution which might help people sails version = 0.12.14

to log quires do following

navigate to node_modules\sails-mysql\lib\adapter.js

locate variable declaration of "log"

then change "process.env.LOG_QUERIES" to "sails.config.LOG_QUERIES"

navigate to

[sails root]/config/env/[development or production].js

add

LOG_QUERIES = 'true',

NOTE :- remember to put ""or '' for true




回答5:


Or add log to sql module.

In mysql this is:

working_dir/node_modules/sails-mysql/node_modules/mysql/lib/Connection.js

function **createQuery** (33)



回答6:


Put

LOG_QUERIES = 'true'

in sails lift command



来源:https://stackoverflow.com/questions/22401062/how-to-show-queries-in-console-log-using-sails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!