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
OPENLOG(3)								 1								OPENLOG(3)

openlog - Open connection to system logger

SYNOPSIS
bool openlog (string $ident, int $option, int $facility) DESCRIPTION
openlog(3) opens a connection to the system logger for a program. The use of openlog(3) is optional. It will automatically be called by syslog(3) if necessary, in which case $ident will default to FALSE. PARAMETERS
o $ident - The string $ident is added to each message. o $option - The $option argument is used to indicate what logging options will be used when generating a log message. openlog(3) Options +-----------+---------------------------------------------------+ | Constant | | | | | | | Description | | | | +-----------+---------------------------------------------------+ | | | | LOG_CONS | | | | | | | if there is an error while sending data to the | | | system logger, write directly to the system con- | | | sole | | | | | | | |LOG_NDELAY | | | | | | | open the connection to the logger immediately | | | | | | | |LOG_ODELAY | | | | | | | (default) delay opening the connection until the | | | first message is logged | | | | | | | |LOG_PERROR | | | | | | | print log message also to standard error | | | | | | | | LOG_PID | | | | | | | include PID with each message | | | | +-----------+---------------------------------------------------+ You can use one or more of this options. When using multiple options you need to OR them, i.e. to open the connection immediately, write to the console and include the PID in each message, you will use: LOG_CONS | LOG_NDELAY | LOG_PID o $facility - The $facility argument is used to specify what type of program is logging the message. This allows you to specify (in your machine's syslog configuration) how messages coming from different facilities will be handled. openlog(3) Facilities +---------------------------+---------------------------------------------------+ | Constant | | | | | | | Description | | | | +---------------------------+---------------------------------------------------+ | | | | LOG_AUTH | | | | | | | security/authorization messages (use LOG_AUTH- | | | PRIV instead in systems where that constant is | | | defined) | | | | | | | | LOG_AUTHPRIV | | | | | | | security/authorization messages (private) | | | | | | | | LOG_CRON | | | | | | | clock daemon (cron and at) | | | | | | | | LOG_DAEMON | | | | | | | other system daemons | | | | | | | | LOG_KERN | | | | | | | kernel messages | | | | | | | |LOG_LOCAL0 ... LOG_LOCAL7 | | | | | | | reserved for local use, these are not available | | | in Windows | | | | | | | | LOG_LPR | | | | | | | line printer subsystem | | | | | | | | LOG_MAIL | | | | | | | mail subsystem | | | | | | | | LOG_NEWS | | | | | | | USENET news subsystem | | | | | | | | LOG_SYSLOG | | | | | | | messages generated internally by syslogd | | | | | | | | LOG_USER | | | | | | | generic user-level messages | | | | | | | | LOG_UUCP | | | | | | | UUCP subsystem | | | | +---------------------------+---------------------------------------------------+ Note LOG_USER is the only valid log type under Windows operating systems RETURN VALUES
Returns TRUE on success or FALSE on failure. SEE ALSO
syslog(3), closelog(3). PHP Documentation Group OPENLOG(3)
All times are GMT -4. The time now is 05:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy