Skip to content


Log level per logger #86

erlichmen opened this Issue · 1 comment

2 participants


Is there a way to set the log level per logger? according to the documentation on the main page there should be a way. I couldn't find any reference for that in the code.
I want the console logger to be in verbose while the file in warn level.

Other than write a specific method in the logger class to do that, is there another way?


You can set the filter for each individual logger. And since "a formatter, is a filter, is a formatter" (as I like to say), this actually means:

[logger setLogFormatter:myLoggerFilter];

Your custom filter could be something as simple as this (although you can certainly get fancier with it if you want):

@interface MyLoggerFilter : NSObject <DDLogFormatter>


@implementation MyLoggerFilter

- (NSString *)formatLogMessage:(DDLogMessage *)logMessage
    if (logMessage->logLevel > LOG_LEVEL_WARN)
        // We can filter this message by simply returning nil
        return nil;
        // We could format this message if we wanted to here.
        // But this example is just about filtering.
        return logMessage->logMsg;


For more information see

The above example was lifted from the ContextFilter example in the repository (Xcode/ContextFilter).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.