禁止登录Azure Webjobs(“执行中:"xxx",因为在"yyy"上检测到新队列消息.") [英] Suppress logging in Azure Webjobs ("Executing: 'xxx' because New queue message detected on 'yyy'.")
问题描述
有没有办法禁止Executing: 'xxx' because New queue message detected on 'yyy'.
的日志条目?
我仍然想查看我的日志(写到控制台),但是我对查看Executing (...)
条目不感兴趣.那些没有给我任何价值,现在是大多数日志.
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.
推荐答案
您可以通过JobHostConfiguration.Tracing.ConsoleLevel
全局控制控制台日志级别.那些正在执行/已执行"消息是在默认的TraceLevel.Info
级别上跟踪的.您可以将日志级别设置为TraceLevel.Warning
或TraceLevel.Error
,您将不再看到它们(您只会看到警告/错误).
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).
但是,该设置也将应用于您通过TextWriter
作业参数从作业功能写入的任何日志(如果这就是您的日志"的意思).如果那不是您想要的,则可以通过JobHostConfiguration.Tracing.Tracers
集合注册自己的自定义TraceWriter
.如果随后用TraceWriter
参数替换了TextWriter
参数,并且使用了允许您指定源"的跟踪重载之一,则您的自定义TraceWriter可能允许您的日志通过.请参见此处.
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.
为了完整起见,您还可以在类或方法级别应用一个属性来控制函数记录.例如,如果将[TraceLevel(TraceLevel.Error)]
应用于特定的作业方法,则在该功能失败时,您将仅获取日志.请注意,此属性将影响仪表板日志记录以及控制台日志记录.
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.
这篇关于禁止登录Azure Webjobs(“执行中:"xxx",因为在"yyy"上检测到新队列消息.")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!