in tests-integration/Elastic.Serilog.Sinks.IntegrationTests/BootstrapMinimumSecurityPrivilegesTests.cs [83:122]
protected SecurityPrivilegesTestsBase(SecurityCluster cluster, ITestOutputHelper output) : base(cluster, output)
{
var logs = new List<Action<Logger>>
{
l => l.Information("Hello Information"),
l => l.Debug("Hello Debug"),
l => l.Warning("Hello Warning"),
l => l.Error("Hello Error"),
l => l.Fatal("Hello Fatal")
};
var apiKey = SecurityCluster.CreateApiKey(Client, ApiKeyJson);
ApiScopedClient = cluster.CreateElasticsearchClient(output,
s=>s.Authentication(new ApiKey(apiKey.Encoded))
);
SinkOptions = new ElasticsearchSinkOptions(ApiScopedClient.Transport)
{
BootstrapMethod = Bootstrap,
DataStream = Target,
ConfigureChannel = c =>
{
c.BufferOptions = new BufferOptions
{
WaitHandle = _waitHandle,
OutboundBufferMaxSize = logs.Count
};
},
ChannelDiagnosticsCallback = (l) => _listener = l
};
var loggerConfig = new LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo.ColoredConsole()
.WriteTo.Elasticsearch(SinkOptions);
using var logger = loggerConfig.CreateLogger();
foreach (var a in logs) a(logger);
}