tinylog2 makes error log but does not make or maintain debug log

19 views Asked by At

I'll paste in my tinylog.properties below. The file structure is this:

/project/
/project/src/main/resources/tinylog.properties
/project/logs/debug/
/project/logs/error/

The properies:

writer       = rolling file
writer.file  = logs/debug/debug_{date: yyyy-MM-dd}_{count}.log
writer.charset  = UTF-8
writer.buffered = true 
writer.backups  = 100
writer.convert  = gzip 
writingthread = true
writer.level = debug
writer.format = {date: HH:mm:ss.SSS} {class}.{method}() {level}: {message}

writer       = rolling file
writer.file  = logs/error/error_{date: yyyy-MM-dd}_{count}.log
writer.charset  = UTF-8
writer.buffered = true 
writer.backups  = 100
writer.convert  = gzip 
writingthread = true
writer.level = error
writer.format = {date: HH:mm:ss.SSS} {class}.{method}() {level}: {message}

There are plenty of Logger.debug statements and a few Logger.error lines in the code. Even though no error fired, an error.log file is made. Many Logger.debug statements had to fire, but no debug.log was made. I'm confused. Thanks in advance for ideas.

I ran the system with a variety of tinylog.properties ideas, the latest being reflected in the tinylog examples.

Someone in a closed tinylog issue put properties in main/java/tinylog.properties. I now have it in both. No change.

1

There are 1 answers

0
Martin On

As JackPark mentioned, all writer keys must be unique to meet the properties file standard. Otherwise you overwrite existing writer settings.

The correct properties file would be:

writer1       = rolling file
writer1.file  = logs/debug/debug_{date: yyyy-MM-dd}_{count}.log
writer1.charset  = UTF-8
writer1.buffered = true 
writer1.backups  = 100
writer1.convert  = gzip 
writer1.level = debug
writer1.format = {date: HH:mm:ss.SSS} {class}.{method}() {level}: {message}

writer2       = rolling file
writer2.file  = logs/error/error_{date: yyyy-MM-dd}_{count}.log
writer2.charset  = UTF-8
writer2.buffered = true 
writer2.backups  = 100
writer2.convert  = gzip 
writer2.level = error
writer2.format = {date: HH:mm:ss.SSS} {class}.{method}() {level}: {message}

writingthread = true

There are plenty of Logger.debug statements and a few Logger.error lines in the code. Even though no error fired, an error.log file is made.

This is as designed as tinylog creates the log files already at startup to ensure that the filesystem is writable.