ElasticSearchTarget Class

ElasticSearch Target for LogHelper

Definition

Namespace: eBizprise.Framework.Log.ElasticSearch
Assembly: eBizprise.Framework.Log.LogHelper.ElasticSearch (in eBizprise.Framework.Log.LogHelper.ElasticSearch.dll) Version: 26.0.0.0+8b857ad8115790502a00f482082d0feffe7e9c92
C#
public class ElasticSearchTarget : AsyncTaskTarget
Inheritance
Object    Target    TargetWithLayout    TargetWithContext    AsyncTaskTarget    ElasticSearchTarget

Remarks

透過 HTTP REST API 將日誌寫入 ElasticSearch

Constructors

ElasticSearchTargetInitializes a new instance of the ElasticSearchTarget class

Properties

ApiKey API Key (用於 ApiKey Authentication)
ApiKeyId API Key ID (用於 ApiKey Authentication)
BatchSize Gets or sets the number of log events that should be processed in a batch by the lazy writer thread.
(Inherited from AsyncTaskTarget)
ConnectionTimeout 連線逾時時間(秒)
ContextProperties Gets the array of custom attributes to be passed into the logevent context
(Inherited from TargetWithContext)
DisableCertificateValidation 是否停用 SSL 憑證驗證
DisablePing 是否停用連線前的 Ping 檢查
ExcludeProperties List of property names to exclude when IncludeEventProperties is
(Inherited from TargetWithContext)
ForceLockingQueue Gets or sets whether to use the locking queue, instead of a lock-free concurrent queue The locking queue is less concurrent when many logger threads, but reduces memory allocation
(Inherited from AsyncTaskTarget)
IncludeAllProperties 是否包含所有屬性
IncludeCallSite Gets or sets a value indicating whether to include call site (class and method name) in the LogEventInfo
(Inherited from TargetWithContext)
IncludeCallSiteStackTrace Gets or sets a value indicating whether to include source info (file name and line number) in the LogEventInfo
(Inherited from TargetWithContext)
IncludeEventProperties Gets or sets the option to include all properties from the log events
(Inherited from TargetWithContext)
IncludeGdc Gets or sets a value indicating whether to include contents of the GlobalDiagnosticsContext dictionary
(Inherited from TargetWithContext)
IncludeScopeNested Gets or sets whether to include the contents of the ScopeContext nested-state-stack.
(Inherited from TargetWithContext)
IncludeScopeProperties Gets or sets whether to include the contents of the ScopeContext properties-dictionary.
(Inherited from TargetWithContext)
Index 索引名稱 (支援 NLog Layout 變數)
IsInitialized Gets a value indicating whether the target has been initialized.
(Inherited from Target)
Layout
(Inherited from TargetWithContext)
LoggingConfiguration Gets the logging configuration this target is part of.
(Inherited from Target)
Name Gets or sets the name of the target.
(Inherited from Target)
OverflowAction Gets or sets the action to be taken when the lazy writer thread request queue count exceeds the set limit.
(Inherited from AsyncTaskTarget)
Password 密碼 (用於 Basic Authentication)
QueueLimit Gets or sets the limit on the number of requests in the lazy writer thread request queue.
(Inherited from AsyncTaskTarget)
RetryCount How many attempts to retry the same Task, before it is aborted
(Inherited from AsyncTaskTarget)
RetryDelayMilliseconds How many milliseconds to wait before next retry (will double with each retry)
(Inherited from AsyncTaskTarget)
SyncRoot Gets the object which can be used to synchronize asynchronous operations that must rely on the .
(Inherited from Target)
TaskDelayMilliseconds How many milliseconds to delay the actual write operation to optimize for batching
(Inherited from AsyncTaskTarget)
TaskScheduler Task Scheduler used for processing async Tasks
(Inherited from AsyncTaskTarget)
TaskTimeoutSeconds How many seconds a Task is allowed to run before it is cancelled.
(Inherited from AsyncTaskTarget)
Uri ElasticSearch 伺服器 URI
Username 使用者名稱 (用於 Basic Authentication)

Methods

CaptureContextGdc Takes snapshot of GlobalDiagnosticsContext for the LogEventInfo
(Inherited from TargetWithContext)
CaptureScopeContextNested Takes snapshot of nested states from ScopeContext for the LogEventInfo
(Inherited from TargetWithContext)
CaptureScopeContextProperties Takes snapshot of ScopeContext dictionary for the LogEventInfo
(Inherited from TargetWithContext)
CloseTarget Closes Target by updating CancellationToken
(Inherited from AsyncTaskTarget)
Dispose Closes the target.
(Inherited from Target)
Dispose(Boolean) 清理資源
(Overrides AsyncTaskTarget.Dispose(Boolean))
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Flush Flush any pending log messages (in case of asynchronous targets).
(Inherited from Target)
FlushAsync Schedules notification of when all messages has been written
(Inherited from AsyncTaskTarget)
GenerateUniqueItemName Generates a new unique name, when duplicate names are detected
(Inherited from TargetWithContext)
GetAllProperties(LogEventInfo) Creates combined dictionary of all configured properties for logEvent
(Inherited from TargetWithContext)
GetAllProperties(LogEventInfo, IDictionaryString, Object) Creates combined dictionary of all configured properties for logEvent
(Inherited from TargetWithContext)
GetContextProperties(LogEventInfo) Checks if any context properties, and if any returns them as a single dictionary
(Inherited from TargetWithContext)
GetContextProperties(LogEventInfo, IDictionaryString, Object) Checks if any context properties, and if any returns them as a single dictionary
(Inherited from TargetWithContext)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetScopeContextNested Returns the captured snapshot of nested states from ScopeContext for the LogEventInfo
(Inherited from TargetWithContext)
GetScopeContextProperties Returns the captured snapshot of ScopeContext dictionary for the LogEventInfo
(Inherited from TargetWithContext)
GetTypeGets the Type of the current instance.
(Inherited from Object)
InitializeTarget 初始化 Target
(Overrides AsyncTaskTarget.InitializeTarget)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
PrecalculateVolatileLayouts Calls the Precalculate(LogEventInfo) on each volatile layout used by this target. This method won't prerender if all layouts in this target are thread-agnostic.
(Inherited from Target)
RenderLogEvent(Layout, LogEventInfo) Renders the logevent into a string-result using the provided layout
(Inherited from Target)
RenderLogEvent``1(LayoutUMP, LogEventInfo, UMP) Renders the logevent into a result-value by using the provided layout
(Inherited from Target)
ResolveService``1 Resolve from DI ServiceRepository
(Inherited from Target)
RetryFailedAsyncTask Handle cleanup after failed write operation
(Inherited from AsyncTaskTarget)
SerializeItemValue Take snapshot of a single object value
(Inherited from TargetWithContext)
SerializeScopeContextNestedState Take snapshot of a single object value from ScopeContext nested states
(Inherited from TargetWithContext)
SerializeScopeContextProperty Take snapshot of a single object value from ScopeContext dictionary
(Inherited from TargetWithContext)
ShouldIncludeProperties Check if logevent has properties (or context properties)
(Inherited from TargetWithContext)
ToString
(Inherited from Target)
Write(AsyncLogEventInfo)
(Inherited from AsyncTaskTarget)
Write(IListAsyncLogEventInfo) Block for override. Instead override WriteAsyncTask(IListLogEventInfo, CancellationToken)
(Inherited from AsyncTaskTarget)
Write(LogEventInfo) Block for override. Instead override WriteAsyncTask(LogEventInfo, CancellationToken)
(Inherited from AsyncTaskTarget)
WriteAsyncLogEvent Writes the log to the target.
(Inherited from Target)
WriteAsyncLogEvents(AsyncLogEventInfo) Writes the array of log events.
(Inherited from Target)
WriteAsyncLogEvents(IListAsyncLogEventInfo) Writes the array of log events.
(Inherited from Target)
WriteAsyncTask(IListLogEventInfo, CancellationToken) Override this to provide async task for writing a batch of logevents.
(Inherited from AsyncTaskTarget)
WriteAsyncTask(LogEventInfo, CancellationToken) 寫入單一日誌事件
(Overrides AsyncTaskTarget.WriteAsyncTask(LogEventInfo, CancellationToken))
WriteAsyncThreadSafe(AsyncLogEventInfo) Write to queue without locking SyncRoot
(Inherited from AsyncTaskTarget)
WriteAsyncThreadSafe(IListAsyncLogEventInfo) Block for override. Instead override WriteAsyncTask(IListLogEventInfo, CancellationToken)
(Inherited from AsyncTaskTarget)
WriteFailedNotInitialized LogEvent is written to target, but target failed to successfully initialize Enqueue logevent for later processing when target failed to initialize because of unresolved service dependency.
(Inherited from AsyncTaskTarget)

Extension Methods

CloneT 跨型別複製物件
(Defined by CoreExtension)
ToBsonString 轉換Bson字串
(Defined by SerializeExtend)
ToBsonString 轉換Bson字串
(Defined by SerializeExtend)
ToJsonString 轉換Json字串
(Defined by SerializeExtend)
ToJsonString 轉換Json字串
(Defined by SerializeExtend)
ToXmlString 轉換Xml字串
(Defined by SerializeExtend)
WriteJsonFile 寫入Json格式檔案
(Defined by SerializeExtend)

Revision History

DateVersionDescription
2025/12/0925.0.0.0新增 ElasticSearch 支援
2025/12/1025.0.1.0新增 RequireAuth、DisableCertificateValidation、DisablePing 設定
2025/12/1625.0.2.0新增獨佔模式設定,移除 RequireAuth 設定

See Also