C # Creating a Log System

I read the following article: http://odetocode.com/articles/294.aspx

In this article, I have raised many questions regarding magazines. (I don't know if I should do this in split questions ... but I don't want to spam stackoverflow.com with my questions)

First, if I have to store it in a .txt or .xml file ... or even in a table inside the database. Saving to .txt will probably be better in terms of performance. But when someone needs to find a .txt file, it can become a pain in the ... neck. So ... what should I use and why?

Secondly, is there any specific class for working with the "journal"? I read several topics on this subject, and I did not find the answers to my questions.

Thanks in advance.

+3
source share
8 answers

The simplest approach I've used in the past is to use log4net. This way you can configure logging in the configuration file. If you need it to go to the database, configure it as such. If you want to be notified when a serious error occurs, configure it this way.

As for sorting the logs, it depends on the approach you want to take and on how much you plan to keep the log. I usually write to a text file, since I do not allow a lot to register in my applications. So parsing through them doesn't really matter.

+18
source

, , log4net nlog.

, , , , , .

, , .

+6

? MS.

+4

xml.

xml, , , , xml . , - .

, , XML , xml.

- , , - , txt . .

( ).

-, , , , , - db.

+2

, .

, .

, (, , , ), .

, .., .

.net , , .

0

db. ( ) . , , , , , .

log4net . , db . , 200 . , , .

0

ASP.NET, ELMAH - . , Microsoft Scott Hanselman .

, ASP.NET MVC HandleError.

0

NLog log4net API , , .

, GIBRLATAR - NLog log4net, . , GIBRALTAR .

-2

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


All Articles