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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:25:50+00:00 2026-06-17T09:25:50+00:00

How can I send log messages to Console.app using Xcode and c++? The only

  • 0

How can I send log messages to Console.app using Xcode and c++? The only code I have access to is the c++ source, not Objective-C. Also, other developers in the shop need to be able to follow log messages using the Mac Console app (Console.app), so using the Xcode console is not an option. I’m basically looking for an NSLog(...) alternative. Something simple like that. Thanks.

  • 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-17T09:25:51+00:00Added an answer on June 17, 2026 at 9:25 am

    If you want to write to the system log, you can use syslog() as follows:

    openlog("foo", (LOG_CONS|LOG_PERROR|LOG_PID), LOG_USER);
    syslog(priority, "%s", "a message");
    closelog();
    

    However, I find it more convenient to write to my own log file which can be read by Console.app. This lets me do fancier formatting than syslog() supports, and I also don’t have to hunt for my messages among the many other messages in the system log.

    Here’s how I do this for a program I’ll call “foo”:

    1. Get the current user’s home directory. You can do this by using getuid() and getpwuid() to get the passwd struct, and analyzing the home directory string from that.
    2. Append “/Library/Logs/foo.log” to the home directory string.
    3. Use that as the path argument to fopen() to create a FILE* for the log file.
    4. Then use standard fprintf(), fflush(), etc. calls to write to the log file.
    5. Close the log file at the end of program execution.

    You can see the result of this in Console.app by opening Files > ~/Library/Logs. The file “foo.log” will be there and contain the contents of your logging.

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

Sidebar

Related Questions

How can I send trace messages to the console (like print ) when I'm
How can I test a function like this? app.post '/incoming', (req,res) -> console.log Hello,
I can send requests to friends using Multi Friend Request Selector inside my Page
In Javascript I can send XML string to JSP server (XmlAction.jsp): Javascript Code: var
Using cURL I can send a GET request with a body. Example: curl -i
I have several sites where users can send me email through an html form
I have a program that can send text to any other program for further
Not just faster but better both in speed and using resources/memory. I have an
I have set up so that my app can connect to the Game Center.
Having a XML response like: app.post '/incoming', (req,res) -> console.log Hello, incoming call! message

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.