Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9113143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:53:59+00:00 2026-06-17T03:53:59+00:00

As we know , we can use ASL (Apple System Logger) API in objective

  • 0

As we know , we can use ASL (Apple System Logger) API in objective C to read logs and also with using asl_search it is possible to retrieve specific application logs.
But the problem is output of asl does not include the time when the log was created.
For example , when you open system.log in directory /var/log with Apple System Logger ,you see logs like this :

Nov 28 09:19:37 localhost bootlog[0]: BOOT_TIME 1354123177 0

But when quering asl with objective C , it reports every attribute of log except the time when the log is created, it means in example mentioned above , asl_search does not report Nov 28 09:19:37
Is there anyway to include time of creating logs with quering asl in objective C?
If this is not possible , what is another approach to retrieving time of logs?


This is my code , note that the time of logs which we can see in system.log files in /var/log does not appear in output of my code .

int main (int argc, const char * argv[])
{

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
aslmsg q, m;
int i;
const char *key, *val;
q = asl_new(ASL_TYPE_QUERY);
asl_set_query(q, ASL_KEY_SENDER, "bootlog", ASL_QUERY_OP_EQUAL);

aslresponse r = asl_search(NULL, q);

while (NULL != (m = aslresponse_next(r)))
{
    NSMutableDictionary *tmpDict = [NSMutableDictionary dictionary];

    for (i = 0; (NULL != (key = asl_key(m, i))); i++)
    {
        NSString *keyString = [NSString stringWithUTF8String:(char *)key];

        val = asl_get(m, key);

        NSString *string = [NSString stringWithUTF8String:val];
        [tmpDict setObject:string forKey:keyString];
    }

    NSLog(@"%@", tmpDict);

}
aslresponse_free(r);

[pool drain];
return 0;

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T03:54:00+00:00Added an answer on June 17, 2026 at 3:54 am

    The timestamp of the log message is the value of the ASL_KEY_TIME key in the message. The value is a UNIX time (seconds since 1.1.1970).

    You can convert the timestamp of the log message to NSDate with

    NSDate *time = [NSDate dateWithTimeIntervalSince1970:(strtod(asl_get(m, ASL_KEY_TIME), NULL))];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I can use System.DirectoryServices to roll my own GAL Name/email selector control
I know you can use (read) to get a user-inputted expression, but (read) will
I know one can use interceptors before a method call by using the @AroundInvoke
I know I can use the following methods of trafficstats api to get bytes
I know I can use the -n flag in git grep to show the
I know you can use -fno-objc-arc flag to disable ARC for files that NOT
I know I can use install-data-hook to do anything I want after my data
I know you can use source control software for source code, but can you
I know I can use the ActionView helper strip_tags method in my views to
I know I can use something like User.sort {|a, b| a.attribute <=> b.attribute} or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.