[英]How do I show logs in the console using angular-CLI
I'm using angular-cli for webpack. 我正在使用angular-cli作为webpack。
ng serve
服务
and the build succeed and I see 我看到,构建成功了
** NG Live Development Server is running on http://localhost:4200 .
** NG Live Development Server在http:// localhost:4200上运行 。 **
**
Hash: dd30d5aeee6e21802b4d e Time: 9397ms哈希:dd30d5aeee6e21802b4d e时间:9397ms
chunk {0} styles.bundle.js, styles.bundle.map (styles) 163 kB {4} [initial] [rendered]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 {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 {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 {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]chunk {4} inline.bundle.js,inline.bundle.map(inline)0 bytes [entry] [rendered]
webpack: bundle is now VALID.webpack:bundle现在是VALID。
nothing seems to be wrong. 没有什么是错的。 But I don't see any logs on the console when I access http://localhost:4200 .
但是当我访问http:// localhost:4200时,我在控制台上看不到任何日志。 Is there anyway I could turn on the server log on console?
无论如何我可以打开服务器登录控制台吗?
You can't make your angular code log to the shell that started ng serve
, sorry :-( 你不能让你的角度代码登录到开始
ng serve
的shell,抱歉:-(
You will only see build errors in that console 您只会在该控制台中看到构建错误
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
. 虽然您无法在控制台中记录不会导致服务器请求的dom / web事件,但您可以通过在启动时传递
--verbose
标志来增加编译过程和静态Web服务器提供的信息量: ng serve --verbose
。
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. 此外,如果您正在运行代理服务器以访问本地API服务器,并且您想要更多关于如何代理这些请求的日志记录,则可以增加代理配置中的
logLevel
。
Example proxy.conf.json
: 示例
proxy.conf.json
:
{
"/api": {
"target": "http://localhost:3001",
"secure": false,
"logLevel": "debug"
}
}
You would then be starting the server as ng serve --proxy-config proxy.conf.json --verbose
. 然后,您将以
ng serve --proxy-config proxy.conf.json --verbose
启动服务器。
you can also install and run another server. 您还可以安装并运行其他服务器。 a simple one to use can be installed via npm:
一个简单的使用可以通过npm安装:
npm install http-server
if you're using routing, you might want to use spa-http-server 如果您正在使用路由,则可能需要使用spa-http-server
npm install spa-http-server
When I do console.log("something") the log is appearing in the browser inspector console tab. 当我执行console.log(“something”)时 ,日志将显示在浏览器检查器控制台选项卡中。 I do not need any configuration.
我不需要任何配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.