Skip to content

Commit b4cc42e

Browse files
authored
chore: Share a single logger for internal EventSourcedBehavior logging (#32866)
1 parent 4af0506 commit b4cc42e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

akka-persistence-typed/src/main/scala/akka/persistence/typed/internal/EventSourcedBehaviorImpl.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ private[akka] object EventSourcedBehaviorImpl {
9898
def metadata[M: ClassTag]: Option[M]
9999
}
100100

101+
// Don't use it directly, but instead call internalLogger() (see below)
102+
private val loggerForInternal = LoggerFactory.getLogger(classOf[EventSourcedBehaviorImpl[_, _, _]])
103+
101104
}
102105

103106
@InternalApi
@@ -142,9 +145,6 @@ private[akka] final case class EventSourcedBehaviorImpl[Command, Event, State](
142145
"snapshotWhen with deleteEventsOnSnapshot must not be used together with replication.")
143146
}
144147

145-
// Don't use it directly, but instead call internalLogger() (see below)
146-
private val loggerForInternal = LoggerFactory.getLogger(this.getClass)
147-
148148
override def apply(context: typed.TypedActorContext[Command]): Behavior[Command] = {
149149
val ctx = context.asScala
150150
val hasCustomLoggerName = ctx match {
@@ -168,7 +168,7 @@ private[akka] final case class EventSourcedBehaviorImpl[Command, Event, State](
168168
// MDC is cleared (if used) from aroundReceive in ActorAdapter after processing each message,
169169
// but important to call `context.log` to mark MDC as used
170170
ctx.log
171-
loggerForInternal
171+
EventSourcedBehaviorImpl.loggerForInternal
172172
}
173173
}
174174

0 commit comments

Comments
 (0)