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

Is there a way to send the log messages to server(api)? #137

Open
sundeepyama opened this issue Feb 14, 2017 · 4 comments
Open

Is there a way to send the log messages to server(api)? #137

sundeepyama opened this issue Feb 14, 2017 · 4 comments

Comments

@sundeepyama
Copy link

If yes, can you point me to an example?

@ashwin-sureshkumar
Copy link

If this is a needed feature, I can send a PR for remote logging @langley-agm

@langley-agm
Copy link
Contributor

Hi Guys,

Thanks for the interest.
This can't be done native atm.
It is planned with the Appenders functionality down the road.
Basically you configure an appender to an specific logger, this appender can be a console appender, or something else, in this case I was planning an http appender of some sort that instead of sending the messages to the console would send them to an specific configured url.

I accept PRs if its tied to this road, but consider that right now no decision has been made whether we'll keep creating Loggers by injecting them or through something like this:

LoggerFactory.getLogger()

And this is a big part of how to configure them and add appenders to them.

A work around would be to create a wrapper of the Logger and inject that instead.
This wrapper would extend the Logger, call the parent's methods and then post the specific message.

@ericis
Copy link

ericis commented Mar 8, 2017

+1 for "create a wrapper of the Logger and inject that instead". This also protects you mostly from future API changes.

@wingsuitist
Copy link

wingsuitist commented Apr 19, 2017

I like it how ng2-translate solves this:

@NgModule({
    imports: [
        BrowserModule,
        HttpModule,
        TranslateModule.forRoot({
            provide: TranslateLoader,
            useFactory: (http: Http) => new TranslateStaticLoader(http, '/assets/i18n', '.json'),
            deps: [Http]
        })
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }

https://github.com/ngx-translate/core/blob/master/index.ts#L46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants