SimpleLogger icon indicating copy to clipboard operation
SimpleLogger copied to clipboard

not an issue, but this logger is not thread safe.

Open xklake opened this issue 8 years ago • 3 comments

if you want to use it in mult-thread, you need make some change on code. i made a little change in publish function in FileLoggerHandler.cs private static ReaderWriterLockSlim _readWriteLock = new ReaderWriterLockSlim();

        _readWriteLock.EnterWriteLock();
        StreamWriter writer = null;

        try
        {
            // Append text to the file
            writer = new StreamWriter(File.Open(Path.Combine(_directory, _fileName), FileMode.Append)); 
            writer.WriteLine(_loggerFormatter.ApplyFormat(logMessage));
            writer.Close();
        }
        finally
        {
            // Release lock
            if(writer != null)
            {
                writer.Close();
            }

        }
        _readWriteLock.ExitWriteLock();

xklake avatar Dec 23 '16 13:12 xklake

Can this get approved and implemented?

dptechdev avatar Jan 17 '17 01:01 dptechdev

@xklake are you using this in production or just messing around?

dptechdev avatar Jan 17 '17 01:01 dptechdev

Yep, @xklake are right. But SimpleLogger is a the only simple logger. But thing "tgis library is single threaded" must be in documentation (or README.md)

maxvodo avatar Feb 22 '17 08:02 maxvodo