howto wirte unix solaris syslog?

i have got a c code running on a unix os.
i have also personal log files. example a.log
in my program i want to write some of my logs to unix (var/log/syslog) and some to a.log
if (a=1)
write syslog
else
write alog.
something like this
can anyone help me , it should be a c program
230409Asked:
Who is Participating?
 
omarfaridCommented:
0
 
gheistCommented:
see "man logger"
normally as simple as:
logger "Process started?"
dosomething
logger "Proccess finished!"
0
 
ewest02Commented:
logger is useful for testing that you have the syslog.conf file setup appropriately.

Calling syslog programmatically...

openlog( message_id_string, flags, facility);
syslog( priority, message_string);
closelog();

Example:
     openlog( "My Test Program", LOG_NDELAY, LOG_LOCAL0); // no delay in logging; user local facility
     syslog( LOG_INFO, "This is my message");                             // LOG_INFO priority
     closelog();

The syslog.conf may need to be adjusted as appropriate to enable logging of your messages.

  --Eric
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.