[英]sequelize: How to log raw query
I use sequelize
with postgresql
and logger winston
.我将sequelize
与postgresql
和记录器winston
。 Here is my code:这是我的代码:
logging: e => logger('sequelize').info(e)
this logs the result like this:这会记录这样的结果:
INSERT INTO "test" ("id","aa","bb","cc") VALUES (DEFAULT,$1,$2,$3) RETURNING *; // I don't want this
how to change so that the output will like this?如何更改以便输出会像这样?
INSERT INTO "test" ("id","aa","bb","cc") VALUES (DEFAULT,"AA","BB","CC") RETURNING *; // I want this
There is an option for this in the Sequelize constructor:在 Sequelize 构造函数中有一个选项:
logQueryParameters : true
It does work, but you might have to play around with it to get the log formatted the way you want.它确实有效,但您可能必须尝试使用它才能按照您想要的方式格式化日志。 Unfortunately, I can't find any good examples.不幸的是,我找不到任何好的例子。 There was a recent bug fix of this feature, so make sure your package is current.此功能最近有一个错误修复,因此请确保您的软件包是最新的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.