Closed huangjinshe closed 2 years ago
Certainly the Async Sink doesn't have any facilities to change things (but in general its not a normal feature for other sinks either)
Best to ask questions like this on stackoverflow as nobody regularly monitors this for random questions - it's intended for logging bugs and/or scoped feature plans relevant to a given repo
When you've posted on SO (with some more info as to what your overall goals are), feel free to post a link here and close this.
My wild guess is that https://github.com/serilog/serilog-sinks-map might be relevant....
@bartelink Thank you for telling me that. Actually I saw it before, but I little worry it will conflict with serilog-sinks-async.
Can I use serilog-sinks-map with serilog-sinks-async together? Write async log with different names?
.WriteTo.Map("Name", "", (name, wt) => wt.File($"logs\\{name}.txt"))
.WriteTo.Async(a => a.File("logs\\{name}.txt", rollingInterval: RollingInterval.Day))
You can chain them like that but in general you wrap it all in the Async and then nest things inside that, i.e. a.Map(...)
I would recommend to read the source of Sinks.Async and you can see it is just shifting work out to a background loop - nice and short and neat.
In summary, it's not a question of conflict - Sinks like Map and Async wrap other sets of Sinks and do routing, and then you use concrete Sinks such as File within them.
If you have a specific scenario you're trying to address, there's no substitute for asking that on Stack Overflow - you'll find lots of people will have specific recipes and tips for things that work well (I reckon every combination of varying the name per your original question is also covered by various questons on SO).
Ok. Thanks again.
Like use a variable to change :