Julian
Julian

Reputation: 9130

CocoaLumberjack and NSLog in other libraries

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()?

Upvotes: 6

Views: 1206

Answers (2)

Bogdan
Bogdan

Reputation: 101

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.

Upvotes: 1

Matthew Kelling
Matthew Kelling

Reputation: 37

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.

Upvotes: 1

Related Questions