TMEE
TMEE

Reputation: 261

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?

Upvotes: 26

Views: 52269

Answers (5)

Jacob Dalton
Jacob Dalton

Reputation: 1693

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.

Upvotes: 16

Allan Nienhuis
Allan Nienhuis

Reputation: 4111

you can also install and run another server. a simple one to use can be installed via npm:

npm install http-server

if you're using routing, you might want to use spa-http-server

npm install spa-http-server

Upvotes: 1

Deepak Singh Mehta
Deepak Singh Mehta

Reputation: 43

You need to change the filter in console window of your google chrome browser, then you can see the message which you have written in console.log() method. enter image description here

Upvotes: 1

Johan Blomgren
Johan Blomgren

Reputation: 618

You can't make your angular code log to the shell that started ng serve, sorry :-(

You will only see build errors in that console

Upvotes: 8

kimy82
kimy82

Reputation: 4465

When I do console.log("something") the log is appearing in the browser inspector console tab. I do not need any configuration.

Upvotes: 2

Related Questions