egg-scripts 启动生成日志地址如何更改?

Created on 19 Jul 2018  ·  12Comments  ·  Source: eggjs/egg

  • Node Version:8.4.0
  • Egg Version:2.2.0
  • Plugin Name:
  • Plugin Version:
  • Platform: linux
  • Mini Showcase Repository:

你好,我在linux服务器启动 egg-scripts的时候,会在 $HOME/logs 生成文件夹,我已经看过关于 egg-scripts的配置了,配置如下

egg-scripts start --env=test --workers=4 --daemon --stdout=$HOME/项目名称/logs/master-stdout.log --stderr=$HOME/项目名称logs/master-stderr.log --title=项目名称

而且在 config里面也配置了
logger: {
dir: '/home/front/项目名称/logs/',

}

现在的问题是,启动egg-scripts 的时候,还是会生成 两个文件夹,一个是 alinode 还有一个是 项目名称的文件夹,如下图,我想问的是,怎样才能 把$HOME/logs 这个文件夹转到我自己config里的dir目录去,需要那行配置吗?我没找到相关的说明。
image

All 12 comments

Translation of this issue:


egg-scripts How do I change the generated log address?

  • Node Version: 8.4.0
  • Egg Version: 2.2.0
  • Plugin Name:
  • Plugin Version:
  • Platform: linux
  • Mini Showcase Repository:

Hello, when I start egg-scripts on the Linux server, I will generate a folder in $HOME/logs. I have read about the configuration of egg-scripts, the configuration is as follows

Egg-scripts start --env=test --workers=4 --daemon --stdout=$HOME/project name/logs/master-stdout.log --stderr=$HOME/project name logs/master-stderr.log --title=project name

And also configured in the config
Logger: {
            Dir: '/home/front/project name/logs/',

}

The problem is that when you start egg-scripts, you will still generate two folders, one is alinode and the other is the project name folder, as shown below, I want to ask, how can I put $HOME/logs this? The folder goes to the dir directory in my own config. Do I need that line configuration? I did not find the relevant instructions.
image

看 alinode 插件

@popomore 你好,我用egg-scripts 启动项目,并没有下载 egg-alinode 插件,${appInfo.root}/logs 下为什么还会生成 alinode日志,你说让我看 alinode插件,但是里面讲解的都是 线安装 egg-alinode 之后配置,我自己项目根本就没引用 egg-alinode,更何谈设置了,请问这种情况你遇到过吗?

谁来解决一下这个问题?

@popomore 你好,我用egg-scripts 启动项目,并没有下载 egg-alinode 插件,${appInfo.root}/logs 下为什么还会生成 alinode日志,你说让我看 alinode插件,但是里面讲解的都是 线安装 egg-alinode 之后配置,我自己项目根本就没引用 egg-alinode,更何谈设置了,请问这种情况你遇到过吗?

https://github.com/eggjs/egg-scripts/blob/master/lib/cmd/start.js#L123

这里只是创建了一个目录,但不会写日志进去。是这里困扰到你吗?

@hyj1991 https://github.com/eggjs/egg-scripts/blob/ad585eb4e25e3b07320419b36f68174af9ad235a/lib/cmd/start.js#L123

这里的 mkdir 逻辑挪到 egg-alinode 去会不会太晚了?还是 alinode 那边会自动建这个目录?

@hyj1991 https://github.com/eggjs/egg-scripts/blob/ad585eb4e25e3b07320419b36f68174af9ad235a/lib/cmd/start.js#L123

这里的 mkdir 逻辑挪到 egg-alinode 去会不会太晚了?还是 alinode 那边会自动建这个目录?

alinode 没有创建目录,这里显然是强行设置 ENABLE_NODE_LOG =YES (不管 runtime 是不是 alinode),理论上这一行的 mkdirp 应该放到 egg-alinode 插件里面,而不是 egg-scripts 里面吧

但 ENABLE_NODE_LOG 放到 egg-alinode 就晚了吧。

mkdirp 来个 PR 搞搞?

但 ENABLE_NODE_LOG 放到 egg-alinode 就晚了吧。

mkdirp 来个 PR 搞搞?

ENABLE_NODE_LOG 是得放到 egg-scripts 里面,当时只支持环境变量的方式局限性比较多,所以我现在搞的那个支持 js 传参了,这种场景下灵活一些。

不过我看这位同学的描述:

现在的问题是,启动egg-scripts 的时候,还是会生成 两个文件夹

显然并不只是这里 mkdirp alinode 文件夹造成的吧?

@atian25 我想了下,NODE_LOG_DIR 的创建也不能放到插件里,因为如果用的是 alinode runtime 的话,egg-scripts 一启动直接就开始写文件了

@llsldwy 要不试下启动前加上 MOCK_HOME_DIR=/path/to/your/project/logs 启动看下,我看了下这里的 home 目录判断在这里:

https://github.com/node-modules/node-homedir/blob/master/index.js#L6

MOCK_HOME_DIR 这个单测的桩环境变量感觉是可以改变这里的 logdir 指向的

我想了下,NODE_LOG_DIR 的创建也不能放到插件里,因为如果用的是 alinode runtime 的话,egg-scripts 一启动直接就开始写文件了

我上面提到了,放插件就很晚了。

Was this page helpful?
0 / 5 - 0 ratings