Batch script to create log file with timestamp

    create log file in batch script
    write log file batch script
    create log file with .cmd script
    create log file with date and time in batch script
  • Create log file in batch script
  • Batch file output to log and console!

    /* steve jansen */

    I use basic logging facilities in my scripts to support troubleshooting both during execution and after execution.

    Batch file output to text file append

  • Batch file output to text file append
  • Dos write to file
  • Batch file output to log and console
  • How to see output of batch file
  • How to log errors in batch file
  • I use basic logging as a way to instrument what my scripts are doing at runtime and why. I remember watching a network operations center trying to troubleshoot a legacy batch process where the sysadmins literrally had to try to read the lines of a console window as they trickled by.

    This technique worked fine for years when the batch machines used dial-up modems for connectivity to remote resources. However, the advent of brooadband meant the batch script executed faster than anyone could read the output.

    A simple log file would have made troubleshooting work much easier for these sysadmins.

    I really like the basic implementation I wrote in Part 7 – Functions.

    This quasi function enable me to write output to the console as well as a log file.

    Here I am reusing the same log file path, which is saved in the users folder as the name of the batch file with a .txt file extension.

    If you need to retain logs for each execution, you could simply

      how to create error log file in batch script
      create log file with date and time in batch script linux