Cocoalumberjack: Change log filenames and path where logfiles where stored

Created on 2 Sep 2013  路  2Comments  路  Source: CocoaLumberjack/CocoaLumberjack

I usually work with log4j and log4cplus and want to define the name of the logfiles and where it was stored. How can i do it ???

Another question :
Is it possible to store the logfiles into the .app package or is it netter to store it in an external folder ?

Thanks in advance.

Most helpful comment

To change path where log file is stored:

NSString* documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
DDLogFileManagerDefault* logFileManager = [[DDLogFileManagerDefault alloc] initWithLogsDirectory:documentsDirectory];
_myLogger = [[DDFileLogger alloc] initWithLogFileManager:logFileManager];
[DDLog addLogger:_myLogger];

This example will store the log file in your app's Documents directory which will be available to iTunes if you enable file sharing via iTunes.

All 2 comments

To change path where log file is stored:

NSString* documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
DDLogFileManagerDefault* logFileManager = [[DDLogFileManagerDefault alloc] initWithLogsDirectory:documentsDirectory];
_myLogger = [[DDFileLogger alloc] initWithLogFileManager:logFileManager];
[DDLog addLogger:_myLogger];

This example will store the log file in your app's Documents directory which will be available to iTunes if you enable file sharing via iTunes.

@memmaker650 and @djschwartz this is the correct approach. Thanks @djschwartz

Was this page helpful?
0 / 5 - 0 ratings