A suggestion howto handle old Log Files

Today somebody complained about to much history files. The standard configuration of NLog is to create every day new files.

by myself i handle this over a batch job and the forfiles.exe which is available at the .Net SDK.

the batch job contains only the following line:

forfiles /p C:\temp\logs\ /d -31 /c "CMD /C del @FILE" /M *.txt

this deletes any *.txt from the directory which is older as 31 day's.

the forfiles you also can download directly from here forfiles.zip
just copy it into your "C:\WINDOWS\system32\" folder and unzip it.

A suggestion howto handle development log files

one of the versions we change default log files into the following structure:

C:\temp\logs\client\
C:\temp\logs\notify\
C:\temp\logs\server\


upon development we delete often the files so here you have another suggestion on how you can handle that in a easy way:

@ECHO Clean Logs
forfiles /p C:\temp\logs\client\ /c "CMD /C del @FILE" /M *.txt
forfiles /p C:\temp\logs\notify\ /c "CMD /C del @FILE" /M *.txt
forfiles /p C:\temp\logs\server\ /c "CMD /C del @FILE" /M *.txt

copy this into your root folder: C:\temp\logs as an .cmd or .bat file (e.g. cleanlogs.bat) and everytime you like to delete all files just execute it instead of browsing.


Last edited Jan 3, 2008 at 9:39 PM by ronischuetz, version 5

Comments

No comments yet.