5 Replies Latest reply on Jul 20, 2012 4:04 PM by Kin Yiu

    Logging in a BLPackage

    Steffen Kreis

      Hi,

       

      we make intense use of BLPackages here for our server environments.

      One thing that alwazs bothers me is the logging of output back to the Deployjob Log in the console.

       

      What is the best way to log back "echo" outputs of an external command without switching the Logging Level to "All information"

       

      The reason why "All information" is not really feasable is the fact that this will return the whole content of the external command prior running it, which gets completly unreadable and confusing.

       

      Cheers

      Steffen

        • 1. Logging in a BLPackage

          There is no clean way of doing it, without 'All Information'.

           

          One dirty way would be to have your echo statements redirect to error:

           

          echo "[INFO] your message" >&2

           

          This way you should see it in the Deploy Job log, and the [INFO] tag will let you know that you should not worry about it. If your last statement in the external command will be simular echo statement, then you want to complete that whole external command with exit 0, so that the blpackage does not fail your item. example:

           

          echo "[INFO] end of blpackage item" >&2

          exit 0

           

          Other than this if your blpakcage consist of scripting pieces only, consider NSH Script Job to print the echo messages to the log.

          • 2. Logging in a BLPackage
            Steffen Kreis

            Hi Lazar,

             

            thanks for your reply....

            Yes, i tried this mechanism myself already...but i'm afraid our customers would be worried due to all the yellow "WARNINGS" ....

             

            I guess i'll raise this as an RFE.

             

            BLPackages could be soooo powerful and nice, but its always that little things that are missing....

             

             

            Cheers

            Steffen

            • 3. Logging in a BLPackage

              Hi Steffen,

               

              Other than the workaround you guys already pointed out, I am afraid there is no other way to echo output from an external command back to the job log without setting the log level to "All Infromation".

               

              On the other hand, you can put "@echo off" at the beginning of the external command which will stop the echoing of the commands being executed. The "@echo off" will be put in by default starting in 8.2 SP2, btw.

               

              -Kin

              • 4. Logging in a BLPackage
                Steffen Kreis

                Hi,

                 

                i'm a bit confused now!


                From my perspective BL always puts the following two lines automagically on the top of every external command from a BLP:

                 

                     @echo off

                     chcp 1252 > NUL

                 

                A BLPAckage that contains the following as an external command:

                 

                @echo off

                echo "********THIS IS A TEST**********"

                 

                ends up as :

                 

                 

                     @echo off

                     chcp 1252 > NUL

                     @echo off

                     echo "********THIS IS A TEST**********"

                 

                 

                on a target server.

                 

                 

                 

                Therefor i don't get what will be new in 8.2 SP2 ?!

                 

                In additon that still doesn't really help as an "@echo off" will prevent that stuff is logged out for the third time:

                 

                As when set to "All information" the commit-phase would still include something similiar to this:

                 

                     Info    Jul 20, 2012 8:06:40 AM     Executing command: "@echo off

                     Info    Jul 20, 2012 8:06:40 AM    echo "********THIS IS A TEST**********""

                     Info    Jul 20, 2012 8:06:41 AM     [stdout: 1]     "********THIS IS A TEST**********"

                 

                So "All information" always shows the whole command to be executed anyway, before it then will log the output on stdout.

                 

                Or do i miss something here ?

                 

                Cheers

                Steffen

                • 5. Logging in a BLPackage

                  Hi Steffen,

                   

                  BL doesn't put the "@echo off" statement into the Windows Batch file it creates to run the external commands until 8.2 SP2 (and a hotfix for 8.2 SP1). The "@echo off" command only prevents Windows from echoing back the commands being executed inside the Batch file. So, the following 2 lines shouldn't be in the log (at least in my test environment):

                   

                       Info    Jul 20, 2012 8:06:40 AM     Executing command: "@echo off

                       Info    Jul 20, 2012 8:06:40 AM    echo "********THIS IS A TEST**********""

                   

                   

                   

                  The [stdout: 1] is the capture of standout from the commands themselve (i.e. the "echo" command in this case), so those output would still be logged (and rightfully so).

                   

                  Thanks

                  -Kin