gpt4 book ai didi

elasticsearch - serilog-sinks-elasticsearch 示例抛出 NullReferenceException

转载 作者:行者123 更新时间:2023-12-02 22:13:08 24 4
gpt4 key购买 nike

当我运行示例 program.cs ( https://github.com/serilog/serilog-sinks-elasticsearch/blob/dev/sample/Serilog.Sinks.Elasticsearch.Sample/Program.cs )

我收到这个错误。
请指教 :-)

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at System.Net.Http.WinHttpRequestCallback.RequestCallback(IntPtr handle, WinHttpRequestState state, UInt32 internetStatus, IntPtr statusInformation, UInt32 statusInformationLength)
at System.Net.Http.WinHttpRequestCallback.WinHttpCallback(IntPtr handle, IntPtr context, UInt32 internetStatus, IntPtr statusInformation, UInt32 statusInformationLength)
at Interop.WinHttp.WinHttpCloseHandle(IntPtr handle)
at Interop.WinHttp.SafeWinHttpHandle.ReleaseHandle()
at System.Runtime.InteropServices.SafeHandle.InternalDispose()
at System.Net.Http.WinHttpRequestState.ClearSendRequestState()
at System.Net.Http.WinHttpHandler.<StartRequest>d__105.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
2019-10-03T10:38:57.2468492Z Failed to create the template. Elasticsearch.Net.ElasticsearchClientException: An error occurred while sending the request.. Call: Status code unknown from: HEAD /_template/serilog-events-template ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.WinHttpException: The parameter is incorrect
at System.Net.Http.WinHttpException.ThrowExceptionUsingLastError()
at System.Net.Http.WinHttpHandler.InternalSendRequestAsync(WinHttpRequestState state)
at System.Net.Http.WinHttpHandler.<StartRequest>d__105.MoveNext()
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at System.Net.Http.HttpClient.<FinishSendAsyncUnbuffered>d__59.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Elasticsearch.Net.HttpConnection.Request[TResponse](RequestData requestData)
--- End of inner exception stack trace ---
at Elasticsearch.Net.Transport`1.HandleElasticsearchClientException(RequestData data, Exception clientException, IElasticsearchResponse response)
at Elasticsearch.Net.Transport`1.FinalizeResponse[TResponse](RequestData requestData, IRequestPipeline pipeline, List`1 seenExceptions, TResponse response)
at Elasticsearch.Net.Transport`1.Request[TResponse](HttpMethod method, String path, PostData data, IRequestParameters requestParameters)
at Elasticsearch.Net.Specification.IndicesApi.LowLevelIndicesNamespace.TemplateExistsForAll[TResponse](String name, IndexTemplateExistsRequestParameters requestParameters)
at Serilog.Sinks.Elasticsearch.ElasticsearchSinkState.RegisterTemplateIfNeeded() in C:\Users\john\Source\Repos\serilog-sinks-elasticsearch\src\Serilog.Sinks.Elasticsearch\Sinks\ElasticSearch\ElasticsearchSinkState.cs:line 161
[12:38:57 INF] Hello, world!
[12:38:57 DBG] Dividing 10 by 0
[12:38:57 ERR] Something went wrong
System.DivideByZeroException: Attempted to divide by zero.
at Serilog.Sinks.Elasticsearch.Sample.Program.Main(String[] args) in C:\Users\john\Source\Repos\serilog-sinks-elasticsearch\sample\Serilog.Sinks.Elasticsearch.Sample\Program.cs:line 60
[12:38:57 DBG] Reusing string by True
Press any key to continue . . .

最佳答案

错误原来是没有设置AutoRegisterTemplateVersion

AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv6,

关于elasticsearch - serilog-sinks-elasticsearch 示例抛出 NullReferenceException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58231332/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com