Sponsored Content
Full Discussion: Writing to System Logs
Operating Systems Linux Red Hat Writing to System Logs Post 302751131 by thmnetwork on Thursday 3rd of January 2013 08:28:57 AM
Old 01-03-2013
Well you're not going to reliably write to the log files directly, so you might as well disregard that notion out of hand. If it's a message that's unrelated to mail (for example) and you want it grouped with other email messages, you can just log it with the "mail" facility and let the syslog daemon do with it whatever it does with "mail" logs in general, which means they'll generally end up in the same place.

It's honestly not that difficult. To syslog in python:

Code:
import syslog
syslog.openlog(logoption=syslog.LOG_PID, facility=syslog.LOG_MAIL)
syslog.syslog('Some mail-related log message...')

If you're using regular C then this will be a good reference.

Basically, the whole thing is over with by the third line no matter what language you're writing your program in.
 

9 More Discussions You Might Find Interesting

1. Solaris

system logs' life

How can you control old system logs keep(or storage) time in Solaris ? Is there any method ? it depends on buffer size long or date long ? (1 Reply)
Discussion started by: xramm
1 Replies

2. Shell Programming and Scripting

not able to redirect the logs of a singl date in one system

Hi All, I have around 15 servers. I need to check for the error in /var/adm/messages in 15 servers of current date everyday and log it in one server. rsh is configured in all servers. The command I am using to accomplish this in shell script is rsh <remote sever> grep 'Jun 17'... (2 Replies)
Discussion started by: partha_bhunia
2 Replies

3. AIX

System Logs

Dear Gurus I am running AIX with several users that are using the system, i would like to monitor the commands that are run by these users. Is there a log system that records the commands that are executed by the users??? Any kind of help will be appreciated. Regards Masquerder (6 Replies)
Discussion started by: masquerer
6 Replies

4. Shell Programming and Scripting

Grep yesterday logs from weblogic logs

Hi, I am trying to write a script which would go search and get the info from the logs based on yesterday timestamp and write yesterday logs in new file. The log file format is as follows: """"""""""""""""""""""""""... (3 Replies)
Discussion started by: harish.parker
3 Replies

5. Solaris

logs for system shutdown

I am working on a SUN T2000 machine with Solaris 10 running on it. When I checked the system this morning, I found it to be turned off. The lastreboot command showed that the system had been shut down the previous night. I want to find out how the system was shut down. I have run hardware health... (2 Replies)
Discussion started by: batman727
2 Replies

6. AIX

system logs

good evening all dear all where i can find the system logs in AIX 5.3 (1 Reply)
Discussion started by: thecobra151
1 Replies

7. Solaris

Svc messages flooding the system logs every second

Hi all I have a newly installed Oracle X2-4 server running Solaris 10 x86 with the latest patches. I have one non-global zone configured running an Oracle DB instance. After configuring IPMP failover between two NICs on the server and rebooting I am seeing the /var/adm/messages being flooded... (7 Replies)
Discussion started by: notreallyhere
7 Replies

8. AIX

AIX system logs files

hello, i just want to know logs files for these actions listed below : - User Account Creation - User Account Deletion - Failed and or Successful User Password Changes - Failed Login Activities for all User Users - System Reboot or and shutdown help appreciated... (6 Replies)
Discussion started by: Bolou
6 Replies

9. Shell Programming and Scripting

If I ran perl script again,old logs should move with today date and new logs should generate.

Appreciate help for the below issue. Im using below code.....I dont want to attach the logs when I ran the perl twice...I just want to take backup with today date and generate new logs...What I need to do for the below scirpt.............. 1)if logs exist it should move the logs with extention... (1 Reply)
Discussion started by: Sanjeev G
1 Replies
SYSLOG(3)								 1								 SYSLOG(3)

syslog - Generate a system log message

SYNOPSIS
bool syslog (int $priority, string $message) DESCRIPTION
syslog(3) generates a log message that will be distributed by the system logger. For information on setting up a user defined log handler, see the syslog.conf(5) Unix manual page. More information on the syslog facili- ties and option can be found in the man pages for syslog(3) on Unix machines. PARAMETERS
o $priority -$priority is a combination of the facility and the level. Possible values are: syslog(3) Priorities (in descending order) +------------+------------------------------------+ | Constant | | | | | | | Description | | | | +------------+------------------------------------+ | | | | LOG_EMERG | | | | | | | system is unusable | | | | | | | | LOG_ALERT | | | | | | | action must be taken immediately | | | | | | | | LOG_CRIT | | | | | | | critical conditions | | | | | | | | LOG_ERR | | | | | | | error conditions | | | | | | | |LOG_WARNING | | | | | | | warning conditions | | | | | | | |LOG_NOTICE | | | | | | | normal, but significant, condition | | | | | | | | LOG_INFO | | | | | | | informational message | | | | | | | | LOG_DEBUG | | | | | | | debug-level message | | | | +------------+------------------------------------+ o $message - The message to send, except that the two characters %m will be replaced by the error message string (strerror) corresponding to the present value of errno. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Using syslog(3) <?php // open syslog, include the process ID and also send // the log to standard error, and use a user defined // logging mechanism openlog("myScriptLog", LOG_PID | LOG_PERROR, LOG_LOCAL0); // some code if (authorized_client()) { // do something } else { // unauthorized client! // log the attempt $access = date("Y/m/d H:i:s"); syslog(LOG_WARNING, "Unauthorized client: $access {$_SERVER['REMOTE_ADDR']} ({$_SERVER['HTTP_USER_AGENT']})"); } closelog(); ?> NOTES
On Windows NT, the syslog service is emulated using the Event Log. Note Use of LOG_LOCAL0 through LOG_LOCAL7 for the $facility parameter of openlog(3) is not available in Windows. SEE ALSO
openlog(3), closelog(3). PHP Documentation Group SYSLOG(3)
All times are GMT -4. The time now is 11:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy