Entries
Entries are the crux of the timber logging system. Entries are objects that are generated by loggers and
dispatched by dispatchers. You can think of them as lines in a log file. That’s what they almost
always end up turning into (unless they’re deemed uninteresting and dropped, that is). Even though they normally get
written into an application log file, depending on your configuration, they could be processed in other ways. It all
depends on your logging backend. As a consumer of the timber API, this doesn’t concern you. Your job is to generate
rich entries and let someone else filter and route them to wherever they want. As a consumer of the timber backend,
you’ll want to understand how to filter and route entries based on their fields.
The only fields that entries always have are a timestamp and a thread name. Everything else is optional. Some of
the data contained in them comes from the parameters on the logger’s method calls. Some comes from the logger itself.
The rest comes from the context in which the entry is constructed. That’s normally the context in which a logger
method is called.
timestamp
type |
Long |
source |
context |
description |
The the time at which the entry was created, in milliseconds since the UNIX epoch. |
threadName
type |
String |
source |
context |
description |
The the name of the thread that created the entry. |
message
type |
Option[ Message ] |
source |
method parameter |
description |
The text content of the entry which may contain multiple lines. |
level
type |
Option[ Level ] |
source |
method parameter |
description |
The relative importance of this log entry. In other logging systems, this is often known as “severity.” |
sourceLocation
type |
Option[SourceLocation] |
source |
context |
description |
The file name and line number in the source code at which the entry was created. This is automatically captured by timber at compile time using a macro. |
loggingClass
type |
Option[String] |
source |
context |
description |
The name of the class from which the entry was created. It will be empty if there is no containing class. This is automatically captured by timber at compile time using a macro. |
loggingMethod
type |
Option[String] |
source |
context |
description |
The name of the method from which the entry was created. It will be empty if there is no containing method. This is automatically captured by timber at compile time using a macro. |
type |
Option[ Tag ] |
source |
context + method parameters |
description |
The tags associated with the entry. This is the union of the tags associated with the logger when it was constructed and tags specified as parameters to the logging call. |
loggerAttributes
type |
Map[String,Any] |
source |
context |
description |
The attributes of the logger that created the entry. |
threadAttributes
type |
Map[String,List[String]] |
source |
context |
description |
The attributes of the thread that created the entry. |