In Azure App Services C# based Web Jobs, you can see the network traffic that is using the System.Net socket and related .Net classes using this functionality. This should be only used to temporarily grab traces as the log will grow quite large and it (as with any logging) will decrease performance slightly.
Navigate to your app files using the Kudu console:
- Open your Azure portal and navigate to your Azure Web App (under App Services) that is hosting the Web Job
- Open the Kudu link and click the ‘go’ link:
- Select ‘Debug console’ then ‘CMD’
- Navigate to the jobs folder by clicking on the folders: home,site,wwwroot,app_data,jobs or… simply type in the console: cdhomesitewwwrootapp_datajobs
Your job might be a triggered or continuous job so next you need to navigate to that directory by clicking on the appropriate folder (my example is a triggered job) and then locating the folder for your job. Then find the executable and config file for your app (hint: if there is not a config file, simply create one with the touch command in the console: touch NAMEOFYOUREXE.exe.config). In my case the name of the executable is WebJobToProfile.exe and the config file is WebJobToProfile.exe.config:
Now edit the .config file by clicking on the pencil icon. Then add the following to the top of the
traceOutputOptions = “ProcessId, DateTime”
Note that this highlighted section is where the log will be written: initializeData=”d:homelogfilesSystem.Net.trace.log”
Now run your web job (If this is a continuous web job, you need to stop and start it because configuration files are read when the .exe first loads) and when your code makes a System.Net trace, it will write the log file. After you are done tracing, remove your changes so you are not logging any more!
You can now download the system.net.trace.log file.
Click on the Home icon, navigate to the LogFiles directory by clicking on the LogFiles folder and click on the Download icon to download the log!
The system.net trace is a powerful tool to see what your .Net app is doing at the socket level. Try it out to see if it helps resolve your issues or to simply see what is happening with your WebJob! DO NOT FORGET to back out your logging changes when done by removing the
Drop me a note if you found this useful!
This post first appeared on MSDN Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The MSDN Blogs., please read the originial post: here