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 8218287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:44:32+00:00 2026-06-07T12:44:32+00:00

I read this article: http://weakreference.wordpress.com/2011/06/22/overriding-nslog-on-ios/ . The idea of the article is to add

  • 0

I read this article: http://weakreference.wordpress.com/2011/06/22/overriding-nslog-on-ios/.

The idea of the article is to add these two things to the prefix.pch file of your app, so that you can override the behavior of NSLog.

The two things I’m adding are:

#define NSLog(...) customLogger(__VA_ARGS__);

and

void customLogger(NSString *format, ...) {
    va_list argumentList;
    va_start(argumentList, format);
    NSMutableString * message = [[NSMutableString alloc] initWithFormat:format
        arguments:argumentList];

    [message appendString:@"Our Logger!"]; // Our custom Message!
    NSLogv(message, argumentList); // Originally NSLog is a wrapper around NSLogv.
    va_end(argumentList);
    [message release];
}

xCode throws an error match-o error, that it finds duplicates of customLogger.

Has anyone successfully overridden NSLog?

Thanks!

Edit in response to Rob:

Okay, great. We’re making progress! I moved thing just like you asked. Here’s what we have now:

My custom logger:

void customLogger(NSString *format, ...) {

    va_list args;
    va_start(args, format);
    va_end(args);
    [newLogger log:format withArgs:args];
}

//This is a newLogger Method
+ (void) log:(NSString *)format withArgs:(va_list) args{

    NSArray *occ = [format componentsSeparatedByString:@"%@"];

    NSInteger characterCount = [occ count]; 

    NSArray *stringItems = [format componentsSeparatedByString:@"%@"];

    NSMutableString *tmp = [[NSMutableString alloc] initWithFormat: @"%@",[stringItems objectAtIndex:0]];

    for( int i = 1; i < characterCount; i++ ) {
        NSString *value = va_arg(args, NSString *);
        [tmp appendString:value];
        [tmp appendString:[stringItems objectAtIndex:i]];
    }

    // Need to alter the above and actually do something with the args! 
    [tmp appendString:@"\n"];
    [[newLogger sharedInstance].logBuffer appendString:tmp];

    if ([newLogger sharedInstance].textTarget){
        [[newLogger sharedInstance].textTarget setText:sharedInstance.logBuffer];
    }
}

When I call +log, I get a SIBABRT error on Thread 1.

  • 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-07T12:44:34+00:00Added an answer on June 7, 2026 at 12:44 pm

    It sounds like you defined customLogger in your .pch file. That means every .m file includes it, so every .o file your project creates contains its own copy of customLogger. That’s why you get duplicate symbol definition errors from the linker.

    You need to just declare customLogger in the .pch, like this:

    void customLogger(NSString *format, ...);
    

    And create a customLogger.m file containing the definition.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read this article http://codebetter.com/iancooper/2011/10/06/avoid-testing-implementation-details-test-behaviours/ And I am confusing about Code developed in
I just read this article: http://www.acunetix.com/websitesecurity/upload-forms-threat.htm which discusses some of the security risks involved
I have read from this article http://codahale.com/how-to-safely-store-a-password/ and it says using a salt isn't
So I read up this article: http://www.wikihow.com/Plot-the-Mandelbrot-Set-By-Hand But I'm stuck at step 7. I'm
Okay so I read this post http://facebook.stackoverflow.com/questions/10373897/deleting-a-previosly-posted-article-with-opengraph-or-check-if-said-article-has but I'm using the news.reads action type.
Recently, I read this article: http://download.oracle.com/javase/tutorial/extra/generics/wildcards.html My question is, instead of creating a method
I have a silly question. I read this article about std::exception http://www.cplusplus.com/doc/tutorial/exceptions/ On catch
I read this article: http://static.patater.com/gbaguy/day3pc.htm It includes the sentence DON'T EVER CHANGE CS!! But
Recently I've read this article: http://www.smashingmagazine.com/2009/09/25/svn-strikes-back-a-serious-vulnerability-found/ Developers of many popular sites like apache.org, php.net
I read this article here http://www.codeproject.com/KB/web-security/RolesFormsAuthorization.aspx What is the limitation of Membership that would

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.