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}
2
  • Are you trying to seperate out your logging by log level (trace, debug, info, warning, error) or by something else (like context or class name)?
    – Taylor Hx
    Aug 8, 2017 at 6:28
  • Yes, I am trying to separate by log level. Or else I am very much open to use any other method . All I want is I need to write error logs into one file and normal logs into other file Aug 8, 2017 at 6:36

1 Answer 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

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.