How to write code for a Logging Event?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to write code for a Logging Event?
# 1  
Old 12-04-2011
How to write code for a Logging Event?

How do I know what parts of the application to monitor and what means do I use to get this data? Can I use proc? What interactions are important and how do I view them?I would be more descriptive but I have not a clue.

Thanks in advance!Smilie
# 2  
Old 12-04-2011
Here is some information on how to use /proc to look at a process:

Exploring procfs LG #115

Not sure if this helps, but post some more specifics on what you need.
This User Gave Thanks to dude2cool For This Post:
# 3  
Old 12-04-2011
wat kind if logging events are u looking for? i just perfected a logwatch to monitor everything in /var/log/* n it emails u daily reports (if u have sendmail already setup)

have a look at the link below if that helps...

https://www.unix.com/suse/171792-last-login-log.html

Last edited by hedkandi; 12-05-2011 at 09:50 AM.. Reason: typo
This User Gave Thanks to hedkandi For This Post:
# 4  
Old 12-05-2011
Thanks for the Replies!

I'm looking for the ins and outs of how Logging Events are created. I have read that with applications logs,the programmer writes code that creates the data that is sent to a separate log application. How do I go about coding events? What events are important? What tools do I use to monitor the running application? Smilie
# 5  
Old 12-05-2011
hmm u sound very confused. from my understanding usually almost all appcomes with their ownn logging. all the logs in /var/log/* are important. if u want to know how these logs are set, check /etc/logrotate.d/*

almost a the logs there are all important

i doubt u will get much gelp unless u provide some detailed info

Smilie
# 6  
Old 12-05-2011
When a programmer writes an application, they include code that generates data so it can be sent to the log files to help determine why the application crashed or hung.
# 7  
Old 12-05-2011
Still think you're overthinking this. It can be as simple as using stdout and stderr:

Code:
printf("handling event...\n"); //stdout

if(error)
{
        fprintf(stderr, "Something we couldn't fix happened!  Error %d\n", 32); // stderr
        exit(1);
}

Code:
./myapplication > /path/to/access.log 2> /path/to/error.log

Or if you want you can use syslog (see man 3 syslog) :

Code:
#include <syslog.h>
#include <stdarg.h>


...

openlog("myprogram", LOG_PID, LOG_DAEMON);

...

syslog(LOG_DEBUG, "Hello, something happened!  Error %d", 32);
exit(1);

Though you can no longer control what file it goes into from your appplication, that's up to the system logger.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Linux

Syslog not logging successful logging while unlocking server's console

When unlocking a Linux server's console there's no event indicating successful logging Is there a way I can fix this ? I have the following in my rsyslog.conf auth.info /var/log/secure authpriv.info /var/log/secure (1 Reply)
Discussion started by: walterthered
1 Replies

2. Shell Programming and Scripting

Logging success event into file

Hi, I've the following code to log the errors any after the command is executed. # Ksh 88 Version log_path=/home/etc/fls/fls_log.log del_path=/home/etc/fls/to_day rm $del_path/* >> $log_path 2>&1 But I even want to log if the rm command is success without any error along with... (1 Reply)
Discussion started by: smile689
1 Replies

3. Shell Programming and Scripting

Event logging to file and display to console | tee command is not able to log all info.

My intention is to log the output to a file as well as it should be displayed on the console > I have used tee ( tee -a ${filename} ) command for this purpose. This is working as expected for first few outputs, after some event loggin nothing is gettting logged in to the file but It is displaying... (3 Replies)
Discussion started by: sanoop
3 Replies

4. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

5. UNIX for Dummies Questions & Answers

How does Unix write events into event log?

Hi to everyone. I'm new to this forum and also pretty new to Unix. I'm developing a cross-platform software and I need to register informational and error messages into the event log of the system. Under Windows, this is implemented so far, I need to implement it unded Unix by now. I do know that... (7 Replies)
Discussion started by: mariano_donati
7 Replies
Login or Register to Ask a Question