http://www.perlmonks.org?node_id=1066200


in reply to View content of Log::Log4perl log file while logger is running

Unless I've misunderstood your question. You're not going to be able to view the log file, until the system has completely flushed the file to disk, and released the filehandle. So that your app can parse it for reading.

Best wishes.

--Chris

Hey. I'm not completely useless. I can be used as a bad example.
  • Comment on Re: View content of Log::Log4perl log file while logger is running

Replies are listed 'Best First'.
Re^2: View content of Log::Log4perl log file while logger is running
by iseif (Novice) on Dec 08, 2013 at 10:30 UTC
    Thanks a lot for your replay. There is no way to 'view the file'? not opening it? for example, in Notepad++ we can open a file while Notepad is updating it - the notepad++ will tell us that the content of the file has been updated. I need to show the file content to the user and when he reload the page (F5) then we will see the new updated file.
      Well. I seem to be having a bit of difficulty following you completely.

      If I understand you correctly. You'd be likening it to opening an already created log file in your favorite editor. Then, refreshing the editor's view. Will show any additions/subtractions that may have occurred. Yes?

      If that's the case, you should be able to open an already created log file. Providing that the system is not already using it. In other words, as I stated before; if your system is either opening, writing, or otherwise, has it open for processing. You will NOT be able to open it, UNTIL the system has finished closing it. That's the way it works -- and for good reason. That's how you prevent data corruption.

      If you can get handle on the file, before the system does. You can maintain that handle, and refresh the view of that file, to see if there have been any changes. But to do that. You will need to create temp variable, that holds your current view. Thereby releasing the original file handle for other processes (whatever process is logging to log file you're viewing). So that, like you're viewing the file. They can write to it.

      Is this helping. Do you understand better how the whole process works? Did I understand your question correctly?

      Best wishes.

      --Chris

      Hey. I'm not completely useless. I can be used as a bad example.