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


C# ObservableEventListener.LogToFlatFile方法代码示例

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


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

示例1: RegisterEFLogger

        private static void RegisterEFLogger()
        {
            var listener = new ObservableEventListener();
            listener.EnableEvents(EFLogging.Logger, EventLevel.LogAlways, Keywords.All);

            listener.LogToFlatFile("EFSqls.log");
            listener.LogToWindowsAzureTable(instanceName: "Protiviti", connectionString: "UseDevelopmentStorage=true",tableAddress:"EFSqls");
        }
开发者ID:szwork2013,项目名称:BoiPlt,代码行数:8,代码来源:Bootstrapper.cs

示例2: RegisterLogger

        private static void RegisterLogger()
        {
            var listener = new ObservableEventListener();
            listener.EnableEvents(WebApiTracing.Log, EventLevel.LogAlways, Keywords.All);

            listener.LogToConsole();
            listener.LogToFlatFile("test.log");
            listener.LogToWindowsAzureTable(instanceName: "Protiviti", connectionString: "UseDevelopmentStorage=true");
        }
开发者ID:szwork2013,项目名称:BoiPlt,代码行数:9,代码来源:Bootstrapper.cs

示例3: ConfigureLogging

 private void ConfigureLogging()
 {
     eventListener = new ObservableEventListener();
     eventListener.EnableEvents(SparkEngineEventSource.Log, EventLevel.LogAlways,
         Keywords.All);
     eventListener.EnableEvents(SparkMongoEventSource.Log, EventLevel.LogAlways,
         Keywords.All);
     eventListener.EnableEvents(SemanticLoggingEventSource.Log, EventLevel.LogAlways, Keywords.All);
     var formatter = new JsonEventTextFormatter(EventTextFormatting.Indented);
     eventListener.LogToFlatFile(@"C:\projects\fhir\log\spark.log", formatter);
 }
开发者ID:Condeti,项目名称:spark,代码行数:11,代码来源:Global.asax.cs

示例4: Application_Start

		protected void Application_Start()
		{
			var listener = new ObservableEventListener();
			listener.EnableEvents(WebApiTracing.Log, EventLevel.LogAlways, Keywords.All);
			listener.LogToFlatFile("test.log");

			AreaRegistration.RegisterAllAreas();
			GlobalConfiguration.Configure(WebApiConfig.Register);
			FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
			RouteConfig.RegisterRoutes(RouteTable.Routes);
			BundleConfig.RegisterBundles(BundleTable.Bundles);
		}
开发者ID:WebApiContrib,项目名称:WebApiContrib.Tracing.Slab,代码行数:12,代码来源:Global.asax.cs

示例5: Configure

        public static void Configure()
        {
            List<EventSource> eventSources = new List<EventSource>(new[] { DomainEventSource.Log });

            ObservableEventListener logListner = new ObservableEventListener();

            foreach (var eventSource in eventSources)
            {
                logListner.EnableEvents(eventSource, EventLevel.Error , Keywords.All);
            }

            logListner.LogToFlatFile("log.txt");
        }
开发者ID:fnouira,项目名称:PC.G5,代码行数:13,代码来源:LoggingConfig.cs

示例6: RegisterLoggingSources

        public static void RegisterLoggingSources(IEnumerable<EventSource> logSources, ISiteSettings settings)
        {
            var logListener = new ObservableEventListener();

            foreach (var logSource in logSources)
            {
                logListener.EnableEvents(
                  logSource, EventLevel.LogAlways, Keywords.All);
            }

            logListener.LogToFlatFile(
                    fileName: settings.LogFilePath,
                    formatter: new EventTextFormatter());
        }
开发者ID:RazvanADumitru,项目名称:OMS,代码行数:14,代码来源:LoggingConfig.cs

示例7: Configure

        public static void Configure()
        {
            List<EventSource> eventSources = new List<EventSource>() { DomainEventSource.Log, SiteEventSource.Log };

            ObservableEventListener logListener = new ObservableEventListener();

            foreach (var eventSource in eventSources)
            {
                logListener.EnableEvents(eventSource, EventLevel.LogAlways, Keywords.All);
            }


            logListener.LogToFlatFile("./Log.txt");
        }
开发者ID:fnouira,项目名称:PropertyCenter.G6,代码行数:14,代码来源:LoggingConfig.cs

示例8: WhenFileNameIsNull

 public void WhenFileNameIsNull()
 {
     try
     {
         var formatter = new EventTextFormatter(EventTextFormatter.DashSeparator);
         using (var listener = new ObservableEventListener())
         {
             listener.LogToFlatFile(null, formatter);
         }
     }
     catch (ArgumentNullException ex)
     {
         Assert.AreEqual("Value cannot be null.\r\nParameter name: fileName", ex.Message);
     }
 }
开发者ID:husains,项目名称:semantic-logging,代码行数:15,代码来源:FlatFileSinkFixture.cs

示例9: EventWithPayloadAndEnumsInXml

        public void EventWithPayloadAndEnumsInXml()
        {
            string fileName = "LogUsingPayloadWithEnumsInProc";
            File.Delete(fileName);
            var formatter = new XmlEventTextFormatter(EventTextFormatting.Indented, "d");
            var logger = MockEventSourceInProcEnum.Logger;

            using (var listener = new ObservableEventListener())
            {
                listener.EnableEvents(logger, EventLevel.LogAlways, Keywords.All);
                listener.LogToFlatFile(fileName, formatter);
                try
                {
                    logger.SendEnumsEvent16(MockEventSourceInProcEnum.MyColor.Green, MockEventSourceInProcEnum.MyFlags.Flag1);
                }
                finally
                {
                    listener.DisableEvents(logger);
                }
            }

            var rawOutput = FlatFileHelper.GetAllText(fileName);
            var entries = XDocument.Parse("<Events>" + rawOutput + "</Events>").Root.Elements();
            Assert.AreEqual(1, entries.Count());
            XmlFormattedEntry.Fill(entries.First());
            Assert.AreEqual("a", XmlFormattedEntry.Payload.Elements().First().Attribute("Name").Value);
            Assert.AreEqual("2", XmlFormattedEntry.Payload.Elements().First().Value);
            Assert.AreEqual("b", XmlFormattedEntry.Payload.Elements().Last().Attribute("Name").Value);
            Assert.AreEqual("1", XmlFormattedEntry.Payload.Elements().Last().Value);
        }
开发者ID:husains,项目名称:semantic-logging,代码行数:30,代码来源:XmlEventTextFormatterFixture.cs

示例10: CreateListener

 /// <summary>
 /// Creates an event listener that logs using a <see cref="FlatFileSink"/>.
 /// </summary>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="formatter">The formatter.</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="FlatFileSink"/> to log events.</returns>
 public static EventListener CreateListener(string fileName = null, IEventTextFormatter formatter = null, bool isAsync = false)
 {
     var listener = new ObservableEventListener();
     listener.LogToFlatFile(fileName, formatter, isAsync);
     return listener;
 }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:13,代码来源:FlatFileLog.cs

示例11: MultipleEventListenersLevel

    static void MultipleEventListenersLevel()
    {
      // Set up and enable the event listeners - typically done when the application starts
      var listener1 = new ObservableEventListener();
      var listener2 = new ObservableEventListener();
      listener1.EnableEvents(MyCompanyEventSource.Log, EventLevel.Error, Keywords.All);
      listener2.EnableEvents(MyCompanyEventSource.Log, EventLevel.LogAlways, Keywords.All);
      listener1.LogToConsole();

      var subscription = listener2.LogToFlatFile(@"C:\Temp\DemoSemanticLogging.log", new EventTextFormatter("===================", "==================="));

      // Log some messages
      MyCompanyEventSource.Log.Startup();
      MyCompanyEventSource.Log.Failure("Couldn't connect to server.");
      Console.WriteLine("Written two log messages.\nUsing a basic console listener and a Flat File listener to capture them.");
      Console.WriteLine("Only the critical message appears in the console, both appear in: \nC:\\Temp\\DemoSemanticLogging.log.\n");
      
      // Flush the sink
      subscription.Sink.FlushAsync().Wait();

      // Disable the event listener - typically done when the application terminates
      listener1.DisableEvents(MyCompanyEventSource.Log);
      listener2.DisableEvents(MyCompanyEventSource.Log);

      listener1.Dispose();
      listener2.Dispose();
    }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:27,代码来源:Program.cs

示例12: WhenFileNameIsFolder

 public void WhenFileNameIsFolder()
 {
     try
     {
         var formatter = new EventTextFormatter(EventTextFormatter.DashSeparator);
         using (var listener = new ObservableEventListener())
         {
             listener.LogToFlatFile(".", formatter);
         }
     }
     catch (ArgumentException ex)
     {
         Assert.AreEqual("A file name with a relative path is not allowed. Provide only the file name or the full path of the file.", ex.Message);
     }
 }
开发者ID:husains,项目名称:semantic-logging,代码行数:15,代码来源:FlatFileSinkFixture.cs

示例13: WhenInvalidCharactersInFileName1

 public void WhenInvalidCharactersInFileName1()
 {
     try
     {
         var formatter = new EventTextFormatter(EventTextFormatter.DashSeparator);
         using (var listener = new ObservableEventListener())
         {
             listener.LogToFlatFile(@"|", formatter);
         }
     }
     catch (ArgumentException ex)
     {
         Assert.AreEqual("Illegal characters in path.", ex.Message);
     }
 }
开发者ID:husains,项目名称:semantic-logging,代码行数:15,代码来源:FlatFileSinkFixture.cs

示例14: WhenFileNameIsEmpty

 public void WhenFileNameIsEmpty()
 {
     try
     {
         var formatter = new EventTextFormatter(EventTextFormatter.DashSeparator);
         using (var listener = new ObservableEventListener())
         {
             listener.LogToFlatFile(string.Empty, formatter);
         }
     }
     catch (ArgumentException ex)
     {
         Assert.AreEqual("Argument is empty\r\nParameter name: fileName", ex.Message);
     }
 }
开发者ID:husains,项目名称:semantic-logging,代码行数:15,代码来源:FlatFileSinkFixture.cs

示例15: WhenFilePathLengthExceedsMaxExceptionOccursEarly

        public void WhenFilePathLengthExceedsMaxExceptionOccursEarly()
        {
            try
            {
                var folderName = "a";
                string completePath = string.Empty;
                int countLength = Directory.GetCurrentDirectory().Length;
                int folderNameLength = 246 - countLength;
                for (int l = 1; l < folderNameLength; l++)
                {
                    folderName = folderName + "a";
                }

                completePath = DeleteFolder(folderName);
                Directory.CreateDirectory(completePath);
                var fileName = "longpath.log";
                var folderfilePath = completePath + "\\" + fileName;

                var formatter = new EventTextFormatter(EventTextFormatter.DashSeparator);
                using (var listener = new ObservableEventListener())
                {
                    listener.LogToFlatFile(folderfilePath, formatter);
                }

                Assert.IsFalse(File.Exists(folderfilePath));
            }
            catch (PathTooLongException ex)
            {
                Assert.AreEqual(ex.Message, "The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.");
            }
        }
开发者ID:husains,项目名称:semantic-logging,代码行数:31,代码来源:FlatFileSinkFixture.cs


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