
What is rolling file adaptor for tinylog?
The rolling file writer or adaptor is a tinylog’s writer which writes logs to rolling files. It keeps rotating files and you will have latest log files as per your configuration.
Let’s get started:
Step-1. Make sure you follow tinylog’s HelloWorld tutorial
Here is a link:
Step-2. Modify tinylog.properties file
writerCrunchifyRollingFile = rolling file
writerCrunchifyRollingFile.level = info
writerCrunchifyRollingFile.format = {date: HH:mm:ss.SSS} {level}: {message}
writerCrunchifyRollingFile.file = logs/crunchifyLog_{count}.log
writerCrunchifyRollingFile.latest = logs/crunchifyLog.log
writerCrunchifyRollingFile.charset = UTF-8
writerCrunchifyRollingFile.buffered = false
writerCrunchifyRollingFile.policies = startup, daily: 00:00, size: 1mb
writerCrunchifyRollingFile.backups = 100
writerCrunchifyRollingFile.convert = gzip
Here are all tinylog’s placeholders:
| Placeholder | Description |
|---|---|
| {count} | Consecutive number, starting with “0” |
| {date} | Current date and time. Optionally there can be a custom date format pattern such as “{date: HH:mm:ss.SSS}”. The date format pattern is compatible with SimpleDateFormat and on Java 9 (or higher), also with DateTimeFormatter that supports milliseconds and nanoseconds. The default date format pattern is “yyyy-MM-dd_HH-mm-ss”. |
| {pid} | Process ID of the application |
Here are all tinylog’s policies:

Step-3. Write program to generate logs
- Create class CrunchifyTinyLogRollingFileWriter.java
package crunchify.com.java.tutorials;
import org.tinylog.Logger;
/**
* @author Crunchify.com
* Program: tinylog Rolling File Writer example
*
*/
public class CrunchifyTinyLogRollingFileWriter {
public static void main(String[] args) {
// create hello x 3 per line
String crunchifyRecord = "Howdy Cruncher! This is App Shah and welcome to Tinylog Tutorial! - INFO Log Level! ";
crunchifyRecord = crunchifyRecord + crunchifyRecord;
System.out.println(crunchifyRecord);
int crunchifyCounter = 0;
while (crunchifyCounter < 50000) {
Logger.info(crunchifyRecord + crunchifyCounter);
crunchifyCounter++;
}
System.out.println("Completed");
}
}
Step-4. Run above program to generate logs
Eclipse / IntelliJ IDEA console result.
Howdy Cruncher! This is App Shah and welcome to Tinylog Tutorial! - INFO Log Level! Howdy Cruncher! This is App Shah and welcome to Tinylog Tutorial! - INFO Log Level! Completed Process finished with exit code 0
Step-5. Verify rolling file logs

