I've got a fairly long notebook. I like to have most of the sections collapsed. If I evaluate the entire notebook I don't see errors in the collapsed sections unless I expand them. I did see that I can direct kernel messages to the console, which would let me see them. But then I don't know where they came from since I don't show the In/Out in my notebooks. It looked like the option inspector would allow me to set the messages to go to both the notebook and the console, but that didn't work.

Is there a way to write a function that would show me if there were any errors? Or, is there a way to "go to" a particular "In"? Or is there a better way to handle this?


1 Answer 1


Since it does not seem possible to send a Stream to a Notebook (ref: How to pipe a stream to another notebook?) I can only suggest modifying the message printing routine in some way. I propose combining these two methods:

Evaluate this in the session:

PrintToConsole[expr_] := (SetSelectedNotebook[MessagesNotebook[]];
  NotebookWrite[SelectedNotebook[], Cell[BoxData[ToBoxes[expr]], "Print"]])

Internal`AddHandler["Message", PrintToConsole]

Afterward messages should be printed in both the Notebook and the Messages window if you open the Messages window before evaluating the Notebook.

This may still leave you hunting for the origin of a particular message but at least you'll know to look. You may also consider inserting information into your messages to make their origin more apparent; see:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.