0

I have a simple iPhone App that uses an NSLog and several printf statements. The app is a simple test app that I created to test serial communication on the iPhone (3GS). Obviously I can not test serial com with the iOS Simulator, so I have my device unplugged from the computer after I click Run from within Xcode. I installed syslogd from Cydia, and tail /var/log/syslog allows me to monitor certain log messages.

However when I open my app and it reaches the NSLog portion of the code I don't see the message appear in /var/log/syslog I also don't see the printf statements output in the syslog file for the app.

Is there a file that exists on the iPhone itself that contains the output from these statements, or do I need to specify my app to output to /var/log/syslog?

I am content with opening another file if it exists on the phone that contains the contents of the log messages. Basically I want to be able to see the contents of the log messages while I am sshed into the phone so I can see what is going on. And obviously using the Console output in Xcode is not an option because the phone isn't connected to the computer.

ipatch
  • 3,933
  • 8
  • 60
  • 99

2 Answers2

1

You write to syslog you should be calling the syslog function.

NSLog output can be seen as shown in this SO question.

printf will only go to stdout.

I would try not to use NSLog and stdout for logging in the same app - use NSLog for all logging there. Or with more work ue a logging framework like CocoaLumberjack that allows more flexibility including other loggers which could include syslog, thus having one logging function that you can redirect to different outputs at runtime.

Community
  • 1
  • 1
mmmmmm
  • 32,227
  • 27
  • 88
  • 117
  • How can I view stdout for my printf statements? I moved my NSLog statement and was able to see it in syslog, but was not able to see the printf statements. – ipatch Jul 21 '12 at 23:16
  • I don't know which is one reason to use NSLog or another logger to allow you to redirect. – mmmmmm Jul 21 '12 at 23:16
1

Are you using tail /var/log/syslog? It only shows the last 15 lines of the log. Maybe try using tail -f /var/log/syslog. I just tested that and it logged my my simple NSLog(@"LOL"); just fine. I was able to see it via ssh and everything.

Fire30
  • 166
  • 7