Hi,

What is a log file?What is its purpose?How do I open, read and write to log files?

Thanks,
Toms

Recommended Answers

All 2 Replies

A log file is a record of what has happened. On linux/unix they tend to be in /var/log.

As a developer I use them when stuff goes wrong and I want to find out why.

IT use them to keep tabs on things, monitor network use etc.

Web masters use them to spot trends and stuff (often using something to interpret their log files like webalizer).

You write to a log file like any other text file. To read from one just type cat filename.log or tail filename.log .

A useful way of printing the end of a log file and update it when it changes is to use tail -f filename.log .

LOG_FILE=/home/iocca_d/app/logs/logfilename.LOG
exec 1>> ${LOG_FILE}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.