Last updated at Thu, 26 Oct 2017 15:35:23 GMT
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?
That all changes today, though, as we’re proud to announce the beta release of our JavaScript client library which you can start using right away. Designed with simplicity as the overarching goal, you can be up & running in minutes, logging data using a compact and easy to use API that works in all modern browsers (desktop and mobile).
Show Me How to Log From JavaScript
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:
LE.log("Hello, logger!");
…which will shortly show up in the Logentries dashboard as an entry similar to this:
11:37:30.882 84.29.115.179 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.
Get Started with JavaScript Logging
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.