2023-03-31 23:00:15 -07:00
|
|
|
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()
|
2023-04-03 09:31:00 -07:00
|
|
|
.MinimumLevel.Debug()
|
2023-03-31 23:00:15 -07:00
|
|
|
.WriteTo.OpenTelemetry(
|
|
|
|
connectionString,
|
|
|
|
resourceAttributes: new Dictionary<string, object>
|
|
|
|
{
|
|
|
|
{ "service.name", "newsbot-collector-api" },
|
|
|
|
{ "Job", jobName }
|
|
|
|
})
|
|
|
|
.CreateLogger();
|
|
|
|
}
|
|
|
|
}
|