本文整理汇总了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);
}
示例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);
}
}
}
}
示例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;
}
示例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);
}
示例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);
}
}
示例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();
}
示例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);
}
示例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;
}
示例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");
}
示例10: Info
public static void Info(ILog log, string format, params object[] @params)
{
if (log == null)
{
return;
}
log.InfoFormat(format, @params);
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}