How do I redirect all printed text to a file instead of the FrontEnd? This question was answered in Temporarily redirect the output of Print[ ] to a second file, except that this does not capture text printed in subkernels as I encountered when I replaced a Do with a ParellelDo. These prints are not saved in my log and are outputted in the FrontEnd. How do I fix this?
P.S.: The text that is printed by the subkernels does not necessarily have to be printed to the same file (might be problematic with kernels that want to write to the same file simultaneously), as long as it is logged somewhere.
Possible relevant posts are: Local logfiles for remote kernels and How to Export from ParallelDo?, but they are not enough for me to help me construct a solution to this problem.
The texts printed are diagnostics on what computations are being done: e.g. what is the computation, how much time is it taking and how much memory is it using. Not all the code is even written by myself. Thus replacing Print with some other function to collect and export the data is not really feasible. (Except if you mean to do something like Block[{Print=NewPrint}...], or another way where I don't actually need to alter the code. )
Why is it useful to Print to file instead of to the frontend? Firstly, a large amount of printed text output will slow down or freeze the frontend. Dedicated text editors are much better suited for dealing with thousands of lines of text. In addition this makes it much easier to save and efficiently archive (semi-permanent) logs of everything you have run.
Comments
Post a Comment