Logging code make my code a bit ugly
Hi friends,
Hope you're doing well,
I'm working on complex project, I use
CQRS
with MediatR
, in the Application
layer, also I'm using Serilog
( Console, and File) for logging, and here the issue, the lines of code I wrote to achieve a logging it makes my code a bit a ugly ( in my opinion), because in the Commands
and Queries
I wrote a logging at the beginning and a logging at the end .
The following is a Handle
method of a Command
:
Please I want you to share with me your experience about this,
<310 Replies
Do you need to log all of that?
I don't know if logging statements inside of a handler is good idea in general, usually I've seen them wrapped around the sender in a custom dispatcher.
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View
lets say yes
Then I'd at least relegate the exception handling to exception handling middleware
Or MediatR pipeline
hmmmm, seems good idea, but what about other logging lines ???
same thing, they can also be added inside a PipelineBehavior
great
Like here : https://github.com/MbarkT3STO/ExpenovaApp/blob/main/Source/ExpenseService/ExpenseService.Application/Category/Commands/CreateCategoryCommand.cs
?????
GitHub
ExpenovaApp/Source/ExpenseService/ExpenseService.Application/Catego...
Contribute to MbarkT3STO/ExpenovaApp development by creating an account on GitHub.
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View