I'm using the Tinylog library with the "rolling file" function to write logs to a file. Sometimes I need to clear a file.
Tried to do it with normal Java methods but it breaks the file and makes it hard to read. Is there a way to clear the log file at any point so it doesn't break?
You can use standard policies for starting new log files at defined events. This is the recommended way.
If you need more flexibility, you can use the
DynamicPolicyfor starting a new log file programmatically. This policy is part of tinylog 2.5. The first milestone is expected to be released during this month and will include this new policy.Configuration:
Start new log file in Java: