471,596 Members | 1,093 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,596 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 3210
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Erich Trowbridge | last post: by
reply views Thread by Stephen Touset | last post: by
1 post views Thread by Gregory Starck | last post: by
8 posts views Thread by Guy Noir | last post: by
2 posts views Thread by greg | last post: by
3 posts views Thread by Troels Arvin | last post: by
1 post views Thread by Lincoln Yeoh | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by Anwar ali | last post: by

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.