iOS Simulator - no NSLog messages

Since using NSLog was mentioned here for debugging, I thought I’d give that a try.

This is the code I am using to attempt to write something to the log file:

Dim x = "MsgLogged here"
NSLog("%@", $"{x}")

This code is right before a line of code that I know is working. Here are the steps I am following:

  • Build the project.
  • Deploy w/o running (to the simulator, which is already running).
  • Manually launch the app in the simulator and wait for it to load and trigger the line of code that is working.
  • From the Simulator menus, choose Debug => Open System Log
  • In the log file, search for the text that should be logged, but it isn’t there.

The log file is not empty. I’m still too much of a newbie to know if what is in there is normal or not. And it does seem to get new information, just not my logged message.

So the question is: am I doing this correctly, or is there something obvious I should change to write information to the log file? (My Google-fu is failing me.)



Check the first message in the debug console. I forget which is which, but iirc simulator doesn’t do NSlog and only stdout (eg writeLn), while the device doesn’t do stdout but only nslog.

If you use the Log() function from Elements RTL instead, it should do the right thing for both cases, iirc; if that fails, try not to NSLog and writeLn(), one of the two should come thru.

That said, of course only if you ARE debugging :).

NSLog messages should also show in (even when not debugging). I know this is messy. Wait til you get to Android :joy:.

Thank you for mentioning the When I was opening the system log file from the Simulator, it was opening the, but I didn’t look at it all that carefully - I just focused on the log that was displayed. Turns out - it was showing the wrong device - oops!

I can see a message now, yay!

Yikes! What a terrifying thought!

Thank you spelling out the various options, and the pointer to Log from Elements RTL. Maybe its time to start looking at that more.



I need do add some docs coverage for it, soon. It’s a very simple but very nifty extensible/pluggable logging infrastructure see here. You can replace it (e.g. to add custom log destinations for your own app), simply my implementing the one methodic of ILogger and assigning tour own to the global Logger property…