I enter the file using FileStream.Write (). When the file reaches its maximum size, I want to remove the log load from the beginning of the file. What is the best way to do this?
The best idea I got so far is to create a second file. Write everything that I want to keep from the source file. Then delete the source file and rename the second file with the name of the source files.
Is there an easier and more efficient way I can do this?
Yes and no; -)
What is important for you: efficiency or simplicity?
. - . /, , == max . , , ... DB " ", . . Yeck!
( , ): , . "" ... , , numLogs == maxLogs .
. .
log4net - .
http://logging.apache.org/log4net/index.html
, , , , .
. "" , . :
, , . , ( - ).
, . : - , , .
, .
, , . , , - .
, - . , log4net , , .
, , ? max , . .
Of course, it would be even easier if you did not write files at all until the program ends, and at that moment you will write all the cached lines. Although this may not be possible if your program has been running for a long time, and you want to see the log during startup with a tail or something similar.
Source: https://habr.com/ru/post/1708551/More articles:How can I capture a click on a browser page without any effect on the reliability of the site? - javascriptMock svn instance for testing svnkit tests - javaWCF issues with using net.pipe binding remotely - .netПеренос на mpc-контроль asp.net, реализующий IDataSource - asp.net-mvcFree Functions in C # - c #html (val), text (val), add (content) and others - jqueryto use Img source with php variable? - variablestry ... except ... except ...: how to avoid code repeating - pythonDrupal homepage with views - viewsКак перетащить из Explorer в Visual Studio без отключения UAC? - windowsAll Articles