473,383 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Syslog vs file

Hi again

The Question of Logs, part II. :)

What are the advantages/disadvantages of using syslog() to do the logging
rather than writing the logs with fopen(), fwrite() and fclose()? What
should be kept in mind while using either technique? And, of course,
which is considered to be the better one?

TIA
Mike
Jul 17 '05 #1
5 3358
Micha? Wo?niak <mikiwoz_remove_this@yahoo_remove_this.co.uk> wrote:
The Question of Logs, part II. :)

What are the advantages/disadvantages of using syslog() to do the logging
rather than writing the logs with fopen(), fwrite() and fclose()?
It well tested, distributed (if need/want to) and "thread safe".
What should be kept in mind while using either technique? And, of
course, which is considered to be the better one?


You oblivous forgot locking.

Jul 17 '05 #2
One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable Daniel Tryba's handwriting:
Micha? Wo?niak <mikiwoz_remove_this@yahoo_remove_this.co.uk> wrote:
The Question of Logs, part II. :)

What are the advantages/disadvantages of using syslog() to do the
logging rather than writing the logs with fopen(), fwrite() and
fclose()?
It well tested, distributed (if need/want to) and "thread safe".
What should be kept in mind while using either technique? And, of
course, which is considered to be the better one?


You oblivous forgot locking.


Well, Malcolm wrote in the previous thread (sorry for a long quote):
Assuming you are on Linux or Unix. Open the log file for append, and write entire lines at a time, no
locking is required (note append mode, that's the key). Up to a large size, (something like 64,000 bytes typical) each such
line is guaranteed to be written as a single atomic unit to the end of
the file, no locking required.
This*is*a*documented*feature*of*append*mode*on unix, and is done
exactly for this kind of situation. (In practise you rarely even have to write whole lines at a time,
because the program's file write will normally buffer your output and
write it one line at a time even if you don't do that part explicitly
your self.)"


So I suppose The File Way is as "thread-safe" (when opened in append
mode, that is) and I don't need locking anyway. Am I missing something?

Cheers
Mike
Jul 17 '05 #3
Micha? Wo?niak <mikiwoz_remove_this@yahoo_remove_this.co.uk> wrote:
Hi again The Question of Logs, part II. :) What are the advantages/disadvantages of using syslog() to do the logging
rather than writing the logs with fopen(), fwrite() and fclose()? What
should be kept in mind while using either technique? And, of course,
which is considered to be the better one? TIA
Mike


If the file system starts to fill up, most implementations of syslog
stop logging rather than bringing the system to a screeching halt.

Most implementations of syslog come with utilities to periodically
compress, remove, or backup syslog files.

It is trivial to change the level of logging while executing with
syslog.

Where the syslog files are and how to deal with them is already
documented by the system documentation and already known by
administrators.

Numerous utilities exist to get reports out of syslog.

It is trivial with syslog to log the pid, program name, time, any
system error messages and exact line which caused the log entry.

Reinventing the wheel is poor form.

--
Jim Pennino

Remove .spam.sux to reply.
Jul 17 '05 #4
One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable ji**@specsol.spam.sux.com's handwriting:
If the file system starts to fill up, most implementations of syslog
stop logging rather than bringing the system to a screeching halt.

Most implementations of syslog come with utilities to periodically
compress, remove, or backup syslog files.

It is trivial to change the level of logging while executing with
syslog.

Where the syslog files are and how to deal with them is already
documented by the system documentation and already known by
administrators.

Numerous utilities exist to get reports out of syslog.

It is trivial with syslog to log the pid, program name, time, any
system error messages and exact line which caused the log entry.

Geez, lots of it. Fine, I am convinced, thanks.
Reinventing the wheel is poor form.


However I do consider re-inventing the wheel sometimes useful - such a
learing project like the one I am actually working on right now is
enough for an example.

But I will stick to syslog to do the logging. Too many advantages. :)

Thanks again
Mike
Jul 17 '05 #5
Micha? Wo?niak <mikiwoz_remove_this@yahoo_remove_this.co.uk> wrote:
[snip]
You oblivous forgot locking.
Well, Malcolm wrote in the previous thread (sorry for a long quote):
Assuming you are on Linux or Unix.

Open the log file for append, and write entire lines at a time, no
locking is required (note append mode, that's the key).

[snip] So I suppose The File Way is as "thread-safe" (when opened in append
mode, that is) and I don't need locking anyway. Am I missing something?


It appears to be true indeed.

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Erich Trowbridge | last post by:
Has anybody seen this tool? It is awesome. check out http://vw.vermeer.org/ . It's a php front end for large-scale syslog deployments. It makes managing syslog in large networks a snap. The idea...
0
by: Stephen Touset | last post by:
--=-vqiBeaRpc7WKjfgJmDzK Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Is there now a way within MySQL to log to syslog? I was reading an archived email conversation...
1
by: Gregory Starck | last post by:
Hello, I'm having what seems to be a deadlock in syslog with the code (wich comes from a project I'm working on, but I've reduced the test case to its minimum) I put at the end of this messsage....
8
by: Guy Noir | last post by:
Hello. I am needing some advice. I need to build a syslog server that writes to a sql backend. I am concerned about the server not being able to handle multiple requests. For example on an...
2
by: greg | last post by:
Hi All, Could anyone tell me how I could syslog to a specific log (e.g. /var/ log/daemon.log, /var/log/syslog.log...)? Thanks very much in advance! -Greg
7
by: johnhelen | last post by:
hello In a perl script for a cronjob, there is a function: sub _write_sys_log { my $seft = shift; my $level = shift; my $string = shift; syslog($level, '%s', "$string");
3
by: Troels Arvin | last post by:
Hello, On a server with DB2 v. 8.2, db2diag.log ran full, it seems (i.e. reached a size of 2GB). And it seems that in this case, DB2 started using syslog instead. I would actually like DB2 to...
1
by: anjaliraman2 | last post by:
Hi All, I am facing a problem of writing into and reading from syslog in Linux Enviornment using C++. The CPU utilization is extremely high of about 55% and is creating problems for other...
1
by: Lincoln Yeoh | last post by:
Hi, I've just started to learn python (I've been using perl for some years). How do I redirect ALL stderr stuff to syslog, even stderr from external programs that don't explicitly change their...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.