FileTarget.AutoFlush ignored

281 views
Skip to first unread message

Robert Važan

unread,
Jul 16, 2013, 1:00:48 PM7/16/13
to nlog-...@googlegroups.com
I've tried to enable FileTarget.KeepFileOpen option with the expectation that FileTarget.AutoFlush will ensure that all messages are flushed to the file. The file however wasn't flushed, i.e. FileTarget.AutoFlush didn't do anything. Looking at the code, FileTarget.AutoFlush property is not referenced anywhere. Was it ever implemented?

Are there better ways to ensure flushing of log messages (even those before application crash) with less overhead that the default reopening of the file for every message?

It looks like this issue has been discussed some time ago:

http://nlog-forum.1685105.n2.nabble.com/keepFileOpen-true-on-lt-target-gt-td6831594.html

Was it ever fixed?

Kim Christensen

unread,
Jul 17, 2013, 7:31:18 AM7/17/13
to nlog-...@googlegroups.com

Could you post your configuration?

Robert Važan

unread,
Jul 17, 2013, 1:49:00 PM7/17/13
to nlog-...@googlegroups.com
             var fileTarget = new FileTarget()
            {
                FileName = file,
                Layout = layout,
                ConcurrentWrites = false,
                ArchiveAboveSize = 10000000,
                MaxArchiveFiles = 1000,
                KeepFileOpen = true,
                AutoFlush = true
            };

Kim Christensen

unread,
Jul 20, 2013, 4:19:34 PM7/20/13
to nlog-...@googlegroups.com

You are correct there are some inconsistency with file appenders and autoflush, i will look into this

Eric Johnson

unread,
Oct 3, 2014, 5:15:09 PM10/3/14
to nlog-...@googlegroups.com
I'm having a similar problem. I have a single process logging to file and per the File target documentation recommendations for best performance I am trying to set keepFileOpen=true and concurrentWrites=false. In this combination, however, NLog will not autoflush. If I switch the value on either attribute, autoflushing works. Referencing the earlier linked post, I have async=true set on the targets element, and setting it to false does not affect anything either.
Reply all
Reply to author
Forward
0 new messages