0

My angular app is deployed on a Kubernetes container and the logs of the application on that container are scraped only if they are outputted as stdout or stderr. In my angular application, I am currently logging using console.log as I believe it's the same function Question I referred , want to know if this is correct or if stdout is something else?

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102
FatBoy98
  • 3
  • 4
  • 1) What does this have to do with elasticsearch? 2) Your angular application is not a nodeJS application -- the two concepts are quite different and I don't think it makes sense to talk about `stdout` in the angular context. `console.log` prints only to the web client... – Joe - GMapsBook.com Nov 10 '20 at 11:36
  • I think in production mode it's not recommended to use console.log and should be disabled! – Rebai Ahmed Nov 10 '20 at 15:27
  • @RebaiAhmed so is it not recomended to log in client side of web applications – FatBoy98 Nov 11 '20 at 01:47
  • Yes, try always to debug your code wit breakpoints and how to handle Errors – Rebai Ahmed Nov 11 '20 at 10:22

1 Answers1

2

Short answer: no

The Angular app runs in the users browser. That means any logs using console.log will be logged on the user side in their browser and Kubernetes will not know about it.

The part that runs in Kubernetes is actually a static web server like Nginx or perhaps a NodeJS server that is just serving up the files.

If you have a backend service (like NodeJS) the logs in the server process will show up in stdout and stderr. Those can be picked up in Kubernetes.

To get the logs from Angular you would need to send them from the client to the backend over REST or something similar.

Justin Tamblyn
  • 719
  • 8
  • 21
  • 1
    thanks for the answer. Is it that you dont normally log in client side of web applications ? – FatBoy98 Nov 11 '20 at 01:45
  • Super. People will often use a service to pump the front-end logs somewhere. Checkout Rollbar (https://rollbar.com/). I'm not affiliated but using it from one of my projects. The alternative is to roll your own. You would need to host an API on the server side and then make Angular capture the logs and send them to the API on the server. https://stackoverflow.com/questions/55241453/angular-client-side-errors-log-to-server – Justin Tamblyn Nov 11 '20 at 11:06