如何使用 angular-CLI 在控制台中显示日志 [英] How do I show logs in the console using angular-CLI
问题描述
我正在为 webpack 使用 angular-cli.
I'm using angular-cli for webpack.
ng 服务
构建成功,我明白了
** NG Live Development Server 在 http://localhost:4200 上运行.**
哈希:dd30d5aeee6e21802b4d e 时间:9397ms
块{0}styles.bundle.js、styles.bundle.map(样式)163 kB {4} [initial] [rendered]
块 {1} main.bundle.js, main.bundle.map (main) 6.52 kB {3} [initial] [rendered]
块 {2} scripts.bundle.js, scripts.bundle.map (scripts) 361 kB {4} [initial] [rendered]
块{3} vendor.bundle.js, vendor.bundle.map (vendor) 2.22 MB [initial] [rendered]
chunk {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]
webpack:包现在有效.
** NG Live Development Server is running on http://localhost:4200. **
Hash: dd30d5aeee6e21802b4d e Time: 9397ms
chunk {0} styles.bundle.js, styles.bundle.map (styles) 163 kB {4} [initial] [rendered]
chunk {1} main.bundle.js, main.bundle.map (main) 6.52 kB {3} [initial] [rendered]
chunk {2} scripts.bundle.js, scripts.bundle.map (scripts) 361 kB {4} [initial] [rendered]
chunk {3} vendor.bundle.js, vendor.bundle.map (vendor) 2.22 MB [initial] [rendered]
chunk {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]
webpack: bundle is now VALID.
好像没什么问题.但是当我访问 http://localhost:4200 时,我在控制台上没有看到任何日志.无论如何我可以在控制台上打开服务器登录吗?
nothing seems to be wrong. But I don't see any logs on the console when I access http://localhost:4200. Is there anyway I could turn on the server log on console?
推荐答案
虽然不能在控制台记录不引起服务器请求的 dom/web 事件,但可以增加编译过程和静态 Web 服务器通过在启动时传递 --verbose
标志来提供:ng serve --verbose
.
Although you can't log dom/web events in the console that don't cause server requests, you can increase the amount of information that the compilation process and static web server provide by passing a --verbose
flag when starting up: ng serve --verbose
.
此外,如果您正在运行代理服务器来访问本地 API 服务器,并且您想要更多关于这些请求如何被代理的日志记录,您可以在代理配置中增加 logLevel
.
Also, if you're running a proxy a server to hit a local API server and you want some more logging regarding how those requests are being proxied, you can increase the logLevel
in your proxy configuration.
示例proxy.conf.json
:
{
"/api": {
"target": "http://localhost:3001",
"secure": false,
"logLevel": "debug"
}
}
然后,您将以 ng serve --proxy-config proxy.conf.json --verbose
的形式启动服务器.
You would then be starting the server as ng serve --proxy-config proxy.conf.json --verbose
.
这篇关于如何使用 angular-CLI 在控制台中显示日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!