You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The LoggingBehaviour class and its Process method do execute when a request is made.
To Reproduce
Steps to reproduce the behavior:
Set up a new project. I used the Angular template with SQLite
Set a breakpoint on line 31 in LoggingBehaviour.cs (or anywhere in the Process method)
Do something in the app that fetches data. For example, go to the weather data page.
Observe that the breakpoint was not hit, the app does not log the user and their request
Expected behavior
The breakpoint should be hit and we should log information about the user and their request.
Additional context
Unlike the other behaviors in Application/Common/Behaviours, LoggingBehaviour implements IRequestPreProcessor. According to the Mediatr docs, "RequestPreProcessorBehavior will execute IRequestPreProcessor implementations before any handlers are called". However, the docs also say this "will be registered if in AddMediatR you register any pre/post processors". So it's not clear to me if a step is missing. I'm guessing cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()); in Application/DependencyInjection.cs is supposed to take care of this. But I'm really not sure.
EDIT: Adding cfg.AddRequestPreProcessor(typeof(IRequestPreProcessor<>), typeof(LoggingBehaviour<>)); after cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()); registers LoggingBehaviour and then the breakpoint can be hit. However I'm guessing that is not the intended way for it to work.
The text was updated successfully, but these errors were encountered:
Describe the bug
The LoggingBehaviour class and its Process method do execute when a request is made.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The breakpoint should be hit and we should log information about the user and their request.
Additional context
Unlike the other behaviors in Application/Common/Behaviours, LoggingBehaviour implements
IRequestPreProcessor
. According to the Mediatr docs, "RequestPreProcessorBehavior will execute IRequestPreProcessor implementations before any handlers are called". However, the docs also say this "will be registered if in AddMediatR you register any pre/post processors". So it's not clear to me if a step is missing. I'm guessingcfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
in Application/DependencyInjection.cs is supposed to take care of this. But I'm really not sure.EDIT: Adding
cfg.AddRequestPreProcessor(typeof(IRequestPreProcessor<>), typeof(LoggingBehaviour<>));
aftercfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
registersLoggingBehaviour
and then the breakpoint can be hit. However I'm guessing that is not the intended way for it to work.The text was updated successfully, but these errors were encountered: