Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate or export the logs from the logger? #154

Closed
rpmansion opened this issue Oct 12, 2017 · 5 comments
Closed

How to generate or export the logs from the logger? #154

rpmansion opened this issue Oct 12, 2017 · 5 comments

Comments

@rpmansion
Copy link

rpmansion commented Oct 12, 2017

You've the logger in the app, how do you extract the information from it?

@sinedied
Copy link
Member

By default the logger outputs in the console (hit F12), filtering debug and info logs when the app is build for production.

To add more outputs (for example to an online logger service), you just need to register a custom output function:

// Logger output
function myCustomLoggerOutput(source: string, level: LogLevel, ...objects: any[]) {
  // do something with the log, like pushing it to an online service
}

// Register new logger ouput
Logger.outputs.push(myCustomLoggerOutput);

@rpmansion
Copy link
Author

@sinedied I see, but when you generate this with a log.txt? I'm thinking to use this logger then create an interface where a user can extract the logs on their end based on a date to a .txt file.

@rpmansion
Copy link
Author

@sinedied my bad. I realized it is not possible to generate a log to a client-side js. I would need to send this to a server to write the logs. thank you.

@rpmansion
Copy link
Author

@sinedied quick question I'm trying to implement JSNLog by adding this as a new logger output. given to your example code, where do I place the code?

@sinedied
Copy link
Member

You can place it along your app bootstrap code in a dedicated bootstrap service if you have one, otherwise you can simply put it in your root app.component.ts ngOnInit method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
ngX-Rocket backlog for all repos
  
Released/Processed
Development

No branches or pull requests

2 participants