22 lines
702 B
C#
22 lines
702 B
C#
|
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()
|
||
|
.WriteTo.OpenTelemetry(
|
||
|
connectionString,
|
||
|
resourceAttributes: new Dictionary<string, object>
|
||
|
{
|
||
|
{ "service.name", "newsbot-collector-api" },
|
||
|
{ "Job", jobName }
|
||
|
})
|
||
|
.CreateLogger();
|
||
|
}
|
||
|
}
|