2

Is there a way for me to use : Use sumologic (https://www.sumologic.com/) in my angular2+ application ? Have googled but have not found anything that suggests I can use it?

Curious Explorer
  • 357
  • 2
  • 14

1 Answers1

1

Haven't tried yet !

But yes you can just follow these steps -

  1. run npm i sumologic --save
  2. As per documentation add this code into your constructor or ngOnInit hook of component var SumoLogger = require('sumologic')

      // Optional opts
      var opts = {
      request // wrapper around https://www.npmjs.com/package/request (useful for testing)
      endpoint // default https://collectors.au.sumologic.com/receiver/v1/http/, change again mostly to aid testing/debugging
      syncInterval // how often we should sync to sumo logic (default ever second)
      };
    
      var logger = new SumoLogger('SUMOLOGIC-HTTP-COLLECTOR-CODE' /*, opts */);
    
      // optional - if you would like console.log to go to sumo logic
      logger.replaceConsole()
    
      // optional - if you would like console.log to go to sumo logic and stdout
      logger.augmentConsole()
    
      logger.log("Yeah, it worked");
    

It should work. any problem let me know.

Pardeep Jain
  • 84,110
  • 37
  • 165
  • 215
  • @pradeep-jain : I am just starting up on angular..hence can you clarify which part of documentation you are referring and how to as you say 'hook'. It seems this is all nodejs code. – Curious Explorer May 17 '18 at 11:31
  • I am referring to https://www.npmjs.com/package/sumologic this documentation, for `hook` refer here https://angular.io/guide/lifecycle-hooks – Pardeep Jain May 17 '18 at 11:37