在同一个程序集中有多个作业,但在日志/列表中分开
Have Several job in the same assembly, but separated in logs/ listing
在我的项目中,我有几个webjobs,到现在为止,我把它们分开在几个项目中。我认为如果它们在同一个程序集下,我不能在我的 webjob 列表/kudu 日志中将它们分开:
如果我在项目中混合使用多个函数,它们都在同一个 webjob 下,并且日志在 kudu 中混合:
例子:
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");
}
}
这只会给我这样的日志:
> [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]
随着我的项目越来越大,这样走下去似乎越来越不对了。
是否可以在一个项目中具有功能,列为不同的 webjob 并具有单独的日志?
谢谢!
据我所知,无法在一个项目中为不同的 webjobs 拆分日志。
如果您想使用 Application Insights logging,有一个解决方法。
如果您选择 application insights for webjobs logging,您需要 create an application insights first, then follow this steps in webjobs with application insights logging。
配置就绪后,当运行webjobs时,所有的日志都会发送到application insights。然后在应用程序洞察日志中,您可以 write query 使用一些过滤器(过滤器如 webjobs 名称)来获取每个 webjobs 的日志。
在我的项目中,我有几个webjobs,到现在为止,我把它们分开在几个项目中。我认为如果它们在同一个程序集下,我不能在我的 webjob 列表/kudu 日志中将它们分开:
如果我在项目中混合使用多个函数,它们都在同一个 webjob 下,并且日志在 kudu 中混合: 例子:
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");
}
}
这只会给我这样的日志:
> [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]
随着我的项目越来越大,这样走下去似乎越来越不对了。 是否可以在一个项目中具有功能,列为不同的 webjob 并具有单独的日志?
谢谢!
据我所知,无法在一个项目中为不同的 webjobs 拆分日志。
如果您想使用 Application Insights logging,有一个解决方法。
如果您选择 application insights for webjobs logging,您需要 create an application insights first, then follow this steps in webjobs with application insights logging。
配置就绪后,当运行webjobs时,所有的日志都会发送到application insights。然后在应用程序洞察日志中,您可以 write query 使用一些过滤器(过滤器如 webjobs 名称)来获取每个 webjobs 的日志。