Shared property not working
See original GitHub issueIm trying to write logs and have the UI read them simultaneously, but when I call File.Open(Path.Combine(directory, fileInfo.Name), FileMode.Open, FileAccess.Read))
it throws an exception and the file is already being used by a process.
The log is configured as such: sublogger -> filter -> sinks.map -> sinks.async -> sinks.file So logged items are logged to a uniquely named file filtered by their type and written asynchronously.
Config code:
public SerilogProvisioner(LoggerConfiguration configuration, LogConfigResolver logConfigResolver,
string rootPath)
{
Relay = new LogRelay();
LogConfigResolver = logConfigResolver;
foreach (var key in logConfigResolver.GetTypes())
{
var resolution = logConfigResolver.Resolve(key);
if (resolution != null && resolution.Output != null)
{
configuration = configuration
.WriteTo.Logger(lc => lc
.Filter.ByIncludingOnly(Matching.FromSource(key.FullName))
.WriteTo.Map(resolution.PropertySelector ?? "LogId", (property, wt) =>
{
var logOptions = logConfigResolver.Resolve(key);
var path = Path.Combine(rootPath, logOptions.Output.Uri, property + "-.txt");
var logId = new LogId(key, property);
var relaySink = new LogRelaySink(logId, Path.Combine(rootPath, logOptions.Output.Uri));
Relay.AddRelay(relaySink);
switch (logOptions.Output.OutputType)
{
case LogOutputType.File:
wt.Async(a => a.File(
path,
shared: true,
rollingInterval: RollingInterval.Day));
break;
}
wt.Sink(relaySink);
}));
}
}
`
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Shared Ownership Top 10 Issues
Learn the 10 best ways to prevent owning with friends from leading to anger, resentment and frustration.
Read more >How to Resolve a Joint Property Ownership Dispute
Joint ownership can make the process of purchasing property more affordable. Read our guide to joint ownership & find out how to resolve...
Read more >Shared ownership: why is it not working for first-time buyers?
Shared ownership has had a bad press in recent years, with negative stories about lack of security, high service charges and negative equity. ......
Read more >VB Property not being set when setting it from another form
I got it to work by adding the Shared setting on the property. Public Shared Property ColumnWidths As Dictionary(Of Integer, Integer) now it ......
Read more >Co-Ownership: Legal Issues with Jointly Owned Property
Disputes may sometimes occur in property co-ownership. Find legal ways to settle your case, read this article to learn more.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hit the same issue when we do read all lines of the log file or using file stream without adding FileShare.ReadWrite:
Logger Configuration:
Code that hit this bug (file refer to the log file user trying to read):
W/A for this bug:
Add FIleShare.ReadWrite
I find that real-time monitoring of log files with is not accurate for long running processes that are using the Serilog logging framework, because Serilog often has a lock on the file even with shared: true
The Serilog config snippet I’m using:
Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.File(logFile, shared: true) .CreateLogger();