in reply to Print log at runtime instead of dumping all at once later

The solution presented by 1nickt, making "hot" the FH, is the right one most of the time. There are, however, some operating systems (such as VMS) where this does not really work: you just can't see, or not even know the size, of a file that has not been closed.

In this case, the best solution that I know is to open the target file for append, print and close the log file each time you write something to it. This might seem inefficient, and it is indeed not very efficient, but if it is just a log file not getting too much input, it is OK.

But, admittedly, this is very OS specific, I don't need that under Unix or Linux (and probably not under Windows, as far as I know).

  • Comment on Re: Print log at runtime instead of dumping all at once later

Replies are listed 'Best First'.
Re^2: Print log at runtime instead of dumping all at once later
by Technext (Acolyte) on Jul 02, 2015 at 03:56 UTC
    @Laurent_R: Apologies for not mentioning the OS. I have now updated the post. Both machines, Jenkins slave and remote box are CentOS instances.
      No problem, I was just saying that there are some cases where setting $| to a true value is not sufficient. I do not know what a Jenkins job is, and don't understand the details of what you're doing, but if the $| solution doesn't work for you, maybe the solution I outlined for VMS might be adapted to your case.
        @Laurent_R: salva's comment worked for me so i'll go for that. :) Just to let you know, Jenkins is a tool which facilitates continuous integration. It is worth looking if you want to automate the whole development cycle (dev > integration > staging > prod) using a user-friendly interface especially for Java projects. Thanks for your help. :)