Confused as to the point of addLogger:withLogLevel and then having to set the log level.

50 views
Skip to first unread message

Sheffield Kevin

unread,
Mar 15, 2014, 1:39:47 PM3/15/14
to cocoalu...@googlegroups.com
I'm probably missing something obvious. I've set up logging like so:

#ifdef DEBUG

    [DDLog addLogger:[DDTTYLogger sharedInstance] withLogLevel:LOG_LEVEL_DEBUG];

#endif

    // Create the file logger.

    DDFileLogger *fileLogger = [[DDFileLogger alloc] init];

    

    // We only want to roll the log file when it reaches it's maximum size.

    // We don't want to roll the log file after some time interval.

    // I'm using the default maximum size of 1MByte.

    fileLogger.rollingFrequency = 0;

    

    // Only keep the last three log files. 

    fileLogger.logFileManager.maximumNumberOfLogFiles = 3;

    [DDLog addLogger:fileLogger withLogLevel:LOG_LEVEL_INFO];


But I don't really understand why I still need to set ddLogLevel. I've set the log levels I want for the two different loggers. If I set ddLogLevel for the application or on a per file base won't that then override the log levels I've set for each of the different loggers?

Kevin

Bogdan Poplauschi

unread,
May 26, 2014, 2:25:19 AM5/26/14
to cocoalu...@googlegroups.com
Hi Kevin,

The ddLogLevel is a setting per application.
The log level for each logger allows you to customise which logs are logged by each logger / filter logs from a certain logger. In practice, this setting overrides the global ddLogLevel for that specific logger.

Let me give an example:
- let's say ddLogLevel = LOG_LEVEL_DEBUG; and you use 2 loggers: DDTTYLogger with LOG_LEVEL_DEBUG and DDFileLogger with LOG_LEVEL_INFO
- in this case, the DDLogDebug statements will not output in the file, just inside TTY

Does this make sense?
Reply all
Reply to author
Forward
0 new messages