当前位置: 首页>>代码示例>>C#>>正文


C# ObservableEventListener.LogToRollingFlatFile方法代码示例

本文整理汇总了C#中ObservableEventListener.LogToRollingFlatFile方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableEventListener.LogToRollingFlatFile方法的具体用法?C# ObservableEventListener.LogToRollingFlatFile怎么用?C# ObservableEventListener.LogToRollingFlatFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObservableEventListener的用法示例。


在下文中一共展示了ObservableEventListener.LogToRollingFlatFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        public override void Initialize()
        {
            var eventListener = new ObservableEventListener();

            eventListener.EnableEvents(
                VirtoCommerceEventSource.Log,
                EventLevel.LogAlways,
                Keywords.All);

            

            var assetsConnection = ConfigurationManager.ConnectionStrings["AssetsConnectionString"];

            if (assetsConnection != null)
            {
                var properties = assetsConnection.ConnectionString.ToDictionary(";", "=");
                var provider = properties["provider"];
                var assetsConnectionString = properties.ToString(";", "=", "provider");

                if (string.Equals(provider, FileSystemBlobProvider.ProviderName, StringComparison.OrdinalIgnoreCase))
                {
                    eventListener.LogToRollingFlatFile("AvaTax.log",
                        10000,
                        "hh",
                        RollFileExistsBehavior.Increment,
                        RollInterval.Day);
                }
                else
                    if (string.Equals(provider, AzureBlobProvider.ProviderName, StringComparison.OrdinalIgnoreCase))
                    {
                        eventListener.LogToWindowsAzureTable(
                            "VirtoCommerce2", assetsConnectionString);

                    }
            }


            var settingsManager = _container.Resolve<ISettingsManager>();
            
            var avalaraTax = new AvaTaxSettings(_usernamePropertyName, _passwordPropertyName, _serviceUrlPropertyName, _companyCodePropertyName, _isEnabledPropertyName, _isValidateAddressPropertyName, settingsManager);
            
            _container.RegisterType<AvaTaxController>
                (new InjectionConstructor(
                    avalaraTax));

            _container.RegisterInstance<ITaxSettings>(avalaraTax);

            //Subscribe to cart changes. Calculate taxes   
            _container.RegisterType<IObserver<CartChangeEvent>, CalculateCartTaxesObserver>("CalculateCartTaxesObserver");

            //Subscribe to order changes. Calculate taxes   
            _container.RegisterType<IObserver<OrderChangeEvent>, CalculateOrderTaxesObserver>("CalculateOrderTaxesObserver");

            //Subscribe to order changes. Calculate taxes   
            _container.RegisterType<IObserver<OrderChangeEvent>, CancelOrderTaxesObserver>("CancelOrderTaxesObserver");

            //Subscribe to order changes. Adjust taxes   
            _container.RegisterType<IObserver<OrderChangeEvent>, CalculateTaxAdjustmentObserver>("CalculateTaxAdjustmentObserver");
        }
开发者ID:rajendra1809,项目名称:VirtoCommerce,代码行数:59,代码来源:Module.cs

示例2: WhenFilenameInvalidErrorOCcursEarly2

        public void WhenFilenameInvalidErrorOCcursEarly2()
        {
            var excpectionThrown = ExceptionAssertHelper.Throws<ArgumentException>(() =>
                {
                    using (var listener = new ObservableEventListener())
                    {
                        listener.LogToRollingFlatFile(@"..\", 1, "yyyy", RollFileExistsBehavior.Increment, RollInterval.None, new EventTextFormatter(EventTextFormatter.DashSeparator));
                    }
                });

            Assert.AreEqual("A file name with a relative path is not allowed. Provide only the file name or the full path of the file.", excpectionThrown.Message);
        }
开发者ID:guyzo,项目名称:semantic-logging,代码行数:12,代码来源:RollingFlatFileSinkFixture.cs

示例3: WhenFilenameInvalidErrorOCcursEarly1

        public void WhenFilenameInvalidErrorOCcursEarly1()
        {
            var excpectionThrown = ExceptionAssertHelper.Throws<ArgumentException>(() =>
                {
                    using (var listener = new ObservableEventListener())
                    {
                        listener.LogToRollingFlatFile(@"|", 1, "yyyy", RollFileExistsBehavior.Increment, RollInterval.None, new EventTextFormatter(EventTextFormatter.DashSeparator));
                    }
                });

            Assert.AreEqual("Illegal characters in path.", excpectionThrown.Message);
        }
开发者ID:guyzo,项目名称:semantic-logging,代码行数:12,代码来源:RollingFlatFileSinkFixture.cs

示例4: WhenTimestampPatternIsEmpty

        public void WhenTimestampPatternIsEmpty()
        {
            var excpectionThrown = ExceptionAssertHelper.Throws<ArgumentException>(() =>
                {
                    using (var listener = new ObservableEventListener())
                    {
                        listener.LogToRollingFlatFile("TestForTimestampAsEmptyString.log", 0, string.Empty, RollFileExistsBehavior.Increment, RollInterval.Midnight, new EventTextFormatter(EventTextFormatter.DashSeparator));
                    }
                });

            Assert.AreEqual("Argument is empty\r\nParameter name: timestampPattern", excpectionThrown.Message);
        }
开发者ID:guyzo,项目名称:semantic-logging,代码行数:12,代码来源:RollingFlatFileSinkFixture.cs

示例5: WhenFileNameIsEmpty

        public void WhenFileNameIsEmpty()
        {
            using (var listener = new ObservableEventListener())
            {
                var subscription = listener.LogToRollingFlatFile(string.Empty, 1, "yyyy", RollFileExistsBehavior.Increment, RollInterval.None, new EventTextFormatter(EventTextFormatter.DashSeparator));

                Assert.IsNotNull(subscription);
            }
        }
开发者ID:guyzo,项目名称:semantic-logging,代码行数:9,代码来源:RollingFlatFileSinkFixture.cs

示例6: CreateListener

 /// <summary>
 /// Creates an event listener that logs using a <see cref="RollingFlatFileSink"/>.
 /// </summary>
 /// <param name="fileName">The filename where the entries will be logged.</param>
 /// <param name="rollSizeKB">The maximum file size (KB) before rolling.</param>
 /// <param name="timestampPattern">The date format that will be appended to the new roll file.</param>
 /// <param name="rollFileExistsBehavior">Expected behavior that will be used when the roll file has to be created.</param>
 /// <param name="rollInterval">The time interval that makes the file to be rolled.</param>
 /// <param name="formatter">The formatter.</param>
 /// <param name="maxArchivedFiles">The maximum number of archived files to keep.</param>
 /// <param name="isAsync">Specifies if the writing should be done asynchronously, or synchronously with a blocking call.</param>
 /// <returns>An event listener that uses <see cref="RollingFlatFileSink"/> to log events.</returns>
 public static EventListener CreateListener(string fileName, int rollSizeKB, string timestampPattern, RollFileExistsBehavior rollFileExistsBehavior, RollInterval rollInterval, IEventTextFormatter formatter = null, int maxArchivedFiles = 0, bool isAsync = false)
 {
     var listener = new ObservableEventListener();
     listener.LogToRollingFlatFile(fileName, rollSizeKB, timestampPattern, rollFileExistsBehavior, rollInterval, formatter, maxArchivedFiles, isAsync);
     return listener;
 }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:18,代码来源:RollingFlatFileLog.cs

示例7: InitializeLocalLogging

        protected override void InitializeLocalLogging()
        {
            _platformEventStream = new ObservableEventListener();
            _platformEventStream.EnableEvents(EventSources.PlatformSources, TraceLevel);

            var formatter = new EventTextFormatter(dateTimeFormat: "O");
            _platformEventStream.Subscribe(evt =>
            {
                StringBuilder b = new StringBuilder();
                using (var writer = new StringWriter(b))
                {
                    formatter.WriteEvent(evt, writer);
                }
                Trace.WriteLine(b.ToString());
            });

            try
            {
                var logsResource = RoleEnvironment.GetLocalResource("Logs");

                var logFile = Path.Combine(logsResource.RootPath, "Platform", "Platform.log.json");

                // Initialize core platform logging
                _subscriptions.Add(_platformEventStream.LogToRollingFlatFile(
                    fileName: logFile,
                    rollSizeKB: 1024,
                    timestampPattern: "yyyyMMdd-HHmmss",
                    rollFileExistsBehavior: RollFileExistsBehavior.Increment,
                    rollInterval: RollInterval.Hour,
                    formatter: new JsonEventTextFormatter(EventTextFormatting.Indented, dateTimeFormat: "O"),
                    maxArchivedFiles: 768, // We have a buffer size of 1024MB for this folder
                    isAsync: false));
            }
            catch (Exception ex)
            {
                ServicePlatformEventSource.Log.FatalException(ex);
                throw;
            }
        }
开发者ID:stephenosrajan,项目名称:NuGet.Services.Platform,代码行数:39,代码来源:AzureServiceHost.cs

示例8: Start

        public void Start(TflProcess process) {
            if (_started)
                return;

            _started = true;
            Name = process.Name;
            foreach (var log in process.Log) {
                switch (log.Provider) {
                    case "file":
                        log.Folder = log.Folder.Replace('/', '\\');
                        log.File = log.File.Replace('/', '\\');
                        log.Folder = (log.Folder.Equals(Common.DefaultValue) ? "logs" : log.Folder).TrimEnd('\\') + "\\";
                        log.File = (log.File.Equals(Common.DefaultValue) ? "tfl-" + process.Name + ".log" : log.File).TrimStart('\\');

                        var fileListener = new ObservableEventListener();
                        fileListener.EnableEvents(TflEventSource.Log, (EventLevel)Enum.Parse(typeof(EventLevel), log.Level));
                        SinkSubscriptions.Add(fileListener.LogToRollingFlatFile(log.Folder + log.File, 5000, "yyyy-MM-dd", RollFileExistsBehavior.Increment, RollInterval.Day, new LegacyLogFormatter(), 0, log.Async));
                        EventListeners.Add(fileListener);
                        break;
                    case "mail":
                        if (log.Subject.Equals(Common.DefaultValue)) {
                            log.Subject = process.Name + " " + log.Level;
                        }
                        var mailListener = new ObservableEventListener();
                        mailListener.EnableEvents(TflEventSource.Log, EventLevel.Error);
                        SinkSubscriptions.Add(mailListener.LogToEmail(log));
                        EventListeners.Add(mailListener);
                        break;
                }

            }

        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:33,代码来源:RunLogger.cs


注:本文中的ObservableEventListener.LogToRollingFlatFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。