| Caching Strategy Employed by Log4Web |
|
Log4Web does not read the log file each time that a request is made to view the messages. This approach would give poor performance. The messages are cached in memory so that they may be processed faster. This section describes the caching strategy that is used, and the options available for tuning the perormance of the application. On initialisation, Log4Web will read the list of files and directories in the messagesPath parameter, and expand this to a list of log files. It will store this list in memory, and periodically refresh the list by searching the disk for any new or deleted files. This means that the list of message files shown in the filter selection page may be slightly out of date with respect to the files on disk. The frequency of the refresh is controlled by an initialisation parameter as described here. Frequent refreshing may lead to performance problems with the application, depending on the number of files on the messagesPath, and the speed of access to the disk. (If the disk is remote from the web server then the access speed is likely to be slower.) Log4Web uses a lazy caching algorithm when reading the contents of the message files. A file will only be read when a user has requested to view the messages in that file. At this point, Log4Web will store the messages in memory. It will periodically re-read the file to search for new or deleted messages. The frequency of the refresh is controlled by an initialisation parameter as described here. Again, frequent refreshing may lead to performance problems with the application, depending on the size of the messages file, and the speed of access to the disk. On the other hand, new messages that are written to a log file will only appear on the Log4Web output when this refresh occurs. Finally, Log4Web will manage the size of its messages cache, by removing messages from the cache when the memory consumption nears the limit. Messages are removed on a least-recently used basis. |