I was just curious to know the difference between normal file write and logging. Of course logging is used to record exceptions, errors, installation details and other important data. But this can be done using a normal file write also. I’ve seen logging use locks for resource sharing (in java). Other than that is there any particular or very important reason behind using logging?
Share
Logging is writing data to some stream to keep a record of events that occur in an application. Note that you don’t necessarily have to log to a file. You can log to a console, for example.
Some applications require an “Audit Log” of user activity in the system. This is a case where logging is fulfilling a very specific business requirement.
Note you can write to a file and NOT be logging. If you use the presence of a file to create a lock for a process, for example, you have written to a file, but you are not logging.
In general though, logging is just writing event data somewhere. “started up”, “entered method x”, “exception occurred” are all events. I think that really what defines a “log” vs a file with different semantics.