[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: 12 ]

[ Next Thread | Previous Thread | Next Message | Previous Message ]

Date Posted: 05:02:54 09/05/08 Fri
Author: Anandan
Subject: Re: How to use Unix syslog in my C/C++ program?
In reply to: prakash 's message, "How to use Unix syslog in my C/C++ program?" on 23:54:46 08/31/08 Sun

If you want to log your information/debug/assertion messages of your C/C++ program, you have to do the following:
1. To log your messages to a file, you have to configure syslog to take the process name of your running program. Your program has to be configured as a user process. syslog is a daemon process that takes its input from "/etc/syslog.conf"

One has to give the level of logging also. For example, if your executable binary program name is 'examplerun'. You might be running the program as ./examplerun. The the process name is 'examplerun'. To get the informational messages of this program, you have to configure in /etc/syslog.conf as given below:

user.info (minimal 2 tab spaces)

Once after above configuration restart syslog using the command:

/etc/init.d/syslog stop ; /etc/init.d/syslog start

2. In your C/C++ program, you should send the log messages
syslog(LOG_NOTICE, "Sum of two integers entered is %d", c);

You may have to include the syslog header file also:

By mentioning user.info in syslog file, we are passing only the informational message mentioned as LOG_NOTICE in our C/C++ program is passed to the log file.

There are some more related to syslog from your application. Please refer the following urls:

[ Next Thread | Previous Thread | Next Message | Previous Message ]


Post a message:
This forum requires an account to post.
[ Create Account ]
[ Login ]
[ Contact Forum Admin ]

Forum timezone: GMT-8
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.