nreco / logging

Generic file logger for .NET Core (FileLoggerProvider) with minimal dependencies
MIT License
296 stars 60 forks source link

File open errors inside FileLoggerProvider constructor are not handled by HandleFileError #59

Closed VitaliyMF closed 1 year ago

VitaliyMF commented 1 year ago

From https://github.com/nreco/logging/issues/57#issuecomment-1753309361_

FileWriter.OpenFile uses "HandleFileError" when it is defined, however at the time of FileLoggerProvider creation (when log file is opened for the first time) this handler is not initialized yet. To fix this it would be enough to postpone log file open and open it only after initialization.

VitaliyMF commented 1 year ago

After reviewing code I find that this cannot be reproduced because HandleFileError comes in FileLoggerOptions which is passed in FileLoggerProvider constructor and initialized before FileWriter.OpenFile so it will be used even on the first log file open.