Exemple #1
0
        public void Dispose()
        {
            if (this.FsDriver is IDisposable)
            {
                ((IDisposable)this.FsDriver).Dispose();
            }
            sessionsDatabaseDriver.Dispose();

            if (logger_output != null)
            {
                logger_output.Close();
            }
        }
Exemple #2
0
        // - - - - - - - - - - - - - - - - - - - - - - - - - - -


        private void _EndStoreLogMessages()
        {
            if (appenderLogMessages != null)
            {
                appenderLogMessages.Close();
                (log.Logger as IAppenderAttachable).RemoveAppender(appenderLogMessages);
                appenderLogMessages = null;
            }
        }
        private long GetLog4NetTimestamp(DateTime dateTime)
        {
            var logXmlBuilder = new StringBuilder();

            using (var writer = new StringWriter(logXmlBuilder))
            {
                var layout   = new XmlLayoutSchemaLog4j();
                var appender = new TextWriterAppender
                {
                    ImmediateFlush = true,
                    Layout         = layout,
                    Writer         = writer
                };
                var repository = LogManager.GetRepository(Assembly.GetCallingAssembly());

                var eventData = new LoggingEventData
                {
                    LoggerName   = "TestLogger",
                    TimeStampUtc = dateTime.ToUniversalTime(),
                    Level        = log4net.Core.Level.Debug,
                    ThreadName   = "TestThread",
                    Message      = "Test message."
                };
                var @event = new LoggingEvent(typeof(TimestampTests), repository, eventData);
                appender.DoAppend(@event);

                writer.Flush();

                appender.Close();
            }

            var logXml = logXmlBuilder.ToString();

            const string timestampStartMarker = "timestamp=\"";
            var          timestampStart       = logXml.IndexOf(timestampStartMarker) + timestampStartMarker.Length;

            Assume.That(timestampStart, Is.GreaterThanOrEqualTo(0));
            var timestampEnd = logXml.IndexOf('"', timestampStart);

            Assume.That(timestampEnd, Is.GreaterThanOrEqualTo(0));

            var timestampString = logXml.Substring(timestampStart, timestampEnd - timestampStart);

            var timestamp = Int64.Parse(timestampString);

            return(timestamp);
        }