midwayjs / midway

🍔 A Node.js Serverless Framework for front-end/full-stack developers. Build the application for next decade. Works on AWS, Alibaba Cloud, Tencent Cloud and traditional VM/Container. Super easy integrate with React and Vue. 🌈
https://www.midwayjs.org/
MIT License
7.4k stars 576 forks source link

如何在config.default.ts中将egg logger实例对象复写给typeorm的logger #756

Open rayintee opened 3 years ago

rayintee commented 3 years ago

如题,目前遇到一个尴尬的情况,midway和typeorm高度集成的框架中,无法自定义typeorm的logger对象,自定义sql query等日志输出自定义文件及目录,请问如何解决这个问题

orm: {
        type: "mysql",
        host: "xxxxxx",
        port: 3306,
        username: "xxxxx",
        password: "xxxx",
        database: "xxxx",
        synchronize: false,
        logging: true,

        //高亮字体的打印信息
        // logger: "advanced-console",

        //连接池最大连接数量, 查阅资料 建议是  core number  * 2 + n
        extra: {
            connectionLimit: 16
        },

        //记录所有执行超过2s的操作
        maxQueryExecutionTime: 2000
    }

上述的配置中logger对象无法自定义,求助~

tkvern commented 3 years ago

这个例子有做 Custom Logger 你看看对你有没有帮助 feat(boilerplate): custom-logger