Replies: 2 comments 1 reply
-
nacosClient.subscribe({ dataId: nacosOptions.dataId, group: nacosOptions.group }, async (configYamlStr: any) => {
try {
const config: any = YAML.parse(configYamlStr);
const level = config?.logger?.level as LoggerLevel || 'info';
this.logger.level = level;
this.logger.get("json").level = level;
this.logger.get("console").level = level;
this.logger.get("error").level = level;
this.app.addConfigObject({
//将MSE
config: config,
})
this.logger.info("nacos配置加载完成", level == 'debug' ? config : '');
} catch (e) {
this.logger.error("配置转换成JSON异常", e, configYamlStr)
}
}) 试出来这样可行,是不是正确用法? |
Beta Was this translation helpful? Give feedback.
0 replies
-
看着怪怪的,按理日志这个东西就不应该动态改了,毕竟改了之后相当于是全局生效了。 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the problem(描述问题)
想在nacos中配置日志等级,出现问题时调成debug级别,不知道该怎么处理
Midway Versions(Midway 版本)
npm http fetch GET 200 https://registry.npmmirror.com/midway-version 135ms (cache revalidated)
✓ @midwayjs/faas-typings(not installed)
✓ @midwayjs/fc-starter(not installed)
✓ @midwayjs/serverless-http-parser(not installed)
✓ @midwayjs/async-hooks-context-manager(3.18.0)
✓ @midwayjs/axios(not installed)
✓ @midwayjs/bootstrap(3.18.2)
✓ @midwayjs/bull(not installed)
✓ @midwayjs/bull-board(not installed)
✓ @midwayjs/busboy(not installed)
✓ @midwayjs/cache-manager(not installed)
✓ @midwayjs/captcha(not installed)
✓ @midwayjs/casbin(not installed)
✓ @midwayjs/casbin-redis-adapter(not installed)
✓ @midwayjs/casbin-typeorm-adapter(not installed)
✓ @midwayjs/code-dye(not installed)
✓ @midwayjs/consul(not installed)
✓ @midwayjs/core(3.18.0)
✓ @midwayjs/cos(not installed)
✓ @midwayjs/cron(not installed)
✓ @midwayjs/cross-domain(not installed)
✓ @midwayjs/decorator(not installed)
✓ @midwayjs/etcd(not installed)
✓ @midwayjs/express-session(not installed)
✓ @midwayjs/faas(not installed)
✓ @midwayjs/grpc(not installed)
✓ @midwayjs/http-proxy(not installed)
✓ @midwayjs/i18n(3.18.2)
✓ @midwayjs/info(3.18.2)
✓ @midwayjs/jwt(not installed)
✓ @midwayjs/kafka(not installed)
✓ @midwayjs/leoric(not installed)
✓ @midwayjs/mikro(not installed)
✓ @midwayjs/mock(3.18.2)
✓ @midwayjs/mongoose(not installed)
✓ @midwayjs/mqtt(not installed)
✓ @midwayjs/oss(not installed)
✓ @midwayjs/otel(not installed)
✓ @midwayjs/passport(not installed)
✓ @midwayjs/process-agent(not installed)
✓ @midwayjs/prometheus(not installed)
✓ @midwayjs/prometheus-socket-io(not installed)
✓ @midwayjs/rabbitmq(not installed)
✓ @midwayjs/redis(3.18.2)
✓ @midwayjs/security(not installed)
✓ @midwayjs/sequelize(not installed)
✓ @midwayjs/session(3.18.2)
✓ @midwayjs/socketio(not installed)
✓ @midwayjs/static-file(not installed)
✓ @midwayjs/swagger(not installed)
✓ @midwayjs/tablestore(not installed)
✓ @midwayjs/tags(not installed)
✓ @midwayjs/tenant(not installed)
✓ @midwayjs/typegoose(not installed)
✓ @midwayjs/typeorm(not installed)
✓ @midwayjs/upload(not installed)
✓ @midwayjs/validate(3.18.2)
✓ @midwayjs/version(not installed)
✓ @midwayjs/view(not installed)
✓ @midwayjs/view-ejs(not installed)
✓ @midwayjs/view-nunjucks(not installed)
✓ @midwayjs/web(not installed)
✓ @midwayjs/express(not installed)
✓ @midwayjs/koa(3.18.2)
✓ @midwayjs/ws(not installed)
Beta Was this translation helpful? Give feedback.
All reactions