powershell: [BUG] Set-PnPTraceLog: log file is empty

Reporting an Issue or Missing Feature

When use Set-PnPTraceLog (PnP.PowerShell 1.7.0) output log file is empty:

Set-PnPTraceLog -On -LogFile "output.log" -Level Debug

Expected behavior

Output log file is not empty and contains logging information from PnP.PowerShell cmdlets.

Actual behavior

Output log is empty.

Steps to reproduce behavior

Please include complete script or code samples in-line or linked from gists

What is the version of the Cmdlet module you are running?

PnP.PowerShell 1.7.0

Which operating system/environment are you running PnP PowerShell on?

  • [ x] Windows

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 18 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Any updates on this issue? I do not get trace logs in the console using the command Invoke-PnPSiteTemplate using version 1.7.0 or 1.8.0.

Merci @ygrenier ! Ok it’s in the build script that changes were done. I wasnt looking at the right place! So if using Build-Debug.ps1 locally, it fixes temporarily the problem…

image

I had an idea.

PnP.PowerShell use the PnP.Framework.Diagnostics.TraceLogger (from the PnP.Framework.dll) wich using the System.Diagnostic.Trace class.

In the PnP.Framework project I see in the Release configuration the TRACE variable is not defined, so because the ConditionalAttribute on the Trace class, the code calling Trace methods is not generated.

I tested with building a new PnP.Framework.dll with the TRACE variable enabled, and my log files are filled.

I don’t know how to report this feedback ?

Regards

I’ve been watching this issue closely because I’ve also encountered the problem. Sadly, it looks to me like something prior to the 1.8 release reverted back to creating empty log files. Here is the sample block that I used to quickly cycle through a few different versions:

[string] $logFileName = "ImportLog.log"
[string] $pnpVersion = "1.7.59-nightly"
[string] $siteUrl = "{site url here}"
[string] $templatePath = "{path to existing PNP site template here}"
[string] $templateFileName = ".\{filename of PNP site template}"

Uninstall-Module PnP.Powershell -Force
Install-Module -Name "PnP.PowerShell" -AllowPrerelease -RequiredVersion $pnpVersion
cd $templatePath
del $logFileName
Connect-PnPOnline -Url $siteUrl -Interactive
Set-PnPTraceLog -On -LogFile $logFileName -Level Debug
Invoke-PnPSiteTemplate -Path $templateFileName
Set-PnPTraceLog -Off
Disconnect-PnPOnline

My test results were as follows: 1.7.58-nightly - works as expected 1.7.59-nightly - works as expected 1.7.60-nightly - Yields empty log file 1.7.69-nightly - Yields empty log file 1.8.0 - Yields empty log file 1.8.12-nightly - Yields empty log file

I didn’t take the time to test all the nightly builds between 1.7.60 and 1.8.0 as the pattern seems relatively clear. Hopefully this helps. I’m eager to see the trace log functionality appear in a LTS build. Thanks for the help!