1 Reply Latest reply on Aug 2, 2017 2:43 AM by phoffmann

    How do I add date/time to log filename?

    bdwest Apprentice

      For my software distribution packages, I'm using centralized logging.  I've set up a share that all domain computers (since it's the local system account that generally runs tasks) can write to.  I create a subfolder for each category I want to group together.  Then I modify the command line switch.  I started out with something like this in the Log File Name field:

      \\Server\Share\SoftwareImInstalling_logs\%COMPUTERNAME%_SoftwareName_1_0_install.log

      That works just fine.

       

      Now I want to put the date and time stamp into the file name.  So this is what I think should work:

      \\Server\Share\SoftwareImInstalling_logs\%COMPUTERNAME%_SoftwareName_1_0_install_%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.log

       

      That command should give me something like this name:

      \\Server\Share\SoftwareImInstalling_logs\MyFavoriteComputer_SoftwareName_1_0_install_20170719_142320.log

       

      Unfortunately, when I put that string in the Log File Name field in the MSI Properties window, it throws an error that the Command is not a supported option, or it requires a parameter.  This is supported syntax within a Windows Command Prompt; does anyone know what, exactly, this is choking on, or maybe a different way to get what I'm looking for?

       

      Thanks.

        • 1. Re: How do I add date/time to log filename?
          phoffmann SupportEmployee

          Not sure what it's choking on, but as one possible idea ...

           

          ... have an "external" Powershell script (or "thing of your preference") check for new files coming in on the share / the subdirectories. Or parse them 1x every 10 minutes or so.

           

          Since you're going to have the logs in individual directories "by computer name", you can just parse through the stuff once every 10 minutes or so, check for "files that don't end with the regular expression date-pattern you're using" and if need be, edit that up.

           

          You can use either the date/time entries within our own logs (if you want to crank them open) or use the "last modified date" as another option to base your datetime string on & then just rename the file accordingly.

           

          Given than %Computername% works fine, it may be a dev-type question to figure out why the %Date %Time... stuff does not - you may want to open a low prio support call and get clarification whether that's just not something the devs thought to provide for, or a defect or a simply case of "oh, you need to add escape characters because reasons" or some such ...?

           

          The first will at least get you rolling with what you want / need .