Using Serilog with memstate (general discussions) #117
Replies: 2 comments 2 replies
-
Aah, bit slow, maybe the egnog talking, but I just realised that logging inside a command is breaking the journal isolation, i.e. it's a side effect and commands should be side effect free. (outside of the model, that is) In other words, this isn't a bug,(it's by design), all I need to do is move the logging to outside of memstate "context" and it should all be good? let me confirm that. i.e. make the call to Log before executing the command, don't do any logging inside the command. |
Beta Was this translation helpful? Give feedback.
-
In either case, if you simply use Serilog, and log before calling memstate commands everything works and memstate doesnt interfere or hook into your logging, which is much better ... imho. |
Beta Was this translation helpful? Give feedback.
-
Hi @rofr
I'm using Serilog in my project and tried to use Serilog with a memstate command and I was unable to to test it.
I wrote these 2 tests, test 1, proving that the TestCorrelator is working fine to capture Log.Information calls, and the second test, proving that my call to Log.Information from inside a memstate command is not working.
I couldn't find any tests in the memstate project for Serilog, and the code for the Serilog provider in memstate doesn't easily explain why it's not working, or how I'm supposed to do logging, and-or use Serilog with memstate.
Before I spend any serious time looking at the LibLog logging code (or experimenting with ripping part of that all out or providing some means of disabling it so that Serilog will work, and creating a PR, .. I wanted to check with you first that i wasn't doing anything obviously wrong?
here are the two tests I've written;
and here is the DummyJournalRecord that I call;
Basically, what I want to be able to do is use Serilog as shown above in the
DummyJournalRecord
. It seems that memstate somehow interferes with the default Log.Logger context, and my calls disappear due to some Context problems. i.e. they don't get flushed or routed to the configured sink. (In this case, the TestCorrelator sink)Any suggestions?
cheers,
Alan
p.s. Merry Christmas!
Oh! ...also, I wrote a new open source project last night
PrettyJson
: https://github.com/goblinfactory/pretty-jsonBeta Was this translation helpful? Give feedback.
All reactions