Newsbot.Collector/Newsbot.Collector.Services/Jobs/JobLogger.cs

23 lines
736 B
C#
Raw Permalink Normal View History

using Serilog;
namespace Newsbot.Collector.Services.Jobs;
public static class JobLogger
{
public static ILogger GetLogger(string connectionString, string jobName)
{
if (connectionString == "")
return Log.Logger = new LoggerConfiguration().WriteTo.Console().CreateLogger();
return Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.MinimumLevel.Debug()
.WriteTo.OpenTelemetry(
connectionString,
resourceAttributes: new Dictionary<string, object>
{
{ "service.name", "newsbot-collector-api" },
{ "Job", jobName }
})
.CreateLogger();
}
}