Javascript/HTML5

Logentries provides direct support using our JavaScript library.

basic

Setup

Log in to InsightOps and create a new log by clicking the Add Data link in the Data Management pages.

Click the "Quick add" button. Give your log a name of your choice, select Token TCP and finally click the "Create new log" button. A log token will be displayed in green. Please record it as we will use it later to configure the library.

Install the InsightOps plug-in

Get the latest build here from our Github repository. We recommend using le.min.js in a Production environment

Insert Logging Code

Include the library in your page:

html
1
<html lang="en">
2
<head>
3
<title>Your page</title>
4
<script src="/js/le.min.js"></script>
5
<script>
6
LE.init({
7
token: 'Your log token will display here',
8
region: 'Your data center here'
9
});
10
</script>
11
</head>
12

Add the the token that you copied earlier. It connects this logger with that file on InsightOps. If you haven’t taken note of the token when creating your log, you can retrieve it by logging in to InsightOps and viewing the settings for the log. Enter the region that your InsightOps account is based in - e.g. "us" or "eu"

Now add some JavaScript that will send log data to InsightOps:

html
1
<script>
2
// log something
3
LE.log("Hello, logger!");
4
</script>

More information can be found on the JavaScript Wiki page.