Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I show logs in the console using angular-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?

like image 764
TMEE Avatar asked Dec 09 '16 09:12

TMEE


People also ask

Can you console log in Angular?

Programmers frequently use console. log to record errors or other informational messages in their Angular applications. Although this is fine while debugging your application, it's not a best practice for production applications.

Where do Angular console logs go?

log Function in Angular. console. log is a JavaScript function that logs messages to the developer's console or the browser console to the web page.


1 Answers

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.

like image 107
Jacob Dalton Avatar answered Oct 21 '22 15:10

Jacob Dalton