Reputation: 5367
Currently I am using MetroLog. It uses a file stream to log info into the log file.
Is there a possibility to read the content of the StorageFile while it is in use by MetroLog's file stream
using (var randomAccessStream = await localFile.OpenReadAsync())
{
...
}
this code will cause an Access Denied
exception. The file exists and it looks like it has the correct rights because it works if I disable logging.
Upvotes: 0
Views: 210
Reputation: 11
I had the same problem. My solution is the following (all my code is placed in the device implementation, not in the pcl):
At initialization of Metrolog save the Streaming file target for later purposes:
private static StreamingFileTarget _target;
...
LogManagerFactory.DefaultConfiguration.AddTarget(LogLevel.Trace, LogLevel.Fatal, _target);
Close all open files of file target before open/read the current logfile of Metrolog:
await _target.CloseAllOpenFiles();
your code...
The current logfile will be opened again at the next log command.
Upvotes: 1