How to log job info

How do I write debug information inside Hangfire log ?

There are anythings like this ?

public void MyJobCallBack() {

    var myJob = Hangfire.JobManager.GetCurrentJob();
    myJob.Alert("test"); // or myJob.Debug("test");

1 Like

You need to implement logging using something like NLog -

getting the current job and jobId from the Hangfire environment would be helpfull. for example to get the jobId

1 Like

Does anyone have anything new to add here?

Is it possible to get hold of some kind of context which identify what job the code currently executes?

It doesn’t really need to be a ‘human readable’ value, like jobId, as long as it’s something unique.

I was first thinking about thread ids, but I guess threads are reused, so it’s not suitable.