I Implemented my own version of a TextWriter to trance events in my site. I'm using MVC 4 WebApi.
I have run code many times in my home PC and other servers and runs great, but in the office I have the problem that it leaves tons of temp files and doesn't clean them up. I believe that it might be the issue with anti-virus or something else locking the
files before IIS delete them.
The code is properly appending to the right file 2015.05.21.adSearch-web-api.log but other files are left behind.
here is the code:
Using tracer = New TextWriterTraceListener(logfile)
For Each logger In events
Dim logType = TraceEventType.Information
If logger.action = cc.logAction.error Then logType = TraceEventType.Error
tracer.TraceEvent(New TraceEventCache, appSession.application, logType, threadId, logger.dateCreated.ToString("yyyy.MM.dd-HH.mm.ss.fff.tt.") + "#" + logger.level.ToString + "#." + logger.source + "." + logger.action + IIf(logger.additional IsNot Nothing, ": " + logger.additional, ""))
Next
tracer.Flush()
End Using
again, this only happens in the office, in my desktop and on the servers. Has anyone experienced this before? anti-virus? permissions? iis setting?
Hi jimmydagher,
Thank you for your post.
These files may be cached files or back up files, you could delete these files in safe mode
For more information, you could create a new thread on windows server forums, you could get more help from there.
Link below is for your reference. https://social.technet.microsoft.com/Forums/en-US/home?forum=winservergen
Hoping my reply could be helpful to you.
Best Regards,
Wang Li
My concern was more as to why it is happening than if I could delete them. Problem is that the directory that the files are being created is the log directory and is cluttering the folder and can't find our log files with ease.
Also to delete them i would have to setup some sort of process to keep flushing them out. Do you know why they are not being auto-deleted? and this is only in my company, not on my personal PC or cloud server, so definitely something this the environment.
Hi jimmydagher,
This may be a problem of folder permissions.
Please check security property of the log folder. set full control to current user.
Best Regards,
Wang Li
None
0 Points
2 Posts
TextWriterTraceListener is creating temp files and not deleting them
May 21, 2015 01:06 PM|jimmydagher|LINK
Hi,
I Implemented my own version of a TextWriter to trance events in my site. I'm using MVC 4 WebApi.
I have run code many times in my home PC and other servers and runs great, but in the office I have the problem that it leaves tons of temp files and doesn't clean them up. I believe that it might be the issue with anti-virus or something else locking the files before IIS delete them.
so what I end up in my folder is:
0e9767dc-40e2-4d81-8d39-c70a27e4153f2015.05.21.adSearch-web-api.log 1K
3f27dd3c-2b52-47ed-8950-d69776bcb10a2015.05.21.adSearch-web-api.log 1K
4c196f6a-d3af-4dcb-942a-30677c93eb4f2015.05.21.adSearch-web-api.log 1K
2015.05.21.adSearch-web-api.log 36K
2204e227-af8e-428f-af31-5e5b0e589d4f2015.05.21.adSearch-web-api.log 1K
The code is properly appending to the right file 2015.05.21.adSearch-web-api.log but other files are left behind.
here is the code:
again, this only happens in the office, in my desktop and on the servers. Has anyone experienced this before? anti-virus? permissions? iis setting?
Help will be appreciate!
TextWriterTraceListener permissions vb.net Tempfiles
Star
9859 Points
974 Posts
Re: TextWriterTraceListener is creating temp files and not deleting them
May 22, 2015 04:52 AM|Li Wang|LINK
Hi jimmydagher,
Thank you for your post.
These files may be cached files or back up files, you could delete these files in safe mode
For more information, you could create a new thread on windows server forums, you could get more help from there.
Link below is for your reference.
https://social.technet.microsoft.com/Forums/en-US/home?forum=winservergen
Hoping my reply could be helpful to you.
Best Regards,
Wang Li
TextWriterTraceListener permissions vb.net Tempfiles
None
0 Points
2 Posts
Re: TextWriterTraceListener is creating temp files and not deleting them
May 22, 2015 06:28 PM|jimmydagher|LINK
Thanks Li for your reply!
My concern was more as to why it is happening than if I could delete them. Problem is that the directory that the files are being created is the log directory and is cluttering the folder and can't find our log files with ease.
Also to delete them i would have to setup some sort of process to keep flushing them out. Do you know why they are not being auto-deleted? and this is only in my company, not on my personal PC or cloud server, so definitely something this the environment.
TextWriterTraceListener permissions vb.net Tempfiles
Star
9859 Points
974 Posts
Re: TextWriterTraceListener is creating temp files and not deleting them
May 24, 2015 09:30 PM|Li Wang|LINK
Hi jimmydagher,
This may be a problem of folder permissions.
Please check security property of the log folder. set full control to current user.
Best Regards,
Wang Li
TextWriterTraceListener permissions vb.net Tempfiles