Introduction
Looking into PnP Provisioning I noticed there isn’t configuration to set up proper log and trace information (version v2.4.1605).
If you haven’t chance to look into PnP Core solution, and you want to know how to start, take a look here: Office 365 PnP Provisioning starting point.
Anyway, if you’d like to add some extended information about what is happening internally when we are provisioning some site templates, we can achieve it following these steps:
Configuring Log
In app.config (console application) just add these xml inside configuration
element.
Including that enables Event viewer information to be displayed directly in the console:
IMPORTANT: you can enable this extended information on Azure WebJobs too. Just copy the xml at the end of app.config.
Usage in our Console App
Now, if we also want to log all the Console App information into a file, we should add this code to our main:
Note: Remember we should then use Trace.WriteLine instead Console,WriteLine in our program.
1 | Trace.WriteLine(""); |
That will create a .log file including the same text and information we see in the console app screen.