Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

The placeholder for the directory in the writer.file property can affect the append attribute. #756

Open
aches opened this issue Aug 27, 2024 · 1 comment
Labels

Comments

@aches
Copy link

aches commented Aug 27, 2024

Describe the bug
When I use System.setProperty("tinylog.directory", path), the append property not works, and the log file gets overwritten every time the application starts.

To Reproduce

writer2          = rolling file
writer2.level    = debug
writer2.file     = #{tinylog.directory}/log_{date:yyyy-MM-dd}.txt
writer2.append   = true
writer2.backups  = 10
writer2.format   = {date: HH:mm:ss.SSS} {level} {class}.{method}():{line}: {message}
writer2.charset = UTF-8
writer2.policies = size: 512mb

java code:
String path = Environment.getExternalStoragePublicDirectory("lb_logs").getPath() + "/"; System.setProperty("tinylog.directory", path);
Environment
tinylog version: 2.7.0
Java version: 11.0.21

@aches aches added the bug label Aug 27, 2024
@pmwmedia pmwmedia added question and removed bug labels Jan 13, 2025
@pmwmedia
Copy link
Member

The rolling file writer does not support the append property. This property is only for the simple file writer. See: https://tinylog.org/v2/configuration/#file-writer

Actually, the rolling file writer should always append the log file until the policies are met.

Please use String path = Environment.getExternalStoragePublicDirectory("lb_logs").getPath(); . The last path separator is redundant.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Development

No branches or pull requests

2 participants