# Need help to Log output on screen and to Text file

**URL:** <https://forums.powershell.org/t/need-help-to-log-output-on-screen-and-to-text-file/3372>\
**Category:** PowerShell Help\
**Created:** [November 5, 2014, 2:48am UTC](https://forums.powershell.org/t/need-help-to-log-output-on-screen-and-to-text-file/3372 "2014-11-05T02:48:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![preenesh-nayanasudha](https://avatars.discourse-cdn.com/v4/letter/p/87869e/32.png) [@preenesh-nayanasudha](https://forums.powershell.org/u/preenesh-nayanasudha)\
**Post date:** [November 5, 2014, 2:48am UTC](https://forums.powershell.org/t/need-help-to-log-output-on-screen-and-to-text-file/3372/1 "2014-11-05T02:48:20Z")

</div>

Hi

Have a function which I call during my script and use to write output to the screen, I would also like to out put the same information to a log file.

I have tried to pipe the output to a file using out-file but I dont see the log file created nor an error. I see the output on screen but not a log file

Function Logit(){  
$TextBlock1 = $args[0]  
$TextBlock2 = $args[1]  
$TextBlock3 = $args[2]  
$Stamp = Get-Date  
Write-Output “[$Stamp] [$Section - $TextBlock1]” | Out-file -Append -FilePath ‘C:\Script\Log.txt’  
}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [November 5, 2014, 2:52am UTC](https://forums.powershell.org/t/need-help-to-log-output-on-screen-and-to-text-file/3372/2 "2014-11-05T02:52:55Z")

</div>

You can use the Start-Transcript command for this, but it has some limitations that are being addressed in PowerShell v5 (only works in the powershell.exe host, only one transcript can be active at a time.) To get around these limitations, I wrote the PowerShellLogging module, which you can download from [https://gallery.technet.microsoft.com/Enhanced-Script-Logging-27615f85](https://gallery.technet.microsoft.com/Enhanced-Script-Logging-27615f85) .

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:46pm UTC](https://forums.powershell.org/t/need-help-to-log-output-on-screen-and-to-text-file/3372/3 "2024-05-16T20:46:46Z")

</div>


