Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 438
  • Last Modified:

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
0
230409
Asked:
230409
3 Solutions
 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now