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 5 3393
Micha? Wo?niak <mikiwoz_remove _this@yahoo_rem ove_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.
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_rem ove_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*docum ented*feature*o f*append*mode*o n 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
Micha? Wo?niak <mikiwoz_remove _this@yahoo_rem ove_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.
One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable ji**@specsol.sp am.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
Micha? Wo?niak <mikiwoz_remove _this@yahoo_rem ove_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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 is to fifo pipe network syslog into a MySQL database backend.
The php scripts reference the database, and print stuff to the screen.
My Info -> RH9.0 , MySQL 4.0.14, apache1.3.28
I have successfully gotten everything installed, compiled, etc....
|
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 between Sinisa Milivojevic and Vincent
Stoessel in which they seemed to indicate that there was no need to log
to syslog. As Vincent only had a request for timestamps in the error
log, Sinisa simply satisfied that demand and moved on.
=20
|
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.
It must be compiled with -lpthread. (so the fork could be also a
possible cause of what I'm mentionning).
The "bug" does not occur every times. So you should maybe launch the
prog a few times before the block occurs.
|
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 enterprise network, I may need to handle a
large number of requests. I assume a thread pool will be needed but I'm
wondering what other advice some of you might have?
Thanks in advance.
|
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
| |
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");
|
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 use syslog instead of / in addition to the
local log files, not only in case of a problem with the local log files.
Is that possible?
|
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 processes.
ideally the CPU utilization has to be only max of 10% not more.
I have used getline() for reading.
I hope u will please provide me a suitable solution.
Thanks
Anjali
|
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 own stderr?
Say I have a program called foo:
#!/usr/bin/python
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |