Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable logging of Angular routing events

Is there a way to disable logging of events from platform-browser.es5.js in Angular 2/4? I want to be able to quickly read through my own logs and the Angular logs are drowning mine out.

Angular router logging

like image 289
Joel Murphy Avatar asked Aug 14 '17 14:08

Joel Murphy


People also ask

What is LoadChildren in Angular routing?

Use LoadChildren:For lazy loading. Using this property will optimize your application's performance by only loading the nested route subtree when a user navigates to a particular URL that matches the current route path. It helps in keeping the nested routes table separate.

What is enableTracing in Angular?

forRoot( routes, { enableTracing: true } // <-- debugging purposes only ) ] Angular will then log all events to the browser's console, per the documentation: enableTracing?: boolean. When true, log all internal navigation events to the console. Use for debugging.

What is NavigationEnd in Angular?

NavigationEndlinkAn event triggered when a navigation ends successfully. class NavigationEnd extends RouterEvent { constructor(id: number, url: string, urlAfterRedirects: string) type: EventType.

How would you get the router to log all its internal events to the console in your Angular 6 application?

unable to navigate or navigation/router is not working, then we can debug it by enabling the enableTracing option in ExtraOptions of RouterModule. By setting this option, we can log all internal navigation events to the console.


1 Answers

By default, the routing events are not logged. So as Maximus suggested, you must have added code somewhere to turn them on. You just need to remove that code.

In my app, I turned on routing events here, in the app routing module:

    RouterModule.forRoot([         { path: 'welcome', component: WelcomeComponent },         { path: '', redirectTo: 'welcome', pathMatch: 'full' },         { path: '**', component: PageNotFoundComponent }     ], { enableTracing: true }) 

If you have code like this, either remove the enableTracing or set it to false.

like image 101
DeborahK Avatar answered Oct 11 '22 14:10

DeborahK