# Capturing logs from a browser (SPA)

**URL:** <https://discuss.elastic.co/t/capturing-logs-from-a-browser-spa/175159>\
**Category:** Logs\
**Created:** [April 3, 2019, 10:13am UTC](https://discuss.elastic.co/t/capturing-logs-from-a-browser-spa/175159 "2019-04-03T10:13:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Russell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matt_russell/32/42429_2.png) [@Matt\_Russell](https://discuss.elastic.co/u/Matt_Russell)\
**Post date:** [April 3, 2019, 10:13am UTC](https://discuss.elastic.co/t/capturing-logs-from-a-browser-spa/175159/1 "2019-04-03T10:13:49Z")

</div>

I wondered if anyone had any good patterns or advice on collecting logs from a single-page application (SPA) running in user browsers and getting them into Elasticsearch? I guess one approach might be to post AJAX to a /logs endpoint on our backend.

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [April 5, 2019, 8:57am UTC](https://discuss.elastic.co/t/capturing-logs-from-a-browser-spa/175159/2 "2019-04-05T08:57:13Z")

</div>

Hi @Matt_Russell,

that sounds like a sensible approach, especially since it doesn't leak sensitive customer information to third-party services. This is a particularly useful property since it is less likely to be blocked by privacy-enhancing browser plugins and doesn't require additional legal data processing agreements. (I'm not a legal expert though, so please don't take this as legal advice. Your legal council and data protection officer should be involved in designing this.)

There are a few features that could improve the UX and DX such as buffering/batching the submissions in general while immediate flushing to server for error logs.

If you opt to implement something like that for yourself, I would recommend taking a look at the [Elastic Common Schema](https://github.com/elastic/ecs/) to guide your design. That will make correlation with other log sources, e.g. from filebeat a lot easier down the road.

I'd be interested to hear what approach you decide on. 😉

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 3, 2019, 9:08am UTC](https://discuss.elastic.co/t/capturing-logs-from-a-browser-spa/175159/3 "2019-05-03T09:08:07Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
