On 2023-05-31 00:22:11 -0700, ahsan iqbal wrote: > Why we need a log file ?
A log file contains information about what your program was doing. You use it to check that your program was performing as intended after the fact. This is especially useful for tracking down problems with programs which are either long-running or are running unattended. For example, if a user tells me that they were having a problem yesterday evening I can read the log file to see what my program was doing at the time which will help me to pin down the problem. The important part to remember is that a log file will only contain information the program writes. If you didn't think to log some information then it won't be in the log file and you can't look it up afterwards. On the other hand you don't want to log too much information because that might cause performance problems, it might fill up your disks and it will be a chore to find the relevant information in a sea of irrelevant details. So deciding what to log is a bit of an art. > If i read a large text file than how log file help me in this regard? It won't help you with reading the file. However, you might want to log some information about operation, e.g. when you started (log files usually contain time stamps), when you ended, how large the file was, etc. That way you can compare different runs (has the file increased in size over the last month? Was reading especially slow yesterday?). You could also log a status message every once in a while (e.g. every 100 MB or every 100000 lines). That will give you reassurance that the program is working and a rough estimate when it will be finished. Or you can log any other information you think might be useful. hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | h...@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!"
signature.asc
Description: PGP signature
-- https://mail.python.org/mailman/listinfo/python-list