本文整理汇总了C#中ILogFactory.GetLog方法的典型用法代码示例。如果您正苦于以下问题:C# ILogFactory.GetLog方法的具体用法?C# ILogFactory.GetLog怎么用?C# ILogFactory.GetLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogFactory
的用法示例。
在下文中一共展示了ILogFactory.GetLog方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
/// <summary>
/// Initializes the specified log factory.
/// </summary>
/// <param name="logFactory">The log factory.</param>
public static void Initialize(ILogFactory logFactory)
{
if (m_Initialized)
throw new Exception("The LogFactoryProvider has been initialized, you cannot initialize it again!");
m_LogFactory = logFactory;
GlobalLog = m_LogFactory.GetLog("Global");
m_Initialized = true;
}
示例2: PerformanceMonitor
public PerformanceMonitor(IRootConfig config, IEnumerable<IWorkItem> appServers, IWorkItem serverManager, ILogFactory logFactory)
{
m_PerfLog = logFactory.GetLog("Performance");
m_AppServers = appServers.ToArray();
m_ServerManager = serverManager;
m_Helper = new ProcessPerformanceCounterHelper(Process.GetCurrentProcess());
m_TimerInterval = config.PerformanceDataCollectInterval * 1000;
m_PerformanceTimer = new Timer(OnPerformanceTimerCallback);
}
示例3: PerformanceMonitor
public PerformanceMonitor(IRootConfig config, IEnumerable<IWorkItem> appServers, ILogFactory logFactory)
{
m_PerfLog = logFactory.GetLog("Performance");
m_AppServers = appServers.ToArray();
Process process = Process.GetCurrentProcess();
m_CpuCores = Environment.ProcessorCount;
var isUnix = Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX;
var instanceName = (isUnix || Platform.IsMono) ? string.Format("{0}/{1}", process.Id, process.ProcessName) : GetPerformanceCounterInstanceName(process);
SetupPerformanceCounters(instanceName);
m_TimerInterval = config.PerformanceDataCollectInterval * 1000;
m_PerformanceTimer = new Timer(OnPerformanceTimerCallback);
}
示例4: PerformanceMonitor
public PerformanceMonitor(IRootConfig config, IEnumerable<IWorkItem> appServers, ILogFactory logFactory)
{
m_AppServers = appServers.ToArray();
Process process = Process.GetCurrentProcess();
m_CpuCores = Environment.ProcessorCount;
var isUnix = Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX;
var instanceName = isUnix ? string.Format("{0}/{1}", process.Id, process.ProcessName) : process.ProcessName;
m_CpuUsagePC = new PerformanceCounter("Process", "% Processor Time", instanceName);
m_ThreadCountPC = new PerformanceCounter("Process", "Thread Count", instanceName);
m_WorkingSetPC = new PerformanceCounter("Process", "Working Set", instanceName);
m_PerfLog = logFactory.GetLog("Performance");
m_TimerInterval = config.PerformanceDataCollectInterval * 1000;
m_PerformanceTimer = new Timer(OnPerformanceTimerCallback);
}
示例5: Initialize
/// <summary>
/// Initializes the bootstrap with the configuration, config resolver and log factory.
/// </summary>
/// <param name="serverConfigResolver">The server config resolver.</param>
/// <param name="logFactory">The log factory.</param>
/// <returns></returns>
public virtual bool Initialize(Func<IServerConfig, IServerConfig> serverConfigResolver, ILogFactory logFactory)
{
if (m_Initialized)
throw new Exception("The server had been initialized already, you cannot initialize it again!");
if (logFactory != null && !string.IsNullOrEmpty(m_Config.LogFactory))
{
throw new ArgumentException("You cannot pass in a logFactory parameter, if you have configured a root log factory.", "logFactory");
}
IEnumerable<WorkItemFactoryInfo> workItemFactories;
using (var factoryInfoLoader = GetWorkItemFactoryInfoLoader(m_Config, logFactory))
{
var bootstrapLogFactory = factoryInfoLoader.GetBootstrapLogFactory();
logFactory = bootstrapLogFactory.ExportFactory.CreateExport<ILogFactory>();
LogFactory = logFactory;
m_GlobalLog = logFactory.GetLog(this.GetType().Name);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
try
{
workItemFactories = factoryInfoLoader.LoadResult(serverConfigResolver);
}
catch (Exception e)
{
if (m_GlobalLog.IsErrorEnabled)
m_GlobalLog.Error(e);
return false;
}
}
m_AppServers = new List<IWorkItem>(m_Config.Servers.Count());
IWorkItem serverManager = null;
//Initialize servers
foreach (var factoryInfo in workItemFactories)
{
IWorkItem appServer = InitializeAndSetupWorkItem(factoryInfo);
if (appServer == null)
return false;
if (factoryInfo.IsServerManager)
serverManager = appServer;
else if (!(appServer is IsolationAppServer))//No isolation
{
//In isolation mode, cannot check whether is server manager in the factory info loader
if (TypeValidator.IsServerManagerType(appServer.GetType()))
serverManager = appServer;
}
m_AppServers.Add(appServer);
}
if (serverManager != null)
m_ServerManager = serverManager;
if (!m_Config.DisablePerformanceDataCollector)
{
m_PerfMonitor = new PerformanceMonitor(m_Config, m_AppServers, serverManager, logFactory);
if (m_GlobalLog.IsDebugEnabled)
m_GlobalLog.Debug("The PerformanceMonitor has been initialized!");
}
if (m_GlobalLog.IsDebugEnabled)
m_GlobalLog.Debug("The Bootstrap has been initialized!");
try
{
RegisterRemotingService();
}
catch (Exception e)
{
if (m_GlobalLog.IsErrorEnabled)
m_GlobalLog.Error("Failed to register remoting access service!", e);
return false;
}
m_Initialized = true;
return true;
}
示例6: DefaultBootstrap
/// <summary>
/// Initializes a new instance of the <see cref="DefaultBootstrap"/> class.
/// </summary>
/// <param name="rootConfig">The root config.</param>
/// <param name="appServers">The app servers.</param>
/// <param name="logFactory">The log factory.</param>
public DefaultBootstrap(IRootConfig rootConfig, IEnumerable<IWorkItem> appServers, ILogFactory logFactory)
{
if (rootConfig == null)
throw new ArgumentNullException("rootConfig");
if (appServers == null)
throw new ArgumentNullException("appServers");
if(!appServers.Any())
throw new ArgumentException("appServers must have one item at least", "appServers");
if (logFactory == null)
throw new ArgumentNullException("logFactory");
m_RootConfig = rootConfig;
SetDefaultCulture(rootConfig);
m_AppServers = appServers.ToList();
m_GlobalLog = logFactory.GetLog(this.GetType().Name);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
if (!rootConfig.DisablePerformanceDataCollector)
{
m_PerfMonitor = new PerformanceMonitor(rootConfig, m_AppServers, null, logFactory);
if (m_GlobalLog.IsDebugEnabled)
m_GlobalLog.Debug("The PerformanceMonitor has been initialized!");
}
if (m_GlobalLog.IsDebugEnabled)
m_GlobalLog.Debug("The Bootstrap has been initialized!");
m_Initialized = true;
}
示例7: Initialize
/// <summary>
/// Initializes the bootstrap with the configuration, config resolver and log factory.
/// </summary>
/// <param name="serverConfigResolver">The server config resolver.</param>
/// <param name="logFactory">The log factory.</param>
/// <returns></returns>
public virtual bool Initialize(Func<IServerConfig, IServerConfig> serverConfigResolver, ILogFactory logFactory)
{
if (m_Initialized)
throw new Exception("The server had been initialized already, you cannot initialize it again!");
if (logFactory != null && !string.IsNullOrEmpty(m_Config.LogFactory))
{
throw new ArgumentException("You cannot pass in a logFactory parameter, if you have configured a root log factory.", "logFactory");
}
IEnumerable<WorkItemFactoryInfo> workItemFactories;
using (var factoryInfoLoader = GetWorkItemFactoryInfoLoader(m_Config, logFactory))
{
var bootstrapLogFactory = factoryInfoLoader.GetBootstrapLogFactory();
logFactory = bootstrapLogFactory.ExportFactory.CreateExport<ILogFactory>();
LogFactory = logFactory;
m_GlobalLog = logFactory.GetLog(this.GetType().Name);
try
{
workItemFactories = factoryInfoLoader.LoadResult(serverConfigResolver);
}
catch (Exception e)
{
if (m_GlobalLog.IsErrorEnabled)
m_GlobalLog.Error(e);
return false;
}
}
m_AppServers = new List<IWorkItem>(m_Config.Servers.Count());
//Initialize servers
foreach (var factoryInfo in workItemFactories)
{
IWorkItem appServer;
try
{
appServer = CreateWorkItemInstance(factoryInfo.ServerType);
if (m_GlobalLog.IsDebugEnabled)
m_GlobalLog.DebugFormat("The server instance {0} has been created!", factoryInfo.Config.Name);
}
catch (Exception e)
{
if (m_GlobalLog.IsErrorEnabled)
m_GlobalLog.Error(string.Format("Failed to create server instance {0}!", factoryInfo.Config.Name), e);
return false;
}
var setupResult = false;
try
{
setupResult = SetupWorkItemInstance(appServer, factoryInfo);
if (m_GlobalLog.IsDebugEnabled)
m_GlobalLog.DebugFormat("The server instance {0} has been initialized!", appServer.Name);
}
catch (Exception e)
{
m_GlobalLog.Error(e);
setupResult = false;
}
if (!setupResult)
{
if (m_GlobalLog.IsErrorEnabled)
m_GlobalLog.Error("Failed to setup server instance!");
return false;
}
m_AppServers.Add(appServer);
}
if (!m_Config.DisablePerformanceDataCollector)
{
m_PerfMonitor = new PerformanceMonitor(m_Config, m_AppServers, logFactory);
if (m_GlobalLog.IsDebugEnabled)
m_GlobalLog.Debug("The PerformanceMonitor has been initialized!");
}
if (m_GlobalLog.IsDebugEnabled)
m_GlobalLog.Debug("The Bootstrap has been initialized!");
m_Initialized = true;
return true;
//.........这里部分代码省略.........
示例8: DefaultBootstrap
/// <summary>
/// Initializes a new instance of the <see cref="DefaultBootstrap"/> class.
/// </summary>
/// <param name="rootConfig">The root config.</param>
/// <param name="appServers">The app servers.</param>
/// <param name="logFactory">The log factory.</param>
public DefaultBootstrap(IRootConfig rootConfig, IEnumerable<IWorkItem> appServers, ILogFactory logFactory)
{
if (rootConfig == null)
throw new ArgumentNullException("rootConfig");
if (appServers == null)
throw new ArgumentNullException("appServers");
if(!appServers.Any())
throw new ArgumentException("appServers must have one item at least", "appServers");
if (logFactory == null)
throw new ArgumentNullException("logFactory");
m_RootConfig = rootConfig;
m_AppServers = appServers.ToList();
m_GlobalLog = logFactory.GetLog(this.GetType().Name);
if (!rootConfig.DisablePerformanceDataCollector)
{
m_PerfMonitor = new PerformanceMonitor(rootConfig, m_AppServers, logFactory);
m_PerfMonitor.Collected += new EventHandler<PermformanceDataEventArgs>(m_PerfMonitor_Collected);
}
m_Initialized = true;
}
示例9: Initialize
/// <summary>
/// Initializes the bootstrap with the configuration, config resolver and log factory.
/// </summary>
/// <param name="serverConfigResolver">The server config resolver.</param>
/// <param name="logFactory">The log factory.</param>
/// <returns></returns>
public virtual bool Initialize(Func<IServerConfig, IServerConfig> serverConfigResolver, ILogFactory logFactory)
{
if (m_Initialized)
throw new Exception("The server had been initialized already, you cannot initialize it again!");
if (logFactory != null && !string.IsNullOrEmpty(m_Config.LogFactory))
{
throw new ArgumentException("You cannot pass in a logFactory parameter, if you have configured a root log factory.", "logFactory");
}
if(logFactory == null)
{
logFactory = GetBootstrapLogFactory(m_Config.LogFactory);
}
m_GlobalLog = logFactory.GetLog(this.GetType().Name);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
m_AppServers = new List<IManagedApp>(m_Config.Servers.Count());
IManagedApp serverManager = null;
//Initialize servers
foreach (var serverConfig in m_Config.Servers)
{
IManagedApp appServer;
try
{
var serverType = serverConfig.ServerType;
if(string.IsNullOrEmpty(serverType) && !string.IsNullOrEmpty(serverConfig.ServerTypeName))
{
var serverTypeProvider = m_Config.ServerTypes.FirstOrDefault(
t => t.Name.Equals(serverConfig.ServerTypeName, StringComparison.OrdinalIgnoreCase));
if (serverTypeProvider != null)
serverType = serverTypeProvider.Type;
}
if (string.IsNullOrEmpty(serverType))
throw new Exception("No server type configured or the configured server type was not found.");
appServer = CreateWorkItemInstance(serverType);
var serverMetadata = appServer.GetAppServerMetadata();
if (serverMetadata.IsServerManager)
serverManager = appServer;
if (m_GlobalLog.IsDebugEnabled)
m_GlobalLog.DebugFormat("The server instance {0} has been created!", serverConfig.Name);
}
catch (Exception e)
{
if (m_GlobalLog.IsErrorEnabled)
m_GlobalLog.Error(string.Format("Failed to create server instance {0}!", serverConfig.Name), e);
return false;
}
var exceptionSource = appServer as IExceptionSource;
if(exceptionSource != null)
exceptionSource.ExceptionThrown += new EventHandler<ErrorEventArgs>(exceptionSource_ExceptionThrown);
var setupResult = false;
try
{
setupResult = SetupWorkItemInstance(appServer, serverConfig);
if (m_GlobalLog.IsDebugEnabled)
m_GlobalLog.DebugFormat("The server instance {0} has been initialized!", appServer.Name);
}
catch (Exception e)
{
m_GlobalLog.Error(e);
setupResult = false;
}
if (!setupResult)
{
if (m_GlobalLog.IsErrorEnabled)
m_GlobalLog.Error("Failed to setup server instance!");
return false;
}
m_AppServers.Add(appServer);
}
if (!m_Config.DisablePerformanceDataCollector)
{
m_PerfMonitor = new PerformanceMonitor(m_Config, m_AppServers, serverManager, logFactory);
//.........这里部分代码省略.........