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}
Community
  • 1
  • 1
hema chandra
  • 402
  • 1
  • 8
  • 29
  • 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 08 '17 at 06: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 – hema chandra Aug 08 '17 at 06:36

1 Answers1

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

Sezin Karli
  • 2,517
  • 19
  • 24
Marcus Bleil
  • 141
  • 1
  • 7
  • Deep link to the documentation of tinylog v2: https://tinylog.org/v2/configuration/#severity-level – koppor Oct 07 '20 at 09:48