Client-side (browser) logger to use with Loggly gen2.
Place the following on your page, and replace the logglyKey value with the key provided by the website:
<script type="text/javascript" src="/js/loggly.tracker.js" async></script>
<script>
var _LTracker = _LTracker || [];
_LTracker.push({
'logglyKey': '8c518f97-e3e0-4bfb-a8ed-582d084a5289',
'sendConsoleErrors' : true,
'tag' : 'jslogger'
});
</script>
Logging text:
_LTracker.push('my tracking string');
Logging JSON:
_LTracker.push({
'text': 'my tracking string',
'aList': [9, 2, 5],
'anObject': {
'id': 1,
'value': 'foobar'
}
});
separate logging instace:
var myBetterLogger = new LogglyTracker();
myBetterLogger.push({'logglyKey': '8c518f97-e3e0-4bfb-a8ed-582d084a5289' }); // push a loggly key to initialize
Keeping sendConsoleErrors value to true will send all the unhandled errors to the Loggly with the detailed information like error message, URL, line number and column number. This script also take cares of all the previously defined window.onerror functions.