Angular – How to show logs in the console using angular-CLI

angularangular-cli

I'm using angular-cli for webpack.

ng serve

and the build succeed and I see

** 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.

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?

Best Answer

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.

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.

Example 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.

Related Topic