-
-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please, do not lock the log file #36
Comments
The issue is explained upstream: nickbnf#109. File is read from disk for each search and for redrawing. There are performance issues on windows if file is closed and opened each time. File is opened using QFile::open(QIODevice::ReadOnly) and I don't know if one can manage locking that way |
In general Windows allows to open file with delete access. one needs to specify FILE_SHARE_DELETE for CreateFile api call |
(Unrelated) @evandrocoan Which tool are your screenshot from? |
https://jetscreenshot.com/, but it is a paid app. For free there is also http://www.donationcoder.com/software/mouser/popular-apps/screenshot-captor |
@variar did you fix this or just closed? |
@shvez I hope that the problem is fixed. I've changed file opening on Windows to use native CreateFile function with This commit should be in build >= 19.1.0.322 (https://github.com/variar/klogg/releases/tag/continuous-win). It would be great if someone could test this because I don't use follow file feature and changing log files in my daily job. |
UPD: Thanks a lot for this try to make us happy. |
Access denied is generated when one is trying to overwrite file opened in klogg. However, renaming opened file works fine. So one could first rename opened file and after that create a new one with old name. In nickbnf#109 there was a suggestion to add option to actually keep file closed and open it every time some data is required. I'll investigate this solution. |
I added option to keep file closed (see 975c3d7). Can't add ui for it right now, but it should appear in configuration file after closing new version of klogg. After setting The fix is in 19.1.0.233 build. There could be issues with file changing on disk during index being rebuilt or search in progress. Need more testing in real-life scenarios. |
Since version 19.1.0.235 there is an option in advanced settings to keep file closed as much as possible |
@variar That what I wanted!!. Thank you very much The only bug I found is a failure after renaming. If I delete opened file, its page cleaned up. But if I rename the file, then its content still on screen, and I get trash if try to search using window below |
Great news @shvez, thanks for testing this. Looks like right now if new file is larger than old one, then only partial index operation is performed for "appended lines", and everything is trashed. Should not happen when overwriting old file with smaller one (that should be the main scenario for rolling log files?) I'll try to figure out some way to check if new file is really not the same as old one and do full reload (inode checking?) |
In my case, I just renamed a file to something else. Behavior of the tool should be same like file would be deleted |
Issue with simple renaming of opened file should be fixed in 19.1.0.237. Overwriting file with larger one completely unrelated file needs further investigation. |
thank you will check it out soon |
Tested klogg-19.01.0.337-x64-portable.zip : 'Enable Polling' doesn't seem to work. :( |
File monitoring on network shares has not been tested. Seems similar to nickbnf#214. Looks like file monitoring api works with network drives, but only if the remote server supports the functionality. What system are you using as network share server? |
@wiz0u I've moved problems with file monitoring and polling to more appropriate issue. This issue should stay for problems with klogg locking files and preventing other applications access them. |
Ok for moving to a separate issue, but in my opinion the locking issue made the most sense on network shares where multiple users can view the file through glogg/klogg and possibly prevent daily rolling/archiving/deleting. It is worse than a purely local issue because you cannot tell all users to close their log viewer before going home. |
I've a feeling that polling could be locking file for brief period (to get current size and modification time). This might still be breaking rolling logs in rare cases. Randomizing polling time so file is not accessed on "round" time (e.g. at the start of a minute) could help to further reduce locking possibility. |
On the other hand polling timer start time is already random. Will close for now. |
I use the Python
logging
module RotatingFileHandler https://docs.python.org/2/library/logging.handlers.html#rotatingfilehandlerWhich renames the log file
file.log
tofile.log.1
when it reaches a maximum size like 50MB, however if I am viewing the log file with this tool, the operation fails because the file is locked byThe text was updated successfully, but these errors were encountered: