By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,613 Members | 1,890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,613 IT Pros & Developers. It's quick & easy.

How to use syslog() in c to get logging from my program into system logs?

P: 12
How to use syslog() for logging from a my C program
Sep 7 '10 #1
Share this Question
Share on Google+
7 Replies


ashitpro
Expert 100+
P: 542

P: 12
Thanks for the link but i already had a look at this link nd tried the code of the code of the example.
But I cud not figure out where to check if this is working or not.
I am not getting any log information on console when i run my binary with the example code in it.
Sep 7 '10 #3

ashitpro
Expert 100+
P: 542
You will not get anything on console..

Look at the end of "/var/log/messages" (This should be specified in /etc/syslog.conf)
It should go there.

Also make sure that syslog service is started...
Sep 7 '10 #4

P: 12
Thanks yes I found out Its going there.
I restarted the syslog service.
I have to somehow attach my Programs logging levels to the syslog() logging level so that the alerts from my code go into syslog().
Any suggestion on this issue.
Sep 7 '10 #5

ashitpro
Expert 100+
P: 542
I am not sure if I understood you correctly.

Can't you use
syslog (LOG_NOTICE, "My alerts");
in your code, wherever you may require?
Sep 7 '10 #6

P: 12
Thanks I tried it nd It worked this way. :)
But I am still not sure will this suffice my need for the entire log levels in my code but till now its good.
Thanks a lot.
Sep 7 '10 #7

Oralloy
Expert 100+
P: 983
@afrah,

I don't know if your release has the concept of console windows and plain terminal windows.

On my Solaris box, system messages are sent to console windows only - plain terminal windows do not get the messages.

Cheers!
Oralloy
Sep 7 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.