Hey.
I'm using it in a webapi but since this is not app specific I'm writing it here.
I am changing the name of the log file per web call. I'm wondering if there is a chance to overlap and write to the wrong file.
Again the call is per request.
Any idea?
The code is this:
I'm not sure what will happen if 2 requests call ChangeLogFileName at the same time.Code:Public Shared Function ChangeLogFileName(ByVal appenderName As String, ByVal newFilename As String) As Boolean Dim rootRepository = log4net.LogManager.GetRepository() For Each appender In rootRepository.GetAppenders() If appender.Name.Equals(appenderName) AndAlso TypeOf appender Is log4net.Appender.FileAppender Then Dim fileAppender = TryCast(appender, log4net.Appender.FileAppender) fileAppender.File = newFilename fileAppender.ActivateOptions() Return True End If Next Return False End Function




Reply With Quote