Skip to content
Advertisement

Tinylog Android, is it possible to clear the file?

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?

Advertisement

Answer

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 DynamicPolicy for 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:

writer          = rolling file
writer.file     = foo.log
writer.policies = dynamic

Start new log file in Java:

DynamicPolicy.setReset();
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement