I'm using the Python logging module. Each time I open the log file I have to scroll all the way down to read the latest entries. Is there a way I can make the logger prepend entries to the beginning of file?
This is not possible through the logger. If you want this, you'll have to write your own custom logger, read all the entries in the log file, add the new entry to the top, then write the entire log file again.
I concur with others: prepending to a file is costly, and making your code more complex than it should be. If you view your log using tools such as more or less, then press the capital G key will bring you all the way to the end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With