In previous versions we used NLog in PowerShell scripts, especially useful with custom PowerShell Sync Projects. It has been extremely useful for debugging connections and specific failures.
It was essentially loaded like this:
# Update to the correct path
$mypath = $MyInvocation.MyCommand.Path;
$parentPath = Split-Path $mypath -parent;
# Load NLog
$nlogPath = "$parentPath\Nlog.dll";
[System.Reflection.Assembly]::LoadFile($nlogPath);
function Import-Logger
{
# Create a new Logger
$Logger = [Nlog.LogManager]::GetLogger("MyLoggerName");
return($Logger);
}
$global:Log = Import-Logger;
$Log.Debug("This is a logged message at Debug level.");
However, this now fails in v10. I see the NLog in v10 is of a v6.0.0 which has moved from LogManager to LogFactory (but switching to that fails with same error). I spent quite a bit of time looking at different ways of loading the DLL, all resulting in the same failure of "Unable to find type [NLog.LogFactory].".
So, I grabbed the nuGet 6.0.0 package, extracted it, and the above code was fine when loading those NLog.dll. So, there is definitely something about the NLog supplied in v10 that can't be loaded into PowerShell.
Any guidance on getting OneID NLog to work in PowerShell?