asl_log not logging on iOS 6.x (on device)

Originator:craig
Number:rdar://14461599 Date Originated:17/07/2013
Status:Open Resolved:
Product:iOS SDK Product Version:6.1
Classification:Data loss Reproducible:Always
 
Summary:
I've been working on storing some logging info using ASL in our iPhone app, and have come across a problem where my ASL search just doesn't seem to be able to find records that I have previously logged using asl_log(). At its most basic level, this is the code I am using:

        const char *facility = "blah";
        NSString *message = @"hi there";

        // write an entry
        aslmsg msg = asl_new(ASL_TYPE_MSG);
        asl_set(msg, ASL_KEY_FACILITY, facility);
        asl_log(NULL, msg, ASL_LEVEL_CRIT, [message UTF8String], nil);
       
        // try to read
        aslmsg query = asl_new(ASL_TYPE_QUERY);
        asl_set_query(query, ASL_KEY_FACILITY, facility, ASL_QUERY_OP_EQUAL);
        aslresponse response = asl_search(NULL, query);
        while (NULL != (msg = aslresponse_next(response))) {
            const char *m = asl_get(msg, ASL_KEY_MSG);
            NSLog(@"XXX %s", m);
        }
        NSLog(@"Done");


If I run this code on Mac OS X or in the simulator, it works perfectly.  If I run it on my device, no entries are output (other than the "Done" at the end).

Note that I am not attempting to read entries written by other applications.  I am attempting to read back my own log entries.


Steps to Reproduce:
Execute the above snippet of code in an application running on a device.

Expected Results:
The application should display:
  XXX hi there
  Done

Actual Results:
The application displays:
  Done

Regression:

Notes:
I posted a question on the dev forums about this, and had several others also saying they had the same problem.  I got some good feedback from Quinn (DTS) saying that ASL probably isn't a good choice for logging due to some undocumented differences between platforms (I've raised a documentation radar - 14461411), however, I haven't seen any statements saying that asl_search shouldn't actually work within the confines of the limitations that Quinn spells out.

Note that I've classified as Crash/Hang/Data Loss.  It doesn't actually Crash or Hang, but we definitely lose data.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!