nreco / logging

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

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

Closed VitaliyMF closed 11 months ago

VitaliyMF commented 11 months 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 11 months 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.