www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Log rotation in std.logger.filelogger

reply Vitalii <yvitaliy1980 yandex.ru> writes:
Hello!

Please tell me how to enable log rotation in 
std.logger.filelogger? Without log rotation, it seems that the 
std.logger.filelogger is useless, because it will quickly take up 
all the free space on the hard drive.

In theory, you can close the file in the logger, rename it, etc., 
open a new one, but the manual says that this will lead to 
undefined behavior. So how do you rotate the log?

Best regards,
Vitalii
May 17 2023
next sibling parent Kagamin <spam here.lot> writes:
I suppose you write a custom logger for that or take an already 
written one from code.dlang.org
May 22 2023
prev sibling parent reply apz28 <home home.com> writes:
On Wednesday, 17 May 2023 at 21:11:41 UTC, Vitalii wrote:
 Hello!

 Please tell me how to enable log rotation in 
 std.logger.filelogger? Without log rotation, it seems that the 
 std.logger.filelogger is useless, because it will quickly take 
 up all the free space on the hard drive.
Or can try my log package https://github.com/apz28/dlang/tree/main https://github.com/apz28/dlang/tree/main/source/pham/external/std/log log_logger.d RollingFileLogger Happy coding!
May 23 2023
parent reply Andrew <andrewlalisofficial gmail.com> writes:
On Tuesday, 23 May 2023 at 11:21:07 UTC, apz28 wrote:
 On Wednesday, 17 May 2023 at 21:11:41 UTC, Vitalii wrote:
 Hello!

 Please tell me how to enable log rotation in 
 std.logger.filelogger? Without log rotation, it seems that the 
 std.logger.filelogger is useless, because it will quickly take 
 up all the free space on the hard drive.
Or can try my log package https://github.com/apz28/dlang/tree/main https://github.com/apz28/dlang/tree/main/source/pham/external/std/log log_logger.d RollingFileLogger Happy coding!
Please don't take this as an insult, as I've also written my own logging library lol. But I have a feeling that our efforts would be better spent in improving the standard library's implementation rather than making our own logger. Hopefully this will become easier in the future as issues are migrated to github and more effort is put into organization.
May 23 2023
parent reply apz28 <home home.com> writes:
On Tuesday, 23 May 2023 at 13:13:18 UTC, Andrew wrote:
 On Tuesday, 23 May 2023 at 11:21:07 UTC, apz28 wrote:
 On Wednesday, 17 May 2023 at 21:11:41 UTC, Vitalii wrote:
 Hello!

 Please tell me how to enable log rotation in 
 std.logger.filelogger? Without log rotation, it seems that 
 the std.logger.filelogger is useless, because it will quickly 
 take up all the free space on the hard drive.
Or can try my log package https://github.com/apz28/dlang/tree/main https://github.com/apz28/dlang/tree/main/source/pham/external/std/log log_logger.d RollingFileLogger Happy coding!
Please don't take this as an insult, as I've also written my own logging library lol. But I have a feeling that our efforts would be better spent in improving the standard library's implementation rather than making our own logger. Hopefully this will become easier in the future as issues are migrated to github and more effort is put into organization.
D is just a learning project (hobby one) and I do not have time to go through the process to add codes to standard library. However, it is www.boost.org/LICENSE_1_0.txt license so feel free to get it and add it to standard one Cheers
May 23 2023
parent Vitalii <yvitaliy1980 yandex.ru> writes:
On Tuesday, 23 May 2023 at 14:10:52 UTC, apz28 wrote:
 On Tuesday, 23 May 2023 at 13:13:18 UTC, Andrew wrote:
 On Tuesday, 23 May 2023 at 11:21:07 UTC, apz28 wrote:
 [...]
Please don't take this as an insult, as I've also written my own logging library lol. But I have a feeling that our efforts would be better spent in improving the standard library's implementation rather than making our own logger. Hopefully this will become easier in the future as issues are migrated to github and more effort is put into organization.
D is just a learning project (hobby one) and I do not have time to go through the process to add codes to standard library. However, it is www.boost.org/LICENSE_1_0.txt license so feel free to get it and add it to standard one Cheers
Thank you all very much! I'll try to do what you kindly suggested. Vitalii
May 23 2023