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


C# ILog.Log方法代码示例

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


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

示例1: SearchAsync

        /// <inheritdoc/>
        public override async Task<ElasticResponse> SearchAsync(
            string body,
            SearchRequest searchRequest,
            CancellationToken token,
            ILog log)
        {
            var stopwatch = Stopwatch.StartNew();

            var response = await Task.Run(() => client.SearchAsync<string>(
                                Index ?? "_all",
                                searchRequest.DocumentType,
                                body,
                                searchParams => SetRequestParameters(searchParams, searchRequest)),
                            token);

            stopwatch.Stop();

            log.Log(TraceEventType.Verbose, null, null, "Request: POST {0}", response.RequestUrl);
            log.Log(TraceEventType.Verbose, null, null, "Body:\n{0}", body);
            log.Log(TraceEventType.Verbose, null, null, "Response: {0} {1} (in {2}ms)", response.HttpStatusCode, response.HttpStatusCode.HasValue ? ((HttpStatusCode)response.HttpStatusCode).ToString() : "", stopwatch.ElapsedMilliseconds);

            if (!response.Success)
                throw new HttpRequestException("Response status code does not indicate success: 404 (Not Found).");

            return ParseResponse(response.Response, log);
        }
开发者ID:jarlrasm,项目名称:ElasticLINQ,代码行数:27,代码来源:ElasticNetConnection.cs

示例2: MyProcess

		static void MyProcess(ILog log)
		{
			log.Log(LogLevels.Diagnostic, "This is a diagnostic message");
			log.Log(LogLevels.Info, "This is an information message");
			log.Log(LogLevels.Warning, "This is a warning message");
			log.Log(LogLevels.Error, "This is an error message: {0}", 1234);
		}
开发者ID:eleven41,项目名称:Eleven41.Logging,代码行数:7,代码来源:Program.cs

示例3: Resolver

        async Task IBoot.Run(CancellationToken token)
        {
            IResolver resolver = new Resolver(new[] {"CH.IoC."});
            _log = resolver.Resolve<ILog>();
            _log.Log(1, "Boot 1");

            var tasks =
                new[]
                    {
                        "isolated\\0",
                        "isolated\\1",
                        "isolated\\2"
                    }
                .Select(path => Run(path, token))
                .ToArray(); // force start

            foreach (var task in tasks)
            {
                try
                {
                    await task;
                }
                catch (Exception ex)
                {
                    _log.Log(2, "Boot 2: " + ex);
                }
            }

            while (!token.IsCancellationRequested)
            {
                await Task.Delay(10, token);
            }
        }
开发者ID:tanglebones,项目名称:ch-ioc,代码行数:33,代码来源:Boot.cs

示例4: AngleSharpExaminer

        public AngleSharpExaminer(ILog log, Uri uri, string content)
        {
            var parser = new HtmlParser();
            _document = parser.Parse(content);
            _links = new HashSet<Uri>();

            foreach (var link in _document.Links)
            {
                var href = link.GetAttribute("href");
                if (string.IsNullOrWhiteSpace(href))
                {
                    log.Log(new LogMessage(LogType.Error, "A-tag has missing or empty href", uri));
                    continue;
                }

                href = href.Trim();

                if (href[0] == '#') continue;

                if (!Uri.IsWellFormedUriString(href, UriKind.RelativeOrAbsolute))
                {
                    log.Log(new LogMessage(LogType.Error, $"A-tag has invalid href ({href})", uri));
                    return;
                }

                try
                {
                    _links.Add(new Uri(uri, href));
                }
                catch (UriFormatException exception)
                {
                    log.Log(new LogMessage(LogType.Error, $"A-tag has invalid href ({href})", exception, uri));
                }
            }
        }
开发者ID:PentiaLabs,项目名称:InspectionCrawler,代码行数:35,代码来源:AngleSharpExaminer.cs

示例5: MyProcess

		static void MyProcess(ILog log)
		{
			log.Log(LogLevels.Diagnostic, "This is a diagnostic message");
			log.Log(LogLevels.Info, "This is an information message");
			log.Log(LogLevels.Warning, new Dictionary<string, object>()
				{
					{ "param2", "override2" }
				}, "This is a warning message");
			log.Log(LogLevels.Error, "This is an error message: {0}", 1234);
		}
开发者ID:eleven41,项目名称:Eleven41.Logging,代码行数:10,代码来源:Program.cs

示例6: DealException

        public virtual void DealException(ExceptionContext filterContext, ILog log)
        {
            if (!filterContext.ExceptionHandled) {
                this.BeforeDeal(filterContext);

                HandleErrorInfo model = null;
                string controllerName = (string)filterContext.RouteData.Values["controller"];
                string actionName = (string)filterContext.RouteData.Values["action"];

                var ex = filterContext.Exception.GetBaseException();
                log.Log(ex);

                model = this.GetHandleErrorInfo(ex, controllerName, actionName);

                ViewResult result = new ViewResult {
                    ViewName = this.ViewName,
                    ViewData = new ViewDataDictionary<HandleErrorInfo>(model),
                    TempData = filterContext.Controller.TempData
                };
                filterContext.Result = result;
                filterContext.ExceptionHandled = this.ExceptionHandled;
                filterContext.HttpContext.Response.Clear();
                filterContext.HttpContext.Response.StatusCode = this.StatusCode;
                filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;
            }
        }
开发者ID:gruan01,项目名称:MessageCenter,代码行数:26,代码来源:BaseExceptionHandler.cs

示例7: WriteSomeLogs

        private static void WriteSomeLogs(ILog logTunnel)
        {
            using (logTunnel.CreateScope("Starting somthing"))
            {
                logTunnel.Info("Test LogEntry {IntValue} {StringValue}", new
                                                                            {
                                                                                IntValue = 5,
                                                                                StringValue = "MyValue",
                                                                                Complex =
                                                                                    new ComplexData()
                                                                                    {
                                                                                        Complex2 =
                                                                                            new ComplexData()
                                                                                    },
                                                                            });

                logTunnel.Warning("My Warning");

                logTunnel.Log("Custom", "Non spesific log title");

                logTunnel.Error("Test LogEntry {*}", new
                                                        {
                                                            IntValue = 5,
                                                            StringValue = "MyValue",
                                                            Complex = new ComplexData()
                                                                      {
                                                                          //ExtraProp = 2,
                                                                          Complex2 = new ComplexDataDerived(),
                                                                      }
                                                        });

            }
        }
开发者ID:ronenbarak,项目名称:Whitelog,代码行数:33,代码来源:Program.cs

示例8: InternalLog

 private static void InternalLog(ILog log, LogLevel logLevel, string message, Exception exception = null)
 {
     if (log == null)
     {
         return;
     }
     log.Log(logLevel, message, exception);
 }
开发者ID:LojalnaJola,项目名称:SharpProject,代码行数:8,代码来源:LogExtensions.cs

示例9: Server

 public Server(ILog log)
 {
     _log = log;
     _client = new AsyncSocketClient();
     _client.Log += (sender, args) => {
         _log.Log(args.Level, args.Message, args.Exception, args.Args);
     };
     ReconnectAttempts = 0;
 }
开发者ID:jcapuano328,项目名称:dotnet-nats,代码行数:9,代码来源:Server.cs

示例10: DiscoveryServer

 public DiscoveryServer(ILog log, string host, int port)
 {
     this.log = log;
     subscriber = new UdpClient(port);
     IPAddress addr = IPAddress.Parse(host);
     subscriber.JoinMulticastGroup(addr);
     subscriber.BeginReceive(ReceiveCallback, subscriber);
     log.Log(LogLevel.Info, "Starting Discovery Server");
 }
开发者ID:djpnewton,项目名称:remote_trackpad,代码行数:9,代码来源:DiscoveryServer.cs

示例11: MainWindowViewModel

 public MainWindowViewModel(ILog log)
 {
     _log = log;
     _service = new Service();
     _service.HandleRequest += HandleServiceRequest;
     _serviceHost = new ServiceHost(_service);
     _serviceHost.Open();
     _log.Log(String.Format("The service is ready at {0}", _serviceHost.BaseAddresses.First()));
 }
开发者ID:jagui,项目名称:WebIntegrationPoc,代码行数:9,代码来源:MainWindowViewModel.cs

示例12: Log

			/// <summary>
			/// Log the message to the supplied event log.
			/// </summary>
			/// <param name="log"></param>
			public void Log(ILog log)
			{
				// If the item is too old, then forget about
				// trying to log it.
				if (DateTime.Now.Subtract(_DateTime) > _OldSpan)
					return;

				// Log using our information
				log.Log(_Level, _sMsg, _args);
			}
开发者ID:dineshkummarc,项目名称:Eleven41.Logging,代码行数:14,代码来源:ThreadedLog.cs

示例13: InputServer

 public InputServer(ILog log, IInputController inputController)
 {
     this.log = log;
     this.inputController = inputController;
     server = new OscServer(TransportType.Udp, IPAddress.Any, DEFAULT_VIP_PORT);
     server.RegisterMethod(JOYPAD_BUTTON_EVENT);
     server.RegisterMethod(MOUSE_EVENT);
     server.RegisterMethod(SCROLL_EVENT);
     server.RegisterMethod(KEYBOARD_EVENT);
     server.RegisterMethod(VOLUME_EVENT);
     server.MessageReceived += new OscMessageReceivedHandler(server_MessageReceived);
     server.Start();
     log.Log(LogLevel.Info, "Starting Input Server");
 }
开发者ID:djpnewton,项目名称:remote_trackpad,代码行数:14,代码来源:InputServer.cs

示例14: ParseResponse

		internal static ElasticResponse ParseResponse(string response, ILog log)
		{
			var stopwatch = Stopwatch.StartNew();

			using (var textReader = new JsonTextReader(new StringReader(response)))
			{
				var results = new JsonSerializer().Deserialize<ElasticResponse>(textReader);
				stopwatch.Stop();

				var resultSummary = string.Join(", ", GetResultSummary(results));

				log.Log(
					ElasticLinq.Logging.TraceEventType.Verbose, 
					null,
					null,
					"Deserialized {0} characters into {1} in {2}ms", 
					response.Length,
					resultSummary,
					stopwatch.ElapsedMilliseconds);

				return results;
			}
		}
开发者ID:FundsLibrary,项目名称:ElasticLINQ.ElasticsearchNet,代码行数:23,代码来源:ElasticNetConnection.cs

示例15: ExecuteIfExists

 public void ExecuteIfExists(string fileName, string command, string arguments, ILog log)
 {
     if (!HasFile(fileName))
     {
         log.Log(string.Format("({0} not present)", fileName));
         return;
     }
     ExecuteProcess(command, arguments, log);
 }
开发者ID:radius314,项目名称:gitdeployhub,代码行数:9,代码来源:Instance.cs


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