You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have lots of Automated Scripts on one server that I would like better logging on. They can all write to the same file location so like C:\tools\logs but would want the log file name to be the name of the file.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Anyway to create a function to call on a generic logger that would create the file name based off of ps1 filename?
So example$logpath + "" + "$ $scriptName" + ".txt" #Creates the log file object
Logfile Variables
$logpath = "C:\tools\logs"
$scriptName = $MyInvocation.MyCommand.Name
$Log =
#####Starts logger info
New-Logger |
Set-MinimumLevel -Value Debug |
Add-SinkConsole -RestrictedToMinimumLevel Information|
Add-SinkFile -Path $log |
close-logger
I have lots of Automated Scripts on one server that I would like better logging on. They can all write to the same file location so like C:\tools\logs but would want the log file name to be the name of the file.
C:\tools\logs\file1.txt
C:\tools\logs\file2.txt
Beta Was this translation helpful? Give feedback.
All reactions