【发布时间】:2020-11-20 23:18:20
【问题描述】:
简单的问题。 Typeorm 不记录任何内容。我已按照https://orkhan.gitbook.io/typeorm/docs/logging上的说明进行操作
ormconfig.json
{
"type": "mongodb",
"host": "aaa",
"port": 27017,
"username": "bbb",
"password": "ccc",
"ssl": true,
"database": "db",
"entities": ["dist/entity/*.js"],
"logging": true
}
我也试过logging: "all、logging: ["query"],但都没有任何效果。
这是我设置应用程序 (app.ts) 的方式
createConnection()
.then(async (connection) => {
// create koa app
const app = new Koa();
const router = new Router();
// register all application routes
AppRoutes.forEach((route) =>
router[route.method](route.path, route.action)
);
// run app
app.use(bodyParser());
app.use(router.routes());
app.use(router.allowedMethods());
app.listen(3000);
console.log("Koa application is up and running on port 3000");
})
.catch((error) => console.log("TypeORM connection error: ", error));
我的其他 console.logs 显示得很好,但 typeorm 没有。
我用tsc && node dist/app.js开始这个项目
之后我发出一个 API 请求,查询一个端点,typeorm 将一路查询 Mongodb,并返回我的数据。但我没有看到任何日志。
以前有没有人遇到过这个问题,或者这是一个新的错误?
【问题讨论】:
-
提供
createConnection逻辑。
标签: node.js typescript typeorm koa