At Logentries we provide a comprehensive collection of client libraries and inputs which make it easy to dispatch log events from any tier in your existing infrastructure. Until now though, one platform has been left out, and it’s the most ubiquitous and widely-understood of all- the browser. Collecting events from the browser presents a number of challenges which have hindered the development of a viable solution:
- There’s no standard means of transmitting log data from the front-end; it’s not like you can pipe it straight to rsyslog
- You’re constrained by the same-origin policy
- Developing a cross-browser solution means dealing with cross-browser idiosyncrasies
- You don’t know in advance where clients will come from, and you don’t have any control over their network topology- so how do you identify individual users?
After you’ve included the library in your page, setup is a one-liner:
<html lang="en"> <head> <script src="/js/le.js"></script> <script> LE.init('YOUR-TOKEN'); // Token for your log </script> </head> ...
Once configured, logging events is even easier:
…which will shortly show up in the Logentries dashboard as an entry similar to this:
11:37:30.882 184.108.40.206 l7pq1r9x LOG Hello, logger!
The logger behaves in a similar manner to the DOM’s console.log, including the ability to log simple types, nested objects and severity levels. So if you know your way around that then you’re pretty familiar with the API already. For more information, check out the documentation.
We’re heavily monitoring and updating this service during its public beta and if you have any questions, comments or suggestions, we’d love to hear them.
You can find the client and all documentation at the GitHub repository.