locked
TextWriterTraceListener is creating temp files and not deleting them RRS feed

  • Question

  • User265138564 posted

    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:

    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?

    Help will be appreciate!

    Thursday, May 21, 2015 1:06 PM

All replies

  • User-84896714 posted

    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

    Friday, May 22, 2015 4:52 AM
  • User265138564 posted

    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.

    Friday, May 22, 2015 6:28 PM
  • User-84896714 posted

    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

    Sunday, May 24, 2015 9:30 PM