954,193 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Handling log files in UNIX

Hi,

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

Thanks,
Toms

titotoms
Newbie Poster
2 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

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 .

pty
Posting Pro
530 posts since Oct 2005
Reputation Points: 64
Solved Threads: 39
 

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

Lalchand Saini
Newbie Poster
1 post since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You