piotrwest
piotrwest

Reputation: 2166

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

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.

Upvotes: 0

Views: 798

Answers (1)

mathewc
mathewc

Reputation: 13568

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.

Upvotes: 3

Related Questions