From cfbdd5b1a0da105f784ae862f4fb9bd6ba1260e1 Mon Sep 17 00:00:00 2001 From: Brah McDude <77924970+brah-mcdude@users.noreply.github.com> Date: Thu, 26 May 2022 20:52:02 +0300 Subject: [PATCH] Update logging.md (#5928) * Update logging.md * Fix linter warnings Co-authored-by: Gregorius Soedharmo Co-authored-by: Aaron Stannard --- docs/articles/utilities/logging.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/articles/utilities/logging.md b/docs/articles/utilities/logging.md index 6051533e4fe..0e6c29270b4 100644 --- a/docs/articles/utilities/logging.md +++ b/docs/articles/utilities/logging.md @@ -112,3 +112,28 @@ akka { } } ``` + +## Logging All Receive'd Messages + +It is possible to log all Receive'd messages, usually for debug purposes. This can be achieved by implementing the ILogReceive interface: + +```c# +public class MyActor : ReceiveActor, ILogReceive +{ + public MyActor() + { + Receive(s => Sender.Tell("ok")); + } +} + +... + +// send a MyActor instance a string message +myActor.Tell("hello"); +``` + +In your log, expect to see a line such as: + +`[DEBUG]... received handled message hello from akka://test/deadLetters` + +This logging can be toggled by configuring `akka.actor.debug.receive`.