32

I'm trying to debug RestKit object mapping and noticed that there are calls to RKLogDebug throughout the code, but it appears that that macro is undefined somewhere. How can I enable it?

Peter DeWeese
  • 18,141
  • 8
  • 79
  • 101
Alex Stone
  • 46,408
  • 55
  • 231
  • 407

2 Answers2

72

You want to add something like this:

    RKLogConfigureByName("RestKit", RKLogLevelWarning); 
    RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace);
    RKLogConfigureByName("RestKit/Network", RKLogLevelTrace);

to your code. See RKLog.h for the various levels. It is pretty trick.

N.B. this supports a wildcard at the end so, e.g.,

    RKLogConfigureByName("*", RKLogLevelTrace); // set all logs to trace,
    RKLogConfigureByName("RestKit*", RKLogLevelWarning); // set all RestKit logs to warning (leaving the app-specific log untouched). 

– Thanks Kevin!

For Swift user use this syntex:

    RKlcl_configure_by_name("RestKit/Network", RKlcl_vTrace.rawValue)  
    RKlcl_configure_by_na`enter code here`me("RestKit/ObjectMapping", RKlcl_vOff.rawValue) 

– Thanks Darshit!

Paul Cezanne
  • 8,629
  • 7
  • 59
  • 90
  • 5
    you are probably the most awesome person in the whole universe, you know? – jturolla Nov 27 '12 at 15:48
  • 3
    N.B. this supports a wildcard at the end so, e.g., `RKLogConfigureByName("*", RKLogLevelTrace);` will set all logs to trace, `RKLogConfigureByName("RestKit*", RKLogLevelWarning);` will set all `RestKit` logs to warning (leaving the app-specific log untouched). – Kevin Oct 16 '13 at 20:34
  • I'd ask that as a new question, you'll probably get better results. (And no, off the top of my head I can't think of any...) – Paul Cezanne Dec 12 '13 at 13:36
  • 1
    RestKit logging explained here http://restkit-tutorials.com/logging-in-restkit-debug-tips/ – Alex Kurkin Jan 02 '14 at 11:09
  • For Swift user use this syntex: `RKlcl_configure_by_name("RestKit/Network", RKlcl_vTrace.rawValue)` `RKlcl_configure_by_name("RestKit/ObjectMapping", RKlcl_vOff.rawValue)` https://stackoverflow.com/questions/31830976/how-to-enable-restkit-logging-in-swift – Darshit Mendapara Aug 26 '21 at 05:30
2

As described in first answer you can configure your app to specific component by calling RKLogConfigureByName.

You can also configure RestKit for specific component using Environment Variables in Xcode scheme. This is useful especially when you have your app building continuously for different environments.

Here's detailed explanation of RestKit logging http://restkit-tutorials.com/logging-in-restkit-debug-tips/

Alex Kurkin
  • 1,069
  • 10
  • 17
  • 1
    hey @Borzh it is available here in archive https://web.archive.org/web/20150706073124/http://restkit-tutorials.com:80/logging-in-restkit-debug-tips – Alex Kurkin Jan 24 '18 at 12:55