0

我们有https://www.nuget.org/packages/Microsoft.AspNet.WebApi.SelfHost/ Web Api 服务,它运行良好。然后我们迁移到https://www.nuget.org/packages/Microsoft.AspNet.WebApi.OwinSelfHost/出现问题。我们将服务部署到服务器,40-60 分钟后我们得到错误并且服务没有响应并且我们无法停止它。然后我们终止进程并启动服务,它在接下来的 40-60 分钟内运行良好。据我了解,logentries appender 的线程或队列没有响应,因为我们在文件中看到日志,但在 logentries 中没有

<appender name="LeAppender" type="log4net.Appender.LogentriesAppender, LogentriesLog4net">
<Debug value="true" />
<HttpPut value="false" />
<Ssl value="false" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="|%level%| %m" />
</layout>
</appender>
<root>
<priority value="ALL" />
<appender-ref ref="ConsoleAppender" />
<appender-ref ref="LogFileAppender" />
<appender-ref ref="LeAppender" />
</root>

错误:

XXXX-XX-XX XX-XX-XX,XXX [Logentries Log Appender] FATAL Topshelf.Runtime.Windows.WindowsServiceHost The service threw an unhandled exception System.IndexOutOfRangeException: Probable I/O race condition detected while copying memory. The I/O package is not thread safe by default. In multithreaded applications, a stream must be accessed in a thread-safe way, such as a thread-safe wrapper returned by TextReader's or TextWriter's Synchronized methods. This also applies to classes like StreamWriter and StreamReader.
at System.Buffer.InternalBlockCopy(Array src, Int32 srcOffsetBytes, Array dst, Int32 dstOffsetBytes, Int32 byteCount)
at System.IO.StreamWriter.Write(Char[] buffer, Int32 index, Int32 count)
at System.IO.TextWriter.SyncTextWriter.Write(Char[] buffer, Int32 index, Int32 count)
at Microsoft.Owin.Hosting.Tracing.DualWriter.Write(Char[] buffer, Int32 index, Int32 count)
at System.IO.TextWriter.WriteLine(String value)
at System.Diagnostics.TextWriterTraceListener.WriteLine(String message)
at System.Diagnostics.TraceInternal.WriteLine(String message)
at LogentriesCore.Net.AsyncLogger.WriteDebugMessages(String message)
at LogentriesCore.Net.AsyncLogger.Run()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

当我启用调试模式时,我得到了更多信息。附加程序或我的应用程序有问题吗?我怎样才能获得更多信息?

log4net:ERROR [LogentriesAppender] ErrorCode: GenericFailure. Failed in DoAppend
LE: Write complete, flush
LE: Flush complete
LE: Await queue data
System.IndexOutOfRangeException: Probable I/O race condition detected while copying memory. The I/O package is not thread safe by default. In multithreaded applications, a stream must be accessed in a thread-safe way, such as a thread-safe wrapper returned by TextReader's or TextWriter's Synchronized methods. This also applies to classes like StreamWriter and StreamReader.
   at System.Buffer.InternalBlockCopy(Array src, Int32 srcOffsetBytes, Array dst, Int32 dstOffsetBytes, Int32 byteCount)
   at System.IO.StreamWriter.Write(Char[] buffer, Int32 index, Int32 count)
   at System.IO.TextWriter.SyncTextWriter.Write(Char[] buffer, Int32 index, Int32 count)
   at Microsoft.Owin.Hosting.Tracing.DualWriter.Write(Char[] buffer, Int32 index, Int32 count)
   at System.IO.TextWriter.WriteLine(String value)
   at System.Diagnostics.TextWriterTraceListener.WriteLine(String message)
   at System.Diagnostics.TraceInternal.WriteLine(String message)
   at LogentriesCore.Net.AsyncLogger.WriteDebugMessages(String message)
   at LogentriesCore.Net.AsyncLogger.AddLine(String line)
   at log4net.Appender.LogentriesAppender.Append(LoggingEvent loggingEvent)
   at log4net.Appender.AppenderSkeleton.DoAppend(LoggingEvent loggingEvent)
4

2 回答 2

0

内部调试问题https://github.com/rapid7/le_dotnet/blob/1b2443a581a6f1a877bf90f472a44eaf5ffe0fa5/src/LogentriesCore/AsyncLogger.cs#L596

当我们将调试更改为错误的附加程序时。

奥列格

于 2016-09-26T11:46:10.277 回答
0

您发布的堆栈跟踪显示错误发生在AsyncLogger.WriteDebugMessages()-显示此方法用于记录内部调试消息,因此<Debug value="false" />在配置中设置应该阻止这种情况发生。

您还应该通过 repro在库上提出问题,以便可以修复它。

于 2016-09-22T13:31:03.987 回答