Jump to content

LogFiles


Recommended Posts

I am looking to improve my script log file function. This function is quite basic and simply does the following

$Logfile = "Testscript.log"

$WorkingLogFile = FileOpen ("c:\YMpkg\Logs\" & $LogFile , 2)

I then send messages to the log file in the following way.

FileWriteLine($WorkingLogFile, $Time)

FileWriteLine($WorkingLogFile, $date)

FileWriteLine($WorkingLogFile, "....Starting installation function")

Etc ...

The issue with this is if the script falls over and terminates or the user / OS kills the process the log file will be empty. I can get around this by writing a function that opens and closes the logfile for each message but I fiure this isnt very efficient and there must be a better way to do this...

Any ideas appreciated....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...