Sudarshani Perera
Sudarshani Perera

Reputation: 248

how can I get a log file in angular using ngx-logger?

How to set logs to file in angular rather that printing logs in console. I’m using ngx-logger. Do you have any suggestions?

Upvotes: 1

Views: 11761

Answers (2)

VeteranLK
VeteranLK

Reputation: 746

According to https://github.com/A1rPun/ngx-logger there's a function to post the log to the server end. if there's no function, modify the library and add one.

//Post to an endpoint somewhere on the internets
logToEndpoint(logMessage: any): void {
  this.http.post(url, logMessage);
}

Example payload

{
  'level': 'info',
  'message': 'Hello log!',
  'app': 'MyApp',
  'timestamp': '1337133371337'
}

Upvotes: 3

Sajeetharan
Sajeetharan

Reputation: 222722

It's not possible to write to a file from angular, since it is purely on client side.

The possible solution would be to send to the server and write to a file or use any of the cloud provider such as azure/aws existing feature appInsights/cloudwatch to log the errors.

Upvotes: 3

Related Questions