I want pass object of Logger (NLog) to my job. I have a class
public partial class SomeClass
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public void SomeMethod() {
try
{
_scheduler = StdSchedulerFactory.GetDefaultScheduler();
IJobDetail job = JobBuilder.Create<Job>()
.WithIdentity("job1", "group1")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(5)
.RepeatForever())
.Build();
_scheduler.ScheduleJob(job, trigger);
_scheduler.Start();
}
catch (SchedulerException es)
{
Logger.Trace(es);
Logger.Fatal(es);
}
}
}
and Job:
[DisallowConcurrentExecution]
public class Job : IJob
{
private static int i = 0;
/// <inheritdoc />
public Job()
{
}
/// <inheritdoc />
public void Execute(IJobExecutionContext context)
{
var logger = (Logger)context.Get("logger");//How ????
logger.Debug("etc");
}
}
How can I pass a logger to intance of my Job class through? Or in other words: How to put a logger to context? I can't find any information about it, even on offical site of Quartz.Net.