ElasticSearchTarget Class

ElasticSearch Target for NLog

Definition

Namespace: eBizprise.Framework.Log.ElasticSearch
Assembly: eBizprise.Framework.Log.LogHelper.ElasticSearch (in eBizprise.Framework.Log.LogHelper.ElasticSearch.dll) Version: 25.0.0.0+adf38c4ccb2bf98d8ad258a6278302b5e05a94ed
C#
public class ElasticSearchTarget : TargetWithLayout
Inheritance
Object    Target    TargetWithLayout    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 批次大小
ConnectionTimeout 連線逾時時間(秒)
IncludeAllProperties 是否包含所有屬性
Index 索引名稱 (支援 NLog Layout 變數)
IsInitialized Gets a value indicating whether the target has been initialized.
(Inherited from Target)
Layout Gets or sets the layout used to format log messages.
(Inherited from TargetWithLayout)
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)
Password 密碼 (用於 Basic Authentication)
SyncRoot Gets the object which can be used to synchronize asynchronous operations that must rely on the .
(Inherited from Target)
Uri ElasticSearch 伺服器 URI
Username 使用者名稱 (用於 Basic Authentication)

Methods

CloseTarget Closes the target to release any initialized resources
(Inherited from Target)
Dispose Closes the target.
(Inherited from Target)
Dispose(Boolean) 清理資源
(Overrides Target.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 Flush any pending log messages
(Inherited from Target)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
InitializeTarget 初始化 Target
(Overrides Target.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)
ToString
(Inherited from Target)
Write(AsyncLogEventInfo) Writes async log event to the log target.
(Inherited from Target)
Write(IListAsyncLogEventInfo) Writes an array of logging events to the log target. By default it iterates on all events and passes them to "Write" method. Inheriting classes can use this method to optimize batch writes.
(Inherited from Target)
Write(LogEventInfo) 寫入單一日誌事件
(Overrides Target.Write(LogEventInfo))
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)
WriteAsyncThreadSafe(AsyncLogEventInfo) Writes a log event to the log target, in a thread safe manner. Any override of this method has to provide their own synchronization mechanism. !WARNING! Custom targets should only override this method if able to provide their own synchronization mechanism. Layout-objects are not guaranteed to be thread-safe, so using them without a SyncRoot-object can be dangerous.
(Inherited from Target)
WriteAsyncThreadSafe(IListAsyncLogEventInfo) Writes an array of logging events to the log target, in a thread safe manner. Any override of this method has to provide their own synchronization mechanism. !WARNING! Custom targets should only override this method if able to provide their own synchronization mechanism. Layout-objects are not guaranteed to be thread-safe, so using them without a SyncRoot-object can be dangerous.
(Inherited from Target)
WriteFailedNotInitialized LogEvent is written to target, but target failed to successfully initialize
(Inherited from Target)

Extension Methods

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 日誌寫入

See Also