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.h(3HEAD) 						      Headers							   syslog.h(3HEAD)

NAME
syslog.h, syslog - definitions for system error logging SYNOPSIS
#include <syslog.h> DESCRIPTION
The <syslog.h> header defines the following symbolic constants, zero or more of which can be OR'ed together to form the logopt option of openlog(): LOG_PID Log the process ID with each message. LOG_CONS Log to the system console on error. LOG_NDELAY Connect to syslog daemon immediately. LOG_ODELAY Delay open until syslog() is called. LOG_NOWAIT Do not wait for child processes. The following symbolic constants are defined as possible values of the facility argument to openlog(): LOG_KERN reserved for message generated by the system LOG_USER message generated by a process LOG_MAIL reserved for message generated by mail system LOG_NEWS reserved for message generated by news system LOG_UUCP reserved for message generated by UUCP system LOG_DAEMON reserved for message generated by system daemon LOG_AUTH reserved for message generated by authorization daemon LOG_CRON reserved for message generated by clock daemon LOG_LPR reserved for message generated by printer system LOG_LOCAL0 reserved for local use LOG_LOCAL1 reserved for local use LOG_LOCAL2 reserved for local use LOG_LOCAL3 reserved for local use LOG_LOCAL4 reserved for local use LOG_LOCAL5 reserved for local use LOG_LOCAL6 reserved for local use LOG_LOCAL7 reserved for local use The following is declared as a macro for constructing the maskpri argument to setlogmask(). The following macro expands to an expression of type int when the argument pri is an expre ssion of type int: LOG_MASK(pri) a mask for priority pri The following constants are defined as possible values for the priority argument of syslog(): LOG_EMERG A panic condition was reported to all processes. LOG_ALERT A condition that should be corrected immediately. LOG_CRIT A critical condition. LOG_ERR An error message. LOG_WARNING A warning message. LOG_NOTICE A condition requiring special handling. LOG_INFO A general information message. LOG_DEBUG A message useful for debugging programs. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
syslog(3C), attributes(5), standards(5) SunOS 5.11 10 Sep 2003 syslog.h(3HEAD)
All times are GMT -4. The time now is 07:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy