當前位置: 首頁>>代碼示例>>C#>>正文


C# ILog.InfoFormat方法代碼示例

本文整理匯總了C#中log4net.ILog.InfoFormat方法的典型用法代碼示例。如果您正苦於以下問題:C# ILog.InfoFormat方法的具體用法?C# ILog.InfoFormat怎麽用?C# ILog.InfoFormat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在log4net.ILog的用法示例。


在下文中一共展示了ILog.InfoFormat方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ElasticCasFactory

        public ElasticCasFactory(string name)
        {
            // Init Log
            Logger = LogManager.GetLogger(name);

            if (Settings.Exists()) {
                Logger.InfoFormat("Using ElasticSearch Host : {0}", Settings.ElasticSearchServer);
            } else {
                Logger.InfoFormat("No ElasticSearch Host specified, using default : {0}", Settings.ElasticSearchServer);
            }

            client = new ElasticClientWrapper();
            Logger.InfoFormat("New ElasticSearch Connection from {0}", name);
        }
開發者ID:Terradue,項目名稱:DotNetElasticCas,代碼行數:14,代碼來源:ElasticCasFactory.cs

示例2: ViewBuilder

        public ViewBuilder()
        {
            _logger = log4net.LogManager.GetLogger(this.GetType());

            Type genericMessageHandlerType = typeof (IHandleMessages<>);
            var eventStore = new PersistenceWireup(
                Wireup.Init()
                    .UsingRavenPersistence("MembershipEventStore")
                )
                .InitializeStorageEngine()
                .Build();

            var container = BootstrapMessageHandlers();

            var commits = eventStore.Advanced.GetFrom(new DateTime(1900, 1, 1));
            foreach (var commit in commits)
            {
                foreach (var @event in commit.Events.Select(x => x.Body))
                {
                    Type eventType = @event.GetType();
                    _logger.InfoFormat("Handling event '{0}'", @eventType.Name);
                    Type specificEventHandlerType = genericMessageHandlerType.MakeGenericType(eventType);
                    Type enumerableOfEventHandlerType = typeof (IEnumerable<>).MakeGenericType(specificEventHandlerType);
                    var handlers = container.Resolve(enumerableOfEventHandlerType) as IEnumerable;
                    bool hadHandlers = false;
                    if (handlers != null)
                    {
                        foreach (var handler in handlers)
                        {
                            hadHandlers = true;
                            _logger.InfoFormat("  Processing event with handler {0}", handler.GetType());
                            var genericHandleMethod =
                                handler.GetType().GetMethods().Where(
                                    m => m.Name == "Handle" && m.GetParameters()[0].ParameterType == eventType).
                                    SingleOrDefault();
                            if (genericHandleMethod != null)
                            {
                                genericHandleMethod.Invoke(handler, new object[]{ @event });
                            }
                        }
                    }
                    if (!hadHandlers)
                    {
                        _logger.InfoFormat("No handlers found for event type {0}", eventType.Name);
                    }
                }
            }
        }
開發者ID:thatpaulschofield,項目名稱:LifeMap,代碼行數:48,代碼來源:Program.cs

示例3: GetProviderFromConfigName

        public static IGroupDataProvider GetProviderFromConfigName(ILog log, IConfig groupsConfig, string configName)
        {
            switch (configName)
            {
                case "XmlRpc":
                    string ServiceURL = groupsConfig.GetString("XmlRpcServiceURL");
                    bool DisableKeepAlive = groupsConfig.GetBoolean("XmlRpcDisableKeepAlive", false);

                    string ServiceReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", String.Empty);
                    string ServiceWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", String.Empty);

                    log.InfoFormat("[GROUPS]: XmlRpc Service URL set to: {0}", ServiceURL);

                    return new XmlRpcGroupDataProvider(ServiceURL, DisableKeepAlive, ServiceReadKey, ServiceWriteKey);


                case "Native":
                    string dbType = groupsConfig.GetString("NativeProviderDBType");
                    string connStr = groupsConfig.GetString("NativeProviderConnString");

                    ConnectionFactory connFactory = new ConnectionFactory(dbType, connStr);
                    return new NativeGroupDataProvider(connFactory);

            }

            return null;
        }
開發者ID:kf6kjg,項目名稱:halcyon,代碼行數:27,代碼來源:ProviderFactory.cs

示例4: PrintVersion

 static void PrintVersion(ILog log)
 {
     var assembly = Assembly.GetExecutingAssembly();
     var attr = assembly.GetCustomAttribute<AssemblyVersionAttribute>();
     var version = attr == null ? "FIXME" : attr.Version;
     log.InfoFormat("nsq_rand {0}", version);
 }
開發者ID:xzoth,項目名稱:NSQnet,代碼行數:7,代碼來源:Program.cs

示例5: RunProcess

        protected void RunProcess(string executablePath, string executableArgs, ILog logger)
        {
            logger.InfoFormat("{0} {1}", executablePath, executableArgs);
            var msDeploy = new Process
                               {
                                   StartInfo =
                                       {
                                           UseShellExecute = false,
                                           RedirectStandardError = true,
                                           RedirectStandardOutput = true,
                                           FileName = executablePath,
                                           Arguments = executableArgs
                                       }
                               };
            msDeploy.Start();

            while (!msDeploy.HasExited)
            {
                var output = msDeploy.StandardOutput.ReadToEnd();
                var error = msDeploy.StandardError.ReadToEnd();

                logger.Info(output);
                if (error.Length > 0)
                {
                    logger.Error(error);
                    throw new ApplicationException("An error occurred running process '"+Path.GetFileName(executablePath)+"'",
                        new Exception(error));
                }

                msDeploy.WaitForExit(2000);
            }
        }
開發者ID:repne,項目名稱:DeployD,代碼行數:32,代碼來源:DeploymentHookBase.cs

示例6: LogScope

 public LogScope(ILog log, string format, params object[] args)
 {
     this.log = log;
     message = String.Format(format, args);
     log.InfoFormat("Begin: {0}", message);
     stopwatch = Stopwatch.StartNew();
 }
開發者ID:sidiandi,項目名稱:ttaudio,代碼行數:7,代碼來源:LogScope.cs

示例7: AssemblyConfiguration

 protected AssemblyConfiguration(Dictionary<string, object> defaultValues, ILog logger)
 {
     NameValueCollection nameValues = ConfigurationManager.AppSettings;
     CreateConfiguration(defaultValues, nameValues);
     foreach (KeyValuePair<string, string> pair in usedValues)
         logger.InfoFormat("Using {0}={1}", pair.Key, pair.Value);
 }
開發者ID:domik82,項目名稱:bricks-toolkit,代碼行數:7,代碼來源:AssemblyConfiguration.cs

示例8: remoteCall

        private static HttpResponse remoteCall( int bufmax, ILog log, HttpWebRequest request )
        {
            HttpWebResponse response;
            try
            {
                response = request.GetResponse() as HttpWebResponse;
            }
            catch (WebException e)
            {
                response = e.Response as HttpWebResponse;
            }
            Stream receiveStream = response.GetResponseStream();
            Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
            StreamReader readStream = new StreamReader(receiveStream, encode);
            Char[] read = new Char[bufmax];
            int count = readStream.Read(read, 0, bufmax);
            if (count == bufmax)
                throw new Exception("buf is small ");

            HttpResponse callRespon = new HttpResponse();
            callRespon.body = new String(read, 0, count);
            callRespon.status = response.StatusCode.ToString();
            log.InfoFormat("[GET] status {0} body:{1}", callRespon.status, callRespon.body);
            response.Close();
            readStream.Close();
            return callRespon;
        }
開發者ID:xcodecraft,項目名稱:pylon4net,代碼行數:27,代碼來源:utls.cs

示例9: LogMessages

 internal static void LogMessages(ILog log)
 {
     log.Info("This is an info");
     log.InfoFormat("Base called at {0}", DateTime.Now);
     log.Debug("This is a debug");
     log.Warn("This is a warning");
     log.Error("This is an error");
 }
開發者ID:Slesa,項目名稱:Playground,代碼行數:8,代碼來源:Program.cs

示例10: Info

        public static void Info(ILog log, string format, params object[] @params)
        {
            if (log == null)
            {
                return;
            }

            log.InfoFormat(format, @params);
        }
開發者ID:MrBretticus,項目名稱:JustGiving.EventStore.Http,代碼行數:9,代碼來源:Log.cs

示例11: CreateBlock

    public static ActionBlock<StatsdMessage> CreateBlock(ITargetBlock<Bucket> target,
      string rootNamespace, 
      bool removeZeroGauges,
      IIntervalService intervalService,
      ILog log)
    {
      var gauges = new ConcurrentDictionary<string, double>();
      var root = rootNamespace;
      var ns = String.IsNullOrEmpty(rootNamespace) ? "" : rootNamespace + ".";

      var incoming = new ActionBlock<StatsdMessage>(p =>
        {
          var gauge = p as Gauge;
          gauges.AddOrUpdate(gauge.Name, gauge.Value, (key, oldValue) => gauge.Value);
        },
        Utility.UnboundedExecution());

      intervalService.Elapsed += (sender, e) =>
        {
          if (gauges.Count == 0)
          {
            return;
          }
          var items = gauges.ToArray();
          var bucket = new GaugesBucket(items, e.Epoch, ns);
          if (removeZeroGauges)
          {
            // Get all zero-value gauges
            double placeholder;
            var zeroGauges = 0;
            for (int index = 0; index < items.Length; index++)
            {
              if (items[index].Value == 0)
              {
                gauges.TryRemove(items[index].Key, out placeholder);
                zeroGauges += 1;
              }
            }
            if (zeroGauges > 0)
            {
              log.InfoFormat("Removed {0} empty gauges.", zeroGauges);
            }
          }
          
          gauges.Clear();
          target.Post(bucket);
        };

      incoming.Completion.ContinueWith(p =>
        {
          // Tell the upstream block that we're done
          target.Complete();
        });
      return incoming;
    }
開發者ID:houcine,項目名稱:statsd.net,代碼行數:55,代碼來源:TimedGaugeAggregatorBlockFactory.cs

示例12: AddInfoLog

        public void AddInfoLog(ILog logger)
        {
            object[] args = new object[4];

            if (!string.IsNullOrEmpty(Data))
            {
                args[0] = LogProcess;
                args[1] = User;
                args[2] = Data;
                args[3] = Message;
                logger.InfoFormat("[{0}] [{1}] [{2}] [{3}]", args);
            }
            else
            {
                args[0] = LogProcess;
                args[1] = User;
                args[2] = Message;
                logger.InfoFormat("[{0}] [{1}] [{2}] ", args);
            }
        }
開發者ID:miyamotomusashi,項目名稱:argemsan,代碼行數:20,代碼來源:LogtrackManager.cs

示例13: ServerHostTestFixture

        // Test-ClassInitialize
        public ServerHostTestFixture()
        {
            this.className = GetType().Name;

            // Set up the log4net configuration.
            BasicConfigurator.Configure();

            this.log = LogManager.GetLogger(className);

            log.InfoFormat("{0} - Initialize", className);
        }
開發者ID:jthelin,項目名稱:ServerHost,代碼行數:12,代碼來源:ServerHostTestFixture.cs

示例14: AssemblyConfiguration

 protected AssemblyConfiguration(string sectionGroup, string sectionName, Dictionary<string, object> defaultValues, ILog logger)
 {
     var nameValues = (NameValueCollection)ConfigurationManager.GetSection(sectionGroup + "/" + sectionName);
     if (logger == null) logger = LogManager.GetLogger(typeof (AssemblyConfiguration));
     if (nameValues == null)
     {
         nameValues = new NameValueCollection();
     }
     CreateConfiguration(defaultValues, nameValues);
     foreach (KeyValuePair<string, string> pair in usedValues)
         logger.InfoFormat("Using {0}={1} for {2}/{3}", pair.Key, pair.Value, sectionGroup, sectionName);
 }
開發者ID:huangzhichong,項目名稱:White,代碼行數:12,代碼來源:AssemblyConfiguration.cs

示例15: GetDeployments

    public static IEnumerable<string> GetDeployments(this IOctopusSession session, Release release, IEnumerable<DeploymentEnvironment> environments, bool force, ILog log)
    {
        var linksToDeploymentTasks = new List<string>();
        foreach (var environment in environments)
        {
            var deployment = session.DeployRelease(release, environment, force);
            var linkToTask = deployment.Link("Task");
            linksToDeploymentTasks.Add(linkToTask);

            log.InfoFormat("Successfully scheduled release {0} for deployment to environment {1}", release.Version, environment.Name);
        }
        return linksToDeploymentTasks;
    }
開發者ID:Jroland,項目名稱:Octopus-Tools,代碼行數:13,代碼來源:DeploymentExtensions.cs


注:本文中的log4net.ILog.InfoFormat方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。