Azure WebJobs: Cannot find trace log
I followed the instructions on this Microsoft web page to log messages from an Azure WebJob, but none of my messages appeared in the log.
In my WebJob I am recording log messages using
Trace.TraceInformation("blah blah blah");
In the application diagnostics section of the configuration file, I have enabled block storage logging with the Verbose option.
Log files are generated (although sometimes I have to wait several minutes - in one case until the next morning - until the logs appear in the blob store), but the logs do not contain messages Trace
.
So how do I write messages to these log files and / or where Trace
are they written to?
Here is a picture of my configured settings for logging:
And the configured blob storage is certainly the same as the one I am looking at.
source to share
To specify a storage account for web work logs, you need to add a connection string under CONFIGURATION > Connection Strings, the connection string name should be AzureWebJobsDashboard.
It should look like this:
- Name : AzureWebJobsDashboard
- Value : DefaultEndpointsProtocol = https; AccountName = "; AccountKey =" "
- Type : custom
You can also view the logs in the Azure portal, open the web app and select the WEBJOBS tab , click the web job URL, display the latest runs, click the Toggle that shows the run details, including custom messages written by the app, using the instructions below.
Console.WriteLine("Error While Doing Something ...");
source to share
Azure WebJobs offers two mechanisms for sending output to the log, visible in the WebJobs SDK Toolbar :
- Class static methods
Console
(for exampleConsole.WriteLine
) - Using the object
TextWriter
you receive as a parameter "log
" of your methods, decorated with one or more SDK attributes (for example[NoAutomaticTrigger]
)
This effectively explains your question:
- The logging mechanism provided by Azure WebJobs (which natively supports
Trace
) is not related to the one used in Azure Web Apps ( this previous answer to this question explains how to set up logging) -
Trace
not supported as the default mechanism , which explains why you can't find the trace log
However, in both cases it is easy to add a TraceListener
that will capture the output of your statements Trace
.
This answer explains how to do it for Console
.
And the object log
can be added as TextWriterTraceListener
.
This worked as expected for me.
source to share
To view the website and website logs easily, you can use the Azure Website Log Browser site extension , find more information about installing it here - http://blog.amitapple.com/post/2014/06/azure-website- logging / .
If you still don't see your logs there, or it takes a long time for them to show (shouldn't) start a thread on the msdn forum that would be more pertinent for such problems.
source to share