What is the best exception handling strategy for error logging classes?

I am writing a set of error logs that will be recorded in a file, event log, etc. What exception handling should be performed in these classes? For example, let's say I have a LogError method that is called from exception handlers and written to a file. What is considered best if an error occurs? Obviously, I have to make these methods as safe as possible, but problems can always arise.

+1
source share
4 answers

In general, I output to stderr as much information as possible in this case, often both an error / exception in the logging code and the original log / error / exception. Thus, there is a chance to reproduce the problem or understand it.

If the entry in stderr failed, then the time to refuse is to either ignore it to completely close the application.

+1
source

Why don't you use an existing logging engine such as log4j / log4net / log4php / log4 *? These tools are probably sorted by these parameters.

, (: tomcat), , . , syserr.

+1

, , , , , - , , , , .

0

. -. - , , , . -. ( - , ) . - SLA, .

Then the audit service can be implemented as a state machine, which can consume and record messages based on the criteria defined in its configuration. A common exception handler can also use the audit service to support a centralized presentation of issues that arise in a corporate SOA, to support exception-based monitoring. Any prerequisite in the solution must be sent an exception message to the exception handler

0
source

Source: https://habr.com/ru/post/1705740/


All Articles