JavaScript Webstite Logging : Logging on Kibana,eslastic,splunk or Server Side

How do we log JavaScript based website code, what are the best practices and solution.

Currently we do not have any logging in Javascript code, we started with small but now it has become humongous and very difficult to debug.

Since, it is not best to use console.log developers avoided to use but now it is next to impossible to track what is happening in the code since that code has several sdk calls and different modules within Javascript.

I have spent time to search on this but looking for more insights on what can we use, my findings are on the below lines

  1. console.log them and send to Kibana,Elastic,Splunk or a VSI and dump log file there.
  2. Elegant way to do the above approach
  3. Use some 3rd party logging framework who can handle this efficiently and elegantly

NOTE: The site is already developed and it would be tough to go to each of the function and add console.log, also want to persist the logs in server or splunk etc