question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue in using ngx-logger in an angular library (buildable)

See original GitHub issue

Hi guys, I am trying to use ngx-logger in my buildable library but I got the error below core.mjs:6500 ERROR NullInjectorError: R3InjectorError(AppModule)[TestService -> TestService -> TestService -> NGXLogger]: NullInjectorError: No provider for NGXLogger!

app/module

@NgModule({
....
  imports: [
    BrowserModule,
    HttpClientModule,
    LoggerModule.forRoot({
      level: NgxLoggerLevel.DEBUG,
      timestampFormat: 'HH:mm:ss.SSS',
      serverLogLevel: NgxLoggerLevel.ERROR,
      disableConsoleLogging: false
    })]
})
export class AppModule { }

library module

@NgModule({
  imports: [CommonModule, LoggerModule.forChild()]
})
export class ReusableModule {}

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
hmendezmcommented, Mar 4, 2022

Ok. I will create a simple app and reproduce the problem

0reactions
hmendezmcommented, Mar 4, 2022

I could not reproduce in a new project. it looks like is a real project that has config problems and I do not know where. this is the full error that I get

By the way, I am working on MFE and the services are a shared library. I use providedIn: 'platform', so I have one instance of the service when there is more than one app loaded.

bootstrap.ts:13 NullInjectorError: R3InjectorError(AppModule)[EffectsRootModule -> InjectionToken @ngrx/effects Root Effects -> AuthenticationEffects -> AuthenticationService -> StateService -> FormService -> FormService -> FormService -> LoggerService -> NGXLogger]: 
  NullInjectorError: No provider for NGXLogger!
    at NullInjector.get (core.mjs:11135:27)
    at R3Injector.get (core.mjs:11302:33)
    at injectInjectorOnly (core.mjs:4786:33)
    at Module.ɵɵinject (core.mjs:4790:12)
    at Object.LoggerService_Factory [as factory] (logger.service.ts:8:27)
    at R3Injector.hydrate (core.mjs:11472:35)
    at R3Injector.get (core.mjs:11291:33)
    at injectInjectorOnly (core.mjs:4786:33)
    at Module.ɵɵinject (core.mjs:4790:12)
    at Object.FormService_Factory [as factory] (form.service.ts:94:25)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Build error with ngx-logger for Angular 11 project · Issue #216
I am getting below error in build as soon as I import the nx-logger Error: node_modules/ngx-logger/lib/logger.module.d.ts:3:22 - error ...
Read more >
ngx-logger - npm
NGX Logger is a simple logging module for angular (currently supports angular 6+). It allows "pretty print" to the console, as well as...
Read more >
ngx-logger-factory - npm Package Health Analysis - Snyk
It may not be fully compatible with current versions of Angular. Ngx-logger. Build Status. This is a simple library to log in Angular....
Read more >
interact-logger - NPM Package Overview - Socket - Socket.dev
Interact logger library created using ngx-logger. It uses most of features of ngx-logger and customizes some of feature based on requirement. Build. Run...
Read more >
Angular Logging Made Simple with ngx-logger - onthecode
As a developer, you are responsible for every line of code you write. If a bug surfaces in the application, you need to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found