These are chat archives for akkadotnet/AkkaStreams

23rd
Aug 2016
Mikhail Shilkov
@mikhailshilkov
Aug 23 2016 21:16
Hi all. When I set my Streams supervision strategy to Resume, how can I log all errors? Ideally, in a separate flow, but to start with - just to console.
Marc Piechura
@marcpiechura
Aug 23 2016 21:22
@mikhailshilkov that's currently not possible afaik, I ended up with a logging statement within the catch block.
Imho we should add a way to make that possible because you often want to log the exceptions even if the stream shouldn't stop
Maybe via another attribute or globally as setting
Mikhail Shilkov
@mikhailshilkov
Aug 23 2016 21:25
I agree. What about the .Log() which is mentioned in the cookbook? Does it log from one stage?
Marc Piechura
@marcpiechura
Aug 23 2016 21:26
With it you can log elements that pass through
Mikhail Shilkov
@mikhailshilkov
Aug 23 2016 21:28
What will LogLevel.ErrorLevel log?
Marc Piechura
@marcpiechura
Aug 23 2016 21:33
Only errors I guess :)
Mikhail Shilkov
@mikhailshilkov
Aug 23 2016 21:35
So will this log anything?
Flow.Create<string>().Select(i =>
                    {
                        throw new Exception("Bad thing");
                        return i;
                    }).Log("name");
I don't see anything (I assume console is the default logger)
Marc Piechura
@marcpiechura
Aug 23 2016 21:37
And you have resume as supervision strategy?
Mikhail Shilkov
@mikhailshilkov
Aug 23 2016 21:37
Yes, the stream goes on fine
Marc Piechura
@marcpiechura
Aug 23 2016 21:38
Yep, so inside of the select there is a try catch block and in the catch statement it checks your supervision strategy and if it's resume it simply keeps going without pushing anything to the log stage
But the log stage only logs something if it gets an element
Mikhail Shilkov
@mikhailshilkov
Aug 23 2016 21:39
Ah I see
Marc Piechura
@marcpiechura
Aug 23 2016 21:39
So if you remove the exception you should see "name" for every element
Mikhail Shilkov
@mikhailshilkov
Aug 23 2016 21:39
So what is the case when Log stage does log an error?
(it has onError parameter)
Marc Piechura
@marcpiechura
Aug 23 2016 21:40
That's when you set your supervision strategy to stop
The select stage will then send the exception upstream to the log stage
Mikhail Shilkov
@mikhailshilkov
Aug 23 2016 21:41
Right! Set it to stop and now I see it
Do you know if JVM Akka can log errors & resume?
Marc Piechura
@marcpiechura
Aug 23 2016 21:45
Don't know, I will see if I can find something in the source, because I can't believe that only we have this requirement ;-)
Mikhail Shilkov
@mikhailshilkov
Aug 23 2016 21:46
Should I make an issue in Akka.NET github?
Marc Piechura
@marcpiechura
Aug 23 2016 21:46
Sure thing, maybe we have missed something
Mikhail Shilkov
@mikhailshilkov
Aug 23 2016 21:46
Ok, thanks for your help Marc
Marc Piechura
@marcpiechura
Aug 23 2016 21:47
You're welcome
Marc Piechura
@marcpiechura
Aug 23 2016 21:59
@mikhailshilkov I may have found a solution, instead of simply using Decider.Resume you can also provide you own decider, which is basically a Func<Exception, Decider>, so we could log the exception inside the func