This plug works like morgan, prints all request & result both to console and local file.
Generally, it prints [$userId/$ip/$traceId/${cost}ms $method $url] $status. If there's an error, it will print the error attached. If the config.consoleLevel is set to debug, it will prints
the request body as json format attached.
This plugin needs egg-logger which is a built-in plugin of egg.js. It bases on ctx.logger, so the options of it will also impact this plugin.
Install
NPM
$ npm i egg-console --saveyarn
$ yarn add egg-consoleUsage
// {app_root}/config/plugin.js
exports.console = {
enable: true,
package: 'egg-console',
};Configuration
// {app_root}/config/config.default.js
exports.console = {
consoleLevel: 'info',
success: 'green',
error: 'red',
debug: 'gray',
};If the consoleLevel is not given, the config.logger.consoleLevel will work.
see config/config.default.js for more detail.





