Esri/resource-proxy

.NET Proxy file throwing error on log file

Closed this issue · 5 comments

Any ideas how to prevent this? .NET v4

[IOException: The process cannot access the file 'D:\...\proxy\proxy-logs.txt' because it is being used by another process.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +893
   System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +1217
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +144
   System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost) +123
   System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) +103
   System.IO.StreamWriter..ctor(String path, Boolean append) +55
   System.IO.File.AppendText(String path) +50
   LogTraceListener.WriteLine(String message) +445
   System.Diagnostics.TraceInternal.WriteLine(String message) +229
   proxy.log(TraceLevel logLevel, String msg) +331
   proxy.ProcessRequest(HttpContext context) +5083
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +790
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +88

@roemhildtg Do you know what "the other process" is? Do you have it open in another app? Or are there multiple proxies trying to write to same file?

Its only one proxy trying to write to this particular file. I'm assuming the "other process" is the proxy itself trying to write to the file from another request.

I don't have it open, it happens very sporadically but definitely quite often.

We have the same issue. We are using it in a web farm scenario where multiple servers potentially need to write into this file, which is stored on the network in a shared location. I don't know if the fact that it is a shared file is the only cause for our issues. Based on this issue report, it looks like it could happen on a single server with a file on a local disk.

I think it would be helpful if we could provide an alternative implementation of the TraceListener via configuration. It would not be too much work to add a configuration option for the name of a concrete class. Config could new-up an instance of that class by name rather than the default file-based LogTraceListener.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you need additional assistance please contact Esri Technical Support. Thank you for your contributions.

This issue has been automatically closed due to inactivity. If you need additional assistance please contact Esri Technical Support.