Reputation: 51
I can't get NSLogger
working in my iOS project, or even in a new empty project.
I was in need of some logging frameworks, and I chose NSLogger
after some comparison because its desktop viewer is exactly what I need.
I use CocoaPod in my project, so the installation is quite simple. Just add one line in the Podfile and running 'pod update' in the console will do.
I followed the instructions in NSLogger
wiki to configure:
First, add LoggerStartForBuildUser()
into the main()
function;
Second, replace NSLog()
with LogMessageCompact()
in my code.
And then I build my project and run it on my iPhone 6 plus(with 8.2 system). My app works fine but I have no log in the console, not a word!
I setup a few break points and make sure the right logging code did execute.
But still nothing happened as if NSLogger
never exists.
I created a brand new empty app project and done the same installation procedure, but still no log was shown.
I really wanna know if I missed anything. Anyone who had come across similar problem like mine?
PS:My development environment is Yosemite + Xcode 6.2
Upvotes: 0
Views: 773
Reputation: 51
Problem solved.
It turns out that the NSLogger cannot connect to the desktop viewer. I had to use LoggerSetViewerHost(NULL,hostname,port) instead of LoggerStartForBuildUser().And It works like a charm.
But every time I restart the desktop viewer, the port will change. So I had to change the port in my code and re-compile. That's a little annoying.
And by default, NSLogger would redirect all the NSLog() to its log buffer. So it's normal to see nothing in the console, unless you use LoggerSetOptions(kLoggerOption_LogToConsole) to force NSLogger to copy all the logs into the console.
Upvotes: 2