How do I programmatically find the user's logging directory?

cocoa, macos, objective-c

Solution

Try this :

NSString* libraryPath = [NSHomeDirectory stringByAppendingPathComponent:@"Library/Logs"];

Update (~/Library/Logs/AppName) :

NSString* bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
NSString* logsPath = [NSString stringWithFormat:@"Library/Logs/%@",bundleName];

NSString* libraryPath = [NSHomeDirectory stringByAppendingPathComponent:logsPath];

Problem

Given an app called ExampleApp, I want to find "~/Library/Logs/ExampleApp" basically without using hard coded paths. There exists NSSearchPathForDirectoriesInDomains, which you can use to find things like "~/Library/Application Support/ExampleApp" using the NSApplicationSupportDirectory search term, but there doesn't seem to be a search term for logging. I don't think ~/Library/Logs is non-standard, since CrashReporter puts its logs there.

Original source