6

I'm using CocoaLumberjack for all the logging in my app. Using this I can log straight to a file by using DDLogVerbose(...) or any of the available variants.

I'm also using fmdb (SQLite wrapper). The problem is that this library uses NSLog() and none if its output ends up on my log file.

Is there a way to capture NSLog's output and redirect it to CocoaLumberjack's? Or if that's not possible, just "rewrite" NSLog() so that it actually executes DDLogVerbose()?

oguz ismail
  • 1
  • 16
  • 47
  • 69
Julian
  • 8,808
  • 8
  • 51
  • 90

2 Answers2

1

Try adding

#define NSLog DDLogInfo

to the top of the other libraries. Of course you will need to

#include "Logging.h"

for it to work.

  • Thank you! This works great for my own NSLog statements, but not for Apple's log statements. – John Jul 24 '15 at 19:03
1

This may work, but it could also create an infinite loop since CocoaLumberjack is using NSLog, so a redefinition with DDLogInfo could mess things up. You just need to try and see.

Bogdan
  • 101
  • 2