objective c - How do I redirect all errors, including uncaught exceptions, NSLog calls, and other logs, to a log file on Mac OS X? -


i attempting find logging framework cocoa application, written in objc.

what i've attempted far:

  1. use nslog, realise hard configure , redirect. suppose hack , write macro obtains information want, such thread id, current function, current line, current file, current time, message, etcetera, , uses nslog, however...
  2. nslog uses nslogv, uses asl, thought "fantastic", tried using asl instead, default client , context (if doing properly, would've had create new client each thread), however, unless create macro, verbose, , noticed logs sent via asl got broadcast system wide, whereas nslog logged stderr, , want them both go same log!
  3. i noticed errors, formatted in different way (different datestamp, etc), there third logging context.

what l logging framework setup can use have messages logged through framework in convenient fashion if there problem application, developer can log files, , figure out went wrong?

i don't want redirect stderr, want have structured log output contains of logs. don't want logs going standard output, don't want logs sent syslogd, want logs written single file, reliably identifies pertinent information log message (such thread id, message, function called logger, etcetera), in format easy view , visualise.

what want redirect current logs new destination.

does have suggestions?

edit:

effectively, want do, in objc terms is:

  1. do "method swizzling" on nslog function. possible? possible (re)configure use of apple system logger override prior configuration of service within same application?
  2. determine places have catch unhandled exceptions. includes, possibly isn't limited to: unhandled cocoa exceptions. unhandled objc exceptions. unhandled c++ exceptions. unix signals.
  3. catch , log stack errors such raised coregraphics. (the ones log message saying "add breakpoint using debugger!!!").

you can intercept nslog() messages (but not asl in general) using _nssetlogcstringfunction(). it’s documented here webobjects 4 windows, exists in current mac os , ios releases too. however, it’s private function may go away @ time, shouldn’t rely on in released code.

if want able safely non-debug builds, suggest duplicating this enhancement request on radar.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -