本文整理汇总了C#中ILog.Info方法的典型用法代码示例。如果您正苦于以下问题:C# ILog.Info方法的具体用法?C# ILog.Info怎么用?C# ILog.Info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILog
的用法示例。
在下文中一共展示了ILog.Info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureTargetFile
static void EnsureTargetFile(string pathToLock, ILog log)
{
try
{
var directoryName = Path.GetDirectoryName(pathToLock);
if (!Directory.Exists(directoryName))
{
log.Info("Directory {0} does not exist - creating it now", pathToLock);
Directory.CreateDirectory(directoryName);
}
}
catch (IOException)
{
//Someone else did this under us
}
try
{
if (!File.Exists(pathToLock))
{
File.WriteAllText(pathToLock, "A");
}
}
catch (IOException)
{
//Someone else did this under us
}
}
示例2: DoLogDirectoryContent
public static void DoLogDirectoryContent(ILog logger, string directory)
{
if (logger == null)
throw new ArgumentNullException("logger");
bool exists = Directory.Exists(directory);
logger.Info("-- Logging directory content:");
logger.Info("Directory: '" + directory + "'");
logger.Info("Directory exists: " + exists);
if (exists)
{
string[] files = Directory.GetFiles(directory);
foreach (string file in files)
{
FileInfo fileInfo = new FileInfo(file);
logger.Info("File: '" + file + "' (size=" + fileInfo.Length + ")");
}
string[] directories = Directory.GetDirectories(directory);
foreach (string subDirectory in directories)
{
logger.Info("Directory: '" + subDirectory + "'");
}
}
logger.Info("--");
}
示例3: Main
static void Main(string[] args)
{
_log = LogManager.GetLogger("Queaso.ConsoleClient.Main");
try
{
_log.Info(l => l("Start client application..."));
_log.Info(l => l("Exercise 1 - Work with ChannelFactory & Channel"));
Exercise1();
_log.Info(l => l("Exercise 2 - Work with Client Proxies"));
Exercise2();
_log.Info(l => l("Behaviours"));
var customerProxy = new CustomerProxy();
customerProxy.IsThisAnException();
Thread.Sleep(50);
}
catch (Exception ex)
{
_log.Error(ex);
throw ex;
}
}
示例4: CallAllMethodsOnLog
protected void CallAllMethodsOnLog(ILog log)
{
Assert.IsTrue(log.IsDebugEnabled);
Assert.IsTrue(log.IsErrorEnabled);
Assert.IsTrue(log.IsFatalEnabled);
Assert.IsTrue(log.IsInfoEnabled);
Assert.IsTrue(log.IsWarnEnabled);
log.Debug("Testing DEBUG");
log.Debug("Testing DEBUG Exception", new Exception());
log.DebugFormat("Testing DEBUG With {0}", "Format");
log.Info("Testing INFO");
log.Info("Testing INFO Exception", new Exception());
log.InfoFormat("Testing INFO With {0}", "Format");
log.Warn("Testing WARN");
log.Warn("Testing WARN Exception", new Exception());
log.WarnFormat("Testing WARN With {0}", "Format");
log.Error("Testing ERROR");
log.Error("Testing ERROR Exception", new Exception());
log.ErrorFormat("Testing ERROR With {0}", "Format");
log.Fatal("Testing FATAL");
log.Fatal("Testing FATAL Exception", new Exception());
log.FatalFormat("Testing FATAL With {0}", "Format");
}
示例5: Main
private static int Main(string[] args)
{
var options = new Options();
if (CommandLine.Parser.Default.ParseArguments(args, options))
{
LogFactory.IsVerbose = options.Verbose;
Log = LogManager.GetCurrentClassLogger();
try
{
IReportBuilderFactory builderFactory = new ReportBuilderFactory();
var builder = builderFactory.Create();
builder.Build(options);
}
catch (AppException ex)
{
Log.Error(ex.Message);
Log.Info("Error occurs. Run sign -help to get more info.", ex);
return ex.ErrorCode;
}
catch (Exception ex)
{
Log.Error("Internal error. Run with -verbose to see more details");
Log.Info(ex.Message, ex);
return ErrorCodes.InternalError;
}
return ErrorCodes.Ok;
}
return ErrorCodes.ParserError;
}
示例6: Main
static void Main(string[] args)
{
var loggingSettings = new NameValueCollection
{
["configType"] = "FILE",
["configFile"] = "NLog.config"
};
LogManager.Adapter = new NLogLoggerFactoryAdapter(loggingSettings);
Logger = LogManager.GetLogger("NetworkRail.ScheduleParser.Console");
if (Logger.IsInfoEnabled)
Logger.Info("Starting up...");
const string url = "https://datafeeds.networkrail.co.uk/ntrod/CifFileAuthenticate?type=CIF_ALL_UPDATE_DAILY&day=toc-update-thu.CIF.gz";
var container = CifParserIocContainerBuilder.Build();
if (Logger.IsInfoEnabled)
Logger.Info("Dependency Injection container built.");
var scheduleManager = container.Resolve<IScheduleManager>();
var entites = scheduleManager.GetRecordsByScheduleFileUrl(url).ToList();
entites = scheduleManager.MergeScheduleRecords(entites).ToList();
scheduleManager.SaveScheduleRecords(entites);
Console.WriteLine("Press any key to close...");
Console.ReadLine();
}
示例7: BasicChannel
protected BasicChannel(EventMessage eventMessage, EventSocket eventSocket)
{
Log = LogProvider.GetLogger(GetType());
UUID = eventMessage.UUID;
lastEvent = eventMessage;
this.eventSocket = eventSocket;
Disposables.Add(
eventSocket.Events
.Where(x => x.UUID == UUID)
.Subscribe(
e =>
{
lastEvent = e;
if (e.EventName == EventName.ChannelAnswer)
{
Log.Info(() => "Channel [{0}] Answered".Fmt(UUID));
}
if (e.EventName == EventName.ChannelHangup)
{
Log.Info(() => "Channel [{0}] Hangup Detected [{1}]".Fmt(UUID, e.HangupCause));
HangupCallBack(e);
}
}));
}
示例8: OnStart
protected override void OnStart(string[] args)
{
_log = _log??LogManager.GetLogger(typeof(MainJobService));
ISchedulerFactory scheduler = new StdSchedulerFactory();
_sche = scheduler.GetScheduler();
_log.Info("starting scheduler...");
_sche.Start();
_log.Info("started scheduler...");
}
示例9: Intercept
public void Intercept(IInvocation invocation)
{
_logger = _logFactory.GetLogger(invocation.TargetType);
if (_logger.IsInfoEnabled) _logger.Info(_invocationLogStringBuilder.BuildLogString(invocation, InvocationPhase.Start));
try
{
invocation.Proceed();
if (_logger.IsInfoEnabled) _logger.Info(_invocationLogStringBuilder.BuildLogString(invocation, InvocationPhase.End));
}
catch (Exception ex)
{
if (_logger.IsErrorEnabled) _logger.Error(_invocationLogStringBuilder.BuildLogString(invocation, InvocationPhase.Error), ex);
throw;
}
}
示例10: CreateTransaction
/// <summary>
/// Create a new instance to generate a transaction to Punto Pagos
/// </summary>
/// <returns></returns>
public Transaction CreateTransaction()
{
if (_logger == null)
{
_logger = Log4NetLoggerProxy.GetLogger("PuntoPagos-sdk");
_logger.Info("Logger for log4net Start");
}
if(string.IsNullOrEmpty(_configuration.ClientKey) || string.IsNullOrEmpty(_configuration.ClientSecret))
{
if(string.IsNullOrEmpty(ConfigurationManager.AppSettings["PuntoPago-Secret"]))
throw new ArgumentNullException("PuntoPago-Secret", "The PuntoPago-Secret in AppSettings can not be null or empty");
if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["PuntoPago-Key"]))
throw new ArgumentNullException("PuntoPago-Key", "The PuntoPago-Key in AppSettings can not be null or empty");
if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["PuntoPago-Environment"]))
throw new ArgumentNullException("PuntoPago-Environment", "The PuntoPago-Environment in AppSettings can not be null or empty ");
_configuration.ClientSecret = ConfigurationManager.AppSettings["PuntoPago-Secret"];
_configuration.ClientKey = ConfigurationManager.AppSettings["PuntoPago-Key"];
_configuration.Environment = ConfigurationManager.AppSettings["PuntoPago-Environment"];
_logger.Debug("End configurate ClientSecret, ClientKey and Environment from AppSettings");
}
else
{
_logger.Debug("End configurate ClientSecret, ClientKey and Environment from Code");
}
return new Transaction(_configuration, PuntoPagoFactory.CreateAuthorization(_configuration, _logger),
PuntoPagoFactory.CreateExecutorWeb(_logger), _logger);
}
示例11: Pull
public void Pull(string workingDirectory, ILog log, IBounce bounce)
{
using (new DirectoryChange(workingDirectory)) {
log.Info("pulling git repo in: " + workingDirectory);
Git(bounce, "pull");
}
}
示例12: InitializeScheduling
private void InitializeScheduling()
{
_log = LogManager.GetLogger(typeof(JobService));
ISchedulerFactory sf = new StdSchedulerFactory();
_sched = sf.GetScheduler();
_log.Info("** Initialized **");
}
示例13: 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(),
}
});
}
}
示例14: Run
public static void Run(ILog log)
{
AppDomain.CurrentDomain.UnhandledException += (sender, args) => log.Error(args.ExceptionObject.ToString());
var configuration = new Configuration.Configuration();
var host = new ServiceHost(new WebSiteService(), new Uri(string.Format("http://{0}:{1}", Environment.MachineName, configuration.WebSiteHost)));
host.AddServiceEndpoint(typeof(IWebSiteService), new WebHttpBinding(), "")
.Behaviors.Add(new WebHttpBehavior { DefaultOutgoingResponseFormat = WebMessageFormat.Json, DefaultOutgoingRequestFormat = WebMessageFormat.Json });
host.Open();
log.Info("Web communication host has been successfully opened");
while (true)
{
try
{
new AutomatedPostReview(log, configuration).Run();
}
catch (Exception ex)
{
log.Error(ex.ToString());
}
Thread.Sleep(configuration.Timeout);
}
}
示例15: Start
public void Start(ConcoctConfiguration config, ILog log)
{
try {
var site = Assembly.LoadFrom(config.ApplicationAssemblyPath);
var types = site.GetTypes();
var httpApplicationType = types.Where(x => x.IsTypeOf<HttpApplication>()).First();
FileRouteHandler.MapPath = path => path.Replace("~", config.WorkingDirectory);
host = MvcHost.Create(
config.GetEndPoint(),
config.VirtualDirectoryOrPrefix,
config.WorkingDirectory,
httpApplicationType);
if(config.LogRequests)
host.RequestHandler.BeginRequest += (_, e) => log.Info("{0} {1}", e.Request.HttpMethod, e.Request.Url);
host.Start();
} catch(FileNotFoundException appNotFound) {
log.Error("Failed to locate {0}", appNotFound.FileName);
throw new ApplicationException("Failed to load application");
} catch(ReflectionTypeLoadException loadError) {
log.Error("Error applications.");
foreach(var item in loadError.LoaderExceptions) {
Console.Error.WriteLine(item);
}
throw new ApplicationException("Failed to load application", loadError);
}
}