I'm writing an application that needs to log error/ exception messages but should still continue execution if it not a fatal error

softwareengineering.stackexchange https://softwareengineering.stackexchange.com/questions/395809

Question

I'm writing an application that needs to log error/ exception messages but should still continue execution if the error is not a fatal error. I was thinking of making a method that returns a Task but calling this method as a fire and forget and not wait for response from the method. What is the recommendation, is this a good approach?

Was it helpful?

Solution

Fire and forget is what we actually did. The less code you have in the application that is initiating the log message the less code that you have to debug there.

All you actually need to do is write your messages to a logfile(s), and spunk can be configured to process those log(s). You may want to have a process that queues the log messages and that appends them to the file - this would be useful if there are multiple processes or even multiple threads sharing the same log file, but also having n log files is also an option.

Having done this for splunk in C and C++ it is very straight forward.

Licensed under: CC-BY-SA with attribution
scroll top