Skip to content

Implement multi-process log file sharing on .NET Core #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
derFunk opened this issue Nov 11, 2016 · 8 comments
Closed

Implement multi-process log file sharing on .NET Core #37

derFunk opened this issue Nov 11, 2016 · 8 comments

Comments

@derFunk
Copy link

derFunk commented Nov 11, 2016

There is a parameter shared when creating a RollingFile sink.
But currently it's throwing a NotSupportedException when set to true.
See also

#if SHARING
_currentFile = _shared ?
(ILogEventSink)new SharedFileSink(path, _textFormatter, _fileSizeLimitBytes, _encoding) :
new FileSink(path, _textFormatter, _fileSizeLimitBytes, _encoding, _buffered);
#else
_currentFile = new FileSink(path, _textFormatter, _fileSizeLimitBytes, _encoding, _buffered);
#endif

What's the status here?

  • Is it working to write to one file from multiple processes even if this shared parameter is set to false?
  • If not, will this be implemented?
@nblumhardt
Copy link
Member

Hi @derFunk - shared works on .NET Framework, but the APIs used are not (yet?) available on .NET Core. My guess is you're receiving NotSupportedException on core - is that right? Thanks!

@derFunk
Copy link
Author

derFunk commented Nov 17, 2016

Yes, I'm on .NET Core.
Thanks for clarification!

@nblumhardt nblumhardt changed the title What's the status on having multiple processes writing to the same logfile? (Sharing?) Implement multi-process log file sharing on .NET Core Nov 18, 2016
@nblumhardt
Copy link
Member

Re-titled to cover the .NET Core aspect. Not sure what the appropriate cross-platform way to implement this is (close/reopen is hideously slow). Any ideas out there?

@skomis-mm
Copy link

@nblumhardt , what do you think about serializing writing/flushing with Mutexes?

@nblumhardt
Copy link
Member

Ooh interesting - I didn't think Mutex was on .NET Core. Yes, that's the top contender then :-) 👍

@nblumhardt
Copy link
Member

I've PR'd a basic implementation in serilog/serilog-sinks-file#27. Once we're happy with it, we can incorporate it downstream here.

@nblumhardt
Copy link
Member

PR in #40.

nblumhardt added a commit that referenced this issue Dec 1, 2016
@nblumhardt
Copy link
Member

Hi all - this is now in the pre-release NuGet package, any feedback welcomed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants