Skip to content

Instantly share code, notes, and snippets.

@brianhdk
Created March 30, 2020 13:55
Show Gist options
  • Select an option

  • Save brianhdk/5c16c0ab7f0a0b8f23bbf796e955ed86 to your computer and use it in GitHub Desktop.

Select an option

Save brianhdk/5c16c0ab7f0a0b8f23bbf796e955ed86 to your computer and use it in GitHub Desktop.
public class Startup : IWebJobsStartup
{
public void Configure(IWebJobsBuilder builder)
{
string environment = Environment.GetEnvironmentVariable("AZURE_FUNCTIONS_ENVIRONMENT");
if (!string.Equals(environment, "Development", StringComparison.OrdinalIgnoreCase))
{
builder.Services.AddLogging(loggingBuilder => loggingBuilder
.AddSerilog(new LoggerConfiguration()
.WriteTo
.Elasticsearch(new ElasticsearchSinkOptions(ElasticClientFactory.Url)
{
AutoRegisterTemplate = true,
AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv7,
MinimumLogEventLevel = LogEventLevel.Information,
ModifyConnectionSettings = connection =>
{
connection.BasicAuthentication(ElasticClientFactory.Username, ElasticClientFactory.Password);
return connection;
}
})
.CreateLogger()));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment