1

I am using tinylog for various features it has. My application needs a very fast asynchronous logging. I can able to log happily. I have only two issues.

1) All my error logs and the info, some debug logs are jumbled into a single file. How can I separate these, such that they come into a single file say "errors.log" and info strings come into another file say "messages.log"?

2) I want the timestamp to be in microseconds that mean like, data: Time in "HH:mm:ss:milli-seconds:Micro-seconds". Is there any way to do?

This is my properties file:

tinylog.writer = rollingfile
tinylog.writer.filename = MessageLogs.txt
tinylog.writer.backups = 1
tinylog.writer.label = timestamp
tinylog.writer.policies = daily, size: 1000KB
tinylog.writingthread = true
tinylog.writingthread.observe = null
tinylog.writingthread.priority = 2
tinylog.format = {date:yyyy-MM-dd HH:mm:ss:sss}  {class}.{method}()\n{level}: {message}
4

1 回答 1

3

it is not possible in the way you want, as you can see in documentation "If multiple writers are used, it is possible to define particular logging formats for them. In that case, these writers will only output log entries with the defined logging level or higher."

example from documention:

tinylog.writer1 = file
tinylog.writer1.level = trace
tinylog.writer1.filename = log_trace.txt
tinylog.writer2 = file
tinylog.writer2.filename = log_error.txt
tinylog.writer2.level = error

for microseconds you need tinylog 1.3 an Java 9 and https://docs.oracle.com/javase/9/docs/api/java/time/format/DateTimeFormatter.html and http://www.tinylog.org/configuration#format

于 2017-12-01T14:37:59.473 回答