[ 
https://issues.apache.org/jira/browse/LOG4NET-623?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16754550#comment-16754550
 ] 

Shrikant Mabrukar commented on LOG4NET-623:
-------------------------------------------

Attached are 3 pix showing
 # log4Net_createAppender -> The code calling to create appenders, test 
program. The red box show line of code which doesn't return the correct count 
when called from multiple threads in quick succession( < 300ms) 
!log4Net_createAppender.gif!

> RollingFIleAppender creating multiple duplicate files within a process
> ----------------------------------------------------------------------
>
>                 Key: LOG4NET-623
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-623
>             Project: Log4net
>          Issue Type: Task
>          Components: Appenders
>    Affects Versions: 2.0.8
>         Environment: Prod
>            Reporter: Shrikant Mabrukar
>            Assignee: Dominik Psenner
>            Priority: Major
>             Fix For: 2.1.0
>
>         Attachments: Log4Net_Appender1.png, Screen Shot 2019-01-22 at 
> 11.41.48 PM.png, log4Net_createAppender.gif
>
>
> In a process I have multiple threads, each thread is creating a file with 
> same log entries resulting in creation of multiple duplicate files within a 
> process. This happens when multiple threads are trying to log same time.
> I am using RollingFIleAppender 
> RollingFileAppender appender = new RollingFileAppender
>  {
>  Name = configuration.LoggerName,
>  Layout = patternLayout,
>  AppendToFile = true,
>  PreserveLogFileNameExtension = true,
>  CountDirection = 1,
>  RollingStyle = RollingFileAppender.RollingMode.Size,
>  MaxSizeRollBackups = configuration.MaxRollBackups.HasValue ? 
> configuration.MaxRollBackups.Value : 4,
>  MaximumFileSize = configuration.MaxFileSizeKB.HasValue == false ? "100KB" : 
> $"\{configuration.MaxFileSizeKB.Value}KB", 
>  StaticLogFileName = false, 
>  File = "myFile[%processid].log"
>  };
>  
> Upon digging turns out log4Net is thread safe but not process safe
> [https://hectorcorrea.com/blog/log4net-thread-safe-but-not-process-safe/17]
> Tried multiple locking mechanism which are offered by Log4Net itself for 
> RollingFileAppender MinimalLock, InterProcessLock and ExclusiveLock none of 
> them helped. Nor does PatterString help.
>  
> Any ideas on how to solve the issue?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to