Skip to content

Enable-NGLogLogging will not redirect "write-host" to log file #1

@zerocode000

Description

@zerocode000

As per the readme, the write-host is supposed to be redirected by default.

The problem seems to exist in this script file:
PSNLog/public/Enable-NLogLogging.ps1

  if (-Not($DontRedirectMessages.IsPresent)) {
            Set-MessageStreams -WriteVerbose -WriteWarning -WriteError
        }

This needs to become

  if (-Not($DontRedirectMessages.IsPresent)) {
            Set-MessageStreams -WriteVerbose -WriteWarning -WriteError -WriteHost
        }

so that the Set-MessageStreams will add the write-host alias in Set-MessageStreams.ps1

     if ($WriteHost.IsPresent) {
            if (-Not(Test-Path 'Alias:\Write-Host')) {
                New-Alias -Name 'Write-Host' -Value 'Write-NLogHost' -Scope Global
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions