Include host and port in mdc if clustered or remote #28073

This commit is contained in:
Johan Andrén 2019-11-28 11:35:11 +01:00 committed by GitHub
parent 38c938124e
commit 4588a3904f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 199 additions and 40 deletions

View file

@ -401,7 +401,7 @@ With Logback the actor path is available with `%X{akkaSource}` specifier within
</encoder>
```
The actor system in which the logging was performed is available in the MDC with attribute name `sourceActorSystem`,
The actor system name in which the logging was performed is available in the MDC with attribute name `sourceActorSystem`,
but that is typically also included in the `akkaSource` attribute.
With Logback the ActorSystem name is available with `%X{sourceActorSystem}` specifier within the pattern layout configuration:
@ -411,9 +411,20 @@ With Logback the ActorSystem name is available with `%X{sourceActorSystem}` spec
</encoder>
```
Akka's internal logging is asynchronous which means that the timestamp of a log entry is taken from
The address of the actor system, containing host and port if the system is using cluster, is available through `akkaAddress`:
```
<encoder>
<pattern>%date{ISO8601} %-5level %logger{36} %X{akkaAddress} - %msg%n</pattern>
</encoder>
```
For typed actors the log event timestamp is taken when the log call was made but for
Akka's _internal_ logging as well as the classic actor logging is asynchronous which means that the timestamp of a log entry is taken from
when the underlying logger implementation is called, which can be surprising at first.
If you want to more accurately output the timestamp, use the MDC attribute `akkaTimestamp`.
If you want to more accurately output the timestamp for such loggers, use the MDC attribute `akkaTimestamp`. Note that
the MDC key will not have any value for a typed actor.
With Logback the timestamp is available with `%X{akkaTimestamp}` specifier within the pattern layout configuration:
```