LogConfigurationExtensionsUseFileAndElasticSearchWithApiKey Method

同時使用檔案與 ElasticSearch 日誌 (ApiKey Authentication)

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 static LogConfiguration UseFileAndElasticSearchWithApiKey(
	this LogConfiguration logConfiguration,
	string elasticSearchUri,
	string apiKeyId,
	string apiKey,
	string logDirectory = null,
	string indexFormat = "logs-${shortdate}"
)

Parameters

logConfiguration  LogConfiguration
日誌配置物件
elasticSearchUri  String
ElasticSearch 服務器 URI
apiKeyId  String
API Key ID
apiKey  String
API Key
logDirectory  String  (Optional)
日誌檔案目錄
indexFormat  String  (Optional)
ElasticSearch 索引格式

Return Value

LogConfiguration
LogConfiguration 物件 (支援鏈式呼叫)

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type LogConfiguration. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Example

C#
LogHelper.Configure(config => 
{
    config.UseFileAndElasticSearchWithApiKey(
        "http://localhost:9200",
        "VuaCfGcBCdbkQm-e5aOx",
        "ui2lp2axTNmsyakw9tvNnw",
        @"C:\Logs",
        "myapp-${shortdate}");
});

Revision History

DateVersionDescription
2025/12/0925.0.0.0新增 ApiKey 驗證支援

See Also