Search code examples
azureazure-webjobs

Have Several job in the same assembly, but separated in logs/ listing


In my project, I have several webjobs, until now, I have separated them in several projets. I thought that I could not have them separated in my webjob list / kudu logs if they were under the same assembly:

enter image description here

If I mix several functions in the project, they all go under the same webjob and logs are mixed in kudu: Exemple:

public class JobA
{
    public async Task Eljob([TimerTrigger("0 * * * * *")]TimerInfo myTimer, ILogger log){
        log.LogInformation("Running Eljob");
    }
}

public class JobB
{
     public async Task JobyAsync([TimerTrigger("0 * * * * *")]TimerInfo myTimer, ILogger log){
        log.LogInformation("Running JobyAsync");
      }
}

This will just give me logs like this:

> [10/02/2019 06:40:00 > da4c4f: INFO]       Executing 'JobA.Eljob'
> (Reason='Timer fired at 2019-10-02T06:40:00.0097572+00:00',
> Id=d235e5f4-7c50-4b9f-9bdc-6a0aa3f71e43) [10/02/2019 06:40:01 >
> da4c4f: INFO] info: Function.JobyAsync.User[0] [10/02/2019 06:40:01 >
> da4c4f: INFO]       Running JobyAsync [10/02/2019 06:40:01 > da4c4f:
> INFO] info: Function.JobyAsync[0] [10/02/2019 06:40:01 > da4c4f: INFO]
> Executed 'NotificationsFunction.JobyAsync' (Succeeded,
> Id=41875a80-33f3-4313-8f4a-5f60cc0a73c2) [10/02/2019 06:40:01 >
> da4c4f: INFO] info: Function.Eljob.User[0] [10/02/2019 06:40:01 >
> da4c4f: INFO]       Running Eljob [10/02/2019 06:40:01 > da4c4f: INFO]
> info: Function.Eljob[0]

As my project grows, it seems more and more wrong to keep on going this way. Is it possible to have functions in one projects, list as different webjob and have separate logs?

Thanks!


Solution

  • As far as I know, there is no way to split the logs for different webjobs in one project.

    There is a workaround if you like to use Application Insights logging.

    If you choose application insights for webjobs logging, you need to create an application insights first, then follow this steps in webjobs with application insights logging.

    After the configuration is ready, when run the webjobs, all the logs are sent to application insights. Then in application insights logs, you can write query with some filters(the filter like webjobs name) to get the logs for each webjobs.