Home > other >  Tinylog Android, is it possible to clear the file?
Tinylog Android, is it possible to clear the file?

Time:02-23

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?

CodePudding user response:

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 DynamicNamePolicy 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 name

Start new log file in Java:

DynamicNamePolicy.setReset();
  • Related