Suppress logging in Azure Webjobs (“Executing: 'xxx' because New queue message detected on 'yyy'.”)

一世执手 提交于 2019-12-08 12:33:04

问题


Is there a way to suppress log entries of Executing: 'xxx' because New queue message detected on 'yyy'.? I still want to see my logs (written to Console), however I'm not interested in seeing Executing (...) entries. Those do not provide me any value and those are the majority of the logs now.


回答1:


You can control the Console log level globally via JobHostConfiguration.Tracing.ConsoleLevel. Those "Executing/Executed" messages are traced at the TraceLevel.Info level which is the default. You can set the log level to TraceLevel.Warning or TraceLevel.Error and you won't see them anymore (you'll see only warnings/errors).

However, that setting will also apply to any logs that you write from your job functions via a TextWriter job parameter (if that's what you mean by "your logs"). If that isn't what you want, you could register your own custom TraceWriter via the JobHostConfiguration.Tracing.Tracers collection. If you then replaced your TextWriter parameters with TraceWriter parameters and used one of the trace overloads that allows you to specify a "source", your custom TraceWriter could allow your logs through. See the custom TraceWriter sample here.

For completeness, there is also an attribute that you can apply at the class or method level to control function logging. For example, if you apply [TraceLevel(TraceLevel.Error)] to a particular job method, you'll only get logs if that function fails. Note that this attribute will affect Dashboard logging as well as Console logging.



来源:https://stackoverflow.com/questions/35142474/suppress-logging-in-azure-webjobs-executing-xxx-because-new-queue-message-d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!