本文整理汇总了C#中ILogger.Information方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.Information方法的具体用法?C# ILogger.Information怎么用?C# ILogger.Information使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogger
的用法示例。
在下文中一共展示了ILogger.Information方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteQueryToStream
public override async Task WriteQueryToStream(Stream stream, ILogger logger, Spec.Query query, CancellationToken cancellationToken)
{
using (var memoryBuffer = new MemoryStream(1024))
using (var streamWriter = new StreamWriter(memoryBuffer, utf8Encoding))
{
WriteQuery(new JsonWriter(streamWriter), query);
streamWriter.Flush();
var data = memoryBuffer.ToArray();
memoryBuffer.Seek(0, SeekOrigin.Begin);
if (logger.InformationEnabled())
{
string dataStr = Encoding.UTF8.GetString(data);
logger.Information("JSON query: {0}", dataStr);
}
var tokenHeader = BitConverter.GetBytes(query.token);
if (!BitConverter.IsLittleEndian)
Array.Reverse(tokenHeader, 0, tokenHeader.Length);
memoryBuffer.Write(tokenHeader, 0, tokenHeader.Length);
var lengthHeader = BitConverter.GetBytes(data.Length);
if (!BitConverter.IsLittleEndian)
Array.Reverse(lengthHeader, 0, lengthHeader.Length);
memoryBuffer.Write(lengthHeader, 0, lengthHeader.Length);
memoryBuffer.Write(data, 0, data.Length);
logger.Debug("Writing packet, {0} bytes", data.Length);
data = memoryBuffer.ToArray();
await stream.WriteAsync(data, 0, data.Length, cancellationToken);
}
}
示例2: ProductsController
static ProductsController()
{
Logger = Log.ForContext<ProductsController>();
Products = new Fixture().CreateMany<Product>(500).OrderBy(p => p.Id).ToList();
Logger.Information("created the products {ProductCount}", Products.Count());
}
示例3: PatchGame
private static void PatchGame(ILogger log)
{
log.Information("Creating {0}", Paths.PatchedAssemblyFolder);
Directory.CreateDirectory(Paths.PatchedAssemblyFolder);
log.Information("Loading original assembly {0}", Paths.OriginalAssembly);
var patcher = new AssemblyPatcher(Paths.OriginalAssembly, log);
patcher.EmbedHistory = false;
patcher.UseBackup = false;
log.Information("Patching");
patcher.PatchAssembly(typeof(W2PWMod.ModType).Assembly.Location);
log.Information("Saving patched file");
patcher.WriteTo(Paths.PatchedAssembly);
}
示例4: LoggingScope
internal LoggingScope(ILogger logger, string messageTemplate, params object[] propertyValues)
{
_Logger = logger;
_MessageTemplate = messageTemplate;
_PropertyValues = propertyValues;
_StopWatch = new Stopwatch();
_StopWatch.Start();
_Logger.Information($">> Started: \"{_MessageTemplate}\"", _PropertyValues);
}
示例5: NamedPipePoshGitServer
public NamedPipePoshGitServer(IRepositoryCache repoCache, ILifetimeScope lifetimeScope, ILogger log)
{
_log = log;
_cancellationTokenSource = new CancellationTokenSource();
_repoCache = repoCache;
_serializer = JsonSerializer.Create();
_lifetimeScope = lifetimeScope;
log.Information("Server started");
}
示例6: Setup
public void Setup()
{
_exception = new Exception("An Error");
_log = new LoggerConfiguration()
.WriteTo.Sink(new NullSink())
.CreateLogger();
// Ensure template is cached
_log.Information(_exception, "Hello, {Name}!", "World");
}
示例7: Before
public static void Before()
{
logger = new LoggerConfiguration()
.ReadFrom.AppSettings()
.Enrich.WithMachineName()
.Enrich.FromLogContext()
.CreateLogger();
Log.Logger = logger;
logger.Information("Logger has been initialized!");
}
示例8: NinjectCore
public NinjectCore(IKernel kernel, ILogger logger, ICoreSettings settings)
{
_kernel = kernel;
_logger = logger;
_settings = settings;
_logger.Information("Initializing Core.");
InitializeKernel();
InitializeExtensions();
_logger.Verbose("Core initilized.");
}
示例9: WindowMessageHook
public WindowMessageHook(
IEnumerable<IWindowMessageInterceptor> windowMessageInterceptors,
ILogger logger,
IConsumerThreadLoop consumerLoop)
{
this.windowMessageInterceptors = windowMessageInterceptors;
this.logger = logger;
this.consumerLoop = consumerLoop;
pendingMessages = new Queue<WindowMessageReceivedArgument>();
cancellationTokenSource = new CancellationTokenSource();
logger.Information($"Window message hook was constructed using {windowMessageInterceptors.Count()} interceptors.");
}
示例10: OneTimePhoneEmulatorDialogMonitor
public OneTimePhoneEmulatorDialogMonitor(ILogger logger)
{
_logger = logger;
_windowsPhoneEmulatorDialogMonitor = new WindowsPhoneEmulatorDialogMonitor(logger);
_timer = new Timer(1000);
_timer.Elapsed += (sender, e) => _windowsPhoneEmulatorDialogMonitor.ExecuteDialogSlapDown(msg =>
{
_logger.Information(msg);
_timer.Stop();
_timer = null;
_windowsPhoneEmulatorDialogMonitor = null;
});
_timer.Start();
}
示例11: WindowMessageHook
public WindowMessageHook(
IReadOnlyCollection<IWindowMessageInterceptor> windowMessageInterceptors,
ILogger logger,
IConsumerThreadLoop consumerLoop,
IMainWindowHandleContainer mainWindowHandleContainer)
{
this.windowMessageInterceptors = windowMessageInterceptors;
this.logger = logger;
this.consumerLoop = consumerLoop;
this.mainWindowHandleContainer = mainWindowHandleContainer;
pendingMessages = new Queue<WindowMessageReceivedArgument>();
cancellationTokenSource = new CancellationTokenSource();
logger.Information(
$"Window message hook was constructed using {windowMessageInterceptors.Count} interceptors.");
}
示例12: EfMigrator
public EfMigrator(string assemblyPath, string qualifiedDbConfigName, string appConfigPath, string connectionString, string connectionProvider,
ILogger logger)
{
_logger = logger;
appConfigPath = Path.GetFullPath(appConfigPath);
if (!File.Exists(appConfigPath))
{
throw new EfMigrationException($"The {nameof(appConfigPath)} '{appConfigPath}' must exist.");
}
var domainSetup = AppDomain.CurrentDomain.SetupInformation;
domainSetup.ConfigurationFile = appConfigPath;
_logger.Debug($"Prepared AppDomain setup using {appConfigPath} as the appconfig.");
var domainName = $"EfMigrator:{Guid.NewGuid()}";
_domain = AppDomain.CreateDomain(domainName, null, domainSetup);
_logger.Debug($"Created new AppDomain named {domainName}.");
var type = typeof(EfMigratorBackend);
var fullPath = Assembly.GetAssembly(typeof(EfMigratorBackend)).Location;
//var domain = AppDomain.CurrentDomain.GetAssemblies()
// .Where(x => !x.IsDynamic)
// .Where(x => !x.GlobalAssemblyCache)
// .Select(x => Path.GetDirectoryName(x.Location))
// .Distinct();
//var domains = string.Join(", ", domain);
//logger.Debug($"Loading assemblies into appDomain: {domains}.");
Debug.Assert(fullPath != null, "fullPath != null");
var migrator = (EfMigratorBackend) _domain.CreateInstanceFromAndUnwrap(fullPath, type.FullName);
_logger.Debug("Created new instance.");
migrator.Initialize(assemblyPath, qualifiedDbConfigName, connectionString, connectionProvider);
_logger.Debug($"Initialized new {nameof(EfMigratorBackend)} within {domainName}.");
CurrentMigration = migrator.GetCurrentMigration() ?? InitialDatabase;
var currentMigrationStr = CurrentMigration == InitialDatabase ? "$InitialDatabase" : CurrentMigration;
_logger.Information($"Current Migration is {currentMigrationStr}.");
_migratorBackend = migrator;
}
示例13: OnStart
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
_container = new UnityContainer();
AccidentalFish.ApplicationSupport.Core.Bootstrapper.RegisterDependencies(_container);
AccidentalFish.ApplicationSupport.Azure.Bootstrapper.RegisterDependencies(_container);
Domain.Bootstrapper.RegisterDependencies(_container);
Domain.Bootstrapper.RegisterInfrastructure(_container);
AccidentalFish.ApplicationSupport.Processes.Bootstrapper.RegisterDependencies(_container);
ILoggerFactory loggerFactory = _container.Resolve<ILoggerFactory>();
_logger = loggerFactory.CreateLongLivedLogger(new LoggerSource("com.accidentalfish.azurelinkboard.background.worker-role"));
_logger.Information("Starting background worker role instance");
return base.OnStart();
}
示例14: MessagePathConfigurator
public MessagePathConfigurator(IPathTemplatesProvider pathTemplateProvider, ILogger logger)
{
if (pathTemplateProvider == null) throw new ArgumentNullException("pathTemplateProvider");
if (logger == null) throw new ArgumentNullException("logger");
_logger = logger;
_pathTemplateProvider = pathTemplateProvider;
_pathTemplateProvider.PathTemplates.CollectionChanged += PathTemplatesCollectionChanged;
DefaultSavePath = AppDomain.CurrentDomain.BaseDirectory;
RenderLoadPaths();
if (LoadPaths.Any()) DefaultSavePath = LoadPaths.First();
_logger.Information(
"Default Message Save Path is Set to {DefaultSavePath}",
DefaultSavePath);
}
示例15: OnStart
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
var builder = new ContainerBuilder();
builder.RegisterType<FixItQueueManager>().As<IFixItQueueManager>();
builder.RegisterType<FixItTaskRepository>().As<IFixItTaskRepository>().SingleInstance();
builder.RegisterType<Logger>().As<ILogger>().SingleInstance();
container = builder.Build();
logger = container.Resolve<ILogger>();
bool result = base.OnStart();
logger.Information("MyFixItWorkerRole has been started");
return result;
}