Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Logger" /> class.
        /// </summary>
        /// <param name="logFile">Log file.</param>
        /// <param name="loggerSetup">Log setup.</param>
        internal Logger(string logFile, LoggerSetup loggerSetup)
        {
            this._logFile = logFile;

            this._loggerSetup = loggerSetup;

            if (this._loggerSetup.WriteToFile)
            {
                try
                {
                    this._fileAppender = new MutexMultiProcessFileAppender(this._logFile, this._loggerSetup);
                }
                catch (Exception e)
                {
                    InternalLogger.Log(e);
                }
            }

            if (this._loggerSetup.WriteToFile && this._fileAppender != null)
            {
                this._queueWaitHandle = new AutoResetEvent(false);

                this._queue = new Queue <string>();

                this._consumerThread = new Thread(this.ConsumerThread);
                this._consumerThread.IsBackground = true;
                this._consumerThread.Start();
            }
        }
Exemple #2
0
 /// <summary>
 /// Dispose file appender.
 /// </summary>
 private void DisposeFileAppender()
 {
     if (this._fileAppender != null)
     {
         this._fileAppender.Dispose();
         this._fileAppender = null;
     }
 }
Exemple #3
0
        /// <summary>
        /// Initializes file appender.
        /// </summary>
        private void InitFileAppender()
        {
            this.DisposeFileAppender();

            if (this._loggerSetup.WriteToFile)
            {
                try
                {
                    this._fileAppender = new MutexMultiProcessFileAppender(this._logFile, this._loggerSetup);
                }
                catch (Exception e)
                {
                    InternalLogger.Log(e);
                }
            }
        }