Answer the question
In order to leave comments, you need to log in
How to properly get logs from an external DLL?
There is a project in which plug-ins are implemented, the question is, what is the best way to get logs from the DLL in order to know about errors that may occur during the execution of the plug-in? What is the best way to implement a logging system in a program? The first thought was to create a dynamic array, declare it in Program.cs so that all assembly types have access to it and add lines to it, and pass a link to this array to the plugin so that logs are also written there. But is this the right approach? Please, share your experience.
Answer the question
In order to leave comments, you need to log in
In the plugin class, you create an event to which you will send logs, and the main program subscribes to this event for all plugins.
more correctly, as you like , where do you write the logs?:
- text files?
- Windows event logs?
- .. or is it a server application, is there a system for collecting logs? .. (although then it would hardly be such a question) the
simplest option is a text file, usually. then it is enough to agree on the format of the logs (message structure) and specify the folder where
plugins can store their own logs - there is nothing wrong with that. it is immediately clear who fell. and it's simple (and simplicity is generally an important quality in programming),
but as soon as you create a special tool for logs, do not forget that the tool itself can fall. then you won't get
luck logs at all
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question