本文整理汇总了C#中log4net.ILog.Fatal方法的典型用法代码示例。如果您正苦于以下问题:C# ILog.Fatal方法的具体用法?C# ILog.Fatal怎么用?C# ILog.Fatal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类log4net.ILog
的用法示例。
在下文中一共展示了ILog.Fatal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SalesManagerService
public SalesManagerService()
{
InitializeComponent();
log4net.Config.XmlConfigurator.Configure();
_logger = LogManager.GetLogger("Windows Service");
ApplicationConfigValidator validator = new ApplicationConfigValidator();
try
{
validator.Validate();
_serverFolderPath = ConfigurationManager.AppSettings["ServerFolder"];
_wrongFilesFolderPath = ConfigurationManager.AppSettings["NotAppropriateFilesFolder"];
_processedFiles = ConfigurationManager.AppSettings["ProcessedFilesFolder"];
_cancelationTokenSource = new CancellationTokenSource();
var taskScheduler =
new LimitedTaskScheduler(Int32.Parse(ConfigurationManager.AppSettings["MaxDatabaseConnections"]));
_taskFactory = new TaskFactory(taskScheduler);
_fileHandler = new FileHandler();
}
catch (ConfigurationErrorsException ex)
{
_logger.Fatal("Eroor occurs with configuration. " + ex.Message);
return;
}
catch (ArgumentOutOfRangeException ex)
{
_logger.Fatal("Erorr occurs with max number of connections to database. " + ex.Message);
return;
}
}
示例2: AddFatalLog
public void AddFatalLog(ILog logger,Exception errormessage)
{
if (!string.IsNullOrEmpty(Data))
{
object[] args = new object[4];
args[0] = LogProcess;
args[1] = User;
args[2] = Data;
args[3] = Message;
string ermes = string.Format("[{0}] [{1}] [{2}] [{3}]", args);
logger.Fatal(ermes, errormessage);
}
else
{
object[] args = new object[4];
args[0] = LogProcess;
args[1] = User;
args[2] = Message;
string ermes = string.Format("[{0}] [{1}] [{2}] ", args);
logger.Fatal(ermes, errormessage);
}
}
示例3: AgentService
public AgentService()
{
logger = LogManager.GetLogger("AgentService");
logger.Info("AgentService initializing...");
// TODO: Extract class ConfigurationManager
// Read controller address
if (ConfigurationManager.AppSettings["ControllerAddress"] == null)
{
logger.Fatal("ControllerAddress setting not found in App.config file!");
throw new Exception("ControllerAddress setting not found in App.config file!");
}
var controllerAddress = ConfigurationManager.AppSettings["ControllerAddress"];
// Read controller port
if (ConfigurationManager.AppSettings["ControllerPort"] == null)
{
logger.Fatal("ControllerPort setting not found in App.config file!");
throw new Exception("ControllerPort setting not found in App.config file!");
}
int controllerPort;
if (!int.TryParse(ConfigurationManager.AppSettings["ControllerPort"], out controllerPort))
{
logger.Fatal("ControllerPort setting is not an integer!");
throw new Exception("ControllerPort setting is not an integer!");
}
// Read threads count value
int threadsCount;
if (ConfigurationManager.AppSettings["ThreadsCount"] != null)
{
if (!int.TryParse(ConfigurationManager.AppSettings["ThreadsCount"], out threadsCount))
{
threadsCount = DefaultThreadsCount;
}
}
else
{
threadsCount = DefaultThreadsCount;
}
// Create clients
this.clients = new List<AgentClient>();
for (var i = 1; i <= threadsCount; i++)
{
var client = new AgentClient(controllerAddress, controllerPort, logger);
this.clients.Add(client);
}
logger.Info("AgentService initialized.");
}
示例4: Main
static void Main(string[] args)
{
Logger = LogManager.GetLogger("default");
try
{
Logger.DebugFormat("Server powered up");
Logger.DebugFormat("Loading configuration");
ConfigManager.LoadConfigs();
string addr = ConfigManager.GetConfig("GameServer.ListenAddress");
string port = ConfigManager.GetConfig("GameServer.ListenPort");
Logger.DebugFormat("Trying to listen at {0}:{1}", addr, port);
TcpListener listener = new TcpListener(new IPEndPoint(IPAddress.Parse(addr), Convert.ToInt32(port)));
listener.Start();
while (true)
{
TcpClient client = listener.AcceptTcpClient();
ClientServant servant = new ClientServant(client);
Program.Logger.DebugFormat("New client connected from: {0}", servant.ClientIPEndPoint);
servant.Start();
}
}
catch (Exception e)
{
Logger.FatalFormat("Unhandled exception: {0}, stacktrace: {1}", e.Message, e.StackTrace);
Logger.Fatal("Server shutdown");
}
}
示例5: Application_Start
protected void Application_Start()
{
AppDomain.CurrentDomain.UnhandledException += Application_Error;
try
{
XmlConfigurator.Configure();
AppLogger = LogManager.GetLogger(GetType());
AppLogger.Info("Application_Start...");
AppLogger.Info("Bootstrapping the container...");
Container = ContainerConfig.Config(AppLogger);
AppLogger.Info("Setting the Controller Factory...");
var controllerFactory = new WindsorControllerFactory(Container.Kernel);
ControllerBuilder.Current.SetControllerFactory(controllerFactory);
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
AuthConfig.RegisterAuth();
}
catch (Exception ex)
{
AppLogger.Fatal("Application_Start FAILED", ex);
throw;
}
}
示例6: Application_Error
protected void Application_Error(object sender, EventArgs e)
{
_logger = ServiceLocator.Current.GetInstance<ILog>();
_logger.Fatal("An unhandled exception occurred in ASP.NET processing: " + Server.GetLastError(), Server.GetLastError());
//DataManager.Dispose();
}
示例7: Fatal
public static void Fatal(System.Type type, object message)
{
logger = LogManager.GetLogger(type);
if (!logger.Logger.Repository.Configured)
XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(GetConfigFile() + ".config"));
logger.Fatal(message);
}
示例8: Main
static void Main(string[] args)
{
ApplicationConfigValidator validator = new ApplicationConfigValidator();
log4net.Config.XmlConfigurator.Configure();
_logger = LogManager.GetLogger("Console application");
try
{
validator.Validate();
_serverFolderPath = ConfigurationManager.AppSettings["ServerFolder"];
_wrongFilesFolderPath = ConfigurationManager.AppSettings["NotAppropriateFilesFolder"];
_processedFiles = ConfigurationManager.AppSettings["ProcessedFilesFolder"];
var taskScheduler =
new LimitedTaskScheduler(Int32.Parse(ConfigurationManager.AppSettings["MaxDatabaseConnections"]));
_taskFactory = new TaskFactory(taskScheduler);
_fileHandler = new FileHandler();
}
catch (ConfigurationErrorsException ex)
{
_logger.Fatal("Eroor occurs with configuration. " + ex.Message);
return;
}
catch (ArgumentOutOfRangeException ex)
{
_logger.Fatal("Erorr occurs with max number of connections to database. " + ex.Message);
return;
}
ScanServerFolder();
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = _serverFolderPath;
watcher.Filter = "*.csv";
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.EnableRaisingEvents = true;
Console.Read();
}
示例9: Write
public static void Write(string msg, LogLevel lv = LogLevel.INFO)
{
log4net.GlobalContext.Properties["LogName"] = string.Format("{0}.{1}.log", DateTime.Now.ToString("yyyy-MM-dd"), lv.ToString().ToLower());
_Log = LogManager.GetLogger(typeof(LogHelper));
switch (lv)
{
case LogLevel.ALL: _Log.Info(msg); break;
case LogLevel.DEBUG: _Log.Debug(msg); break;
case LogLevel.ERROR: _Log.Error(msg); break;
case LogLevel.FATAL: _Log.Fatal(msg); break;
case LogLevel.INFO: _Log.Info(msg); break;
case LogLevel.WARN: _Log.Warn(msg); break;
default:
_Log.Info(msg); break;
}
}
示例10: App
public App()
{
log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
log.Info("程序启动");
try
{
log.Info("启动初始化启动窗口");
SplashScreen splashScreen = new SplashScreen("icons/SplashScreen.png");
splashScreen.Show(true);
}
catch (Exception ex)
{
log.Fatal("初始化启动窗口出错", ex);
}
}
示例11: ReadAndValidate
public static ExtensionPointsConfiguration ReadAndValidate(ILog logger)
{
Contract.Requires(logger != null, "ExtensionPointsConfigurationValidator:Validate - logger cannot be null!");
logger.Info("Validating configuration started");
ExtensionPointsConfiguration extensionPointsConfiguration = null;
try
{
extensionPointsConfiguration = TryRetrieveConfigurationObject();
}
catch(Exception ex)
{
logger.Fatal("Validation failed: " + ex.Message);
return null;
}
logger.Info("Validating configuration finished");
return extensionPointsConfiguration;
}
示例12: ExecuteScriptIfFoundInPackage
private void ExecuteScriptIfFoundInPackage(DeploymentContext context, string scriptPath, ILog logger)
{
var file = context.Package.GetFiles().SingleOrDefault(f => f.Path.Equals(scriptPath, StringComparison.InvariantCultureIgnoreCase));
if (file == null)
{
return;
}
logger.DebugFormat("Found script {0}, executing...", scriptPath);
try
{
LoadAndExecuteScript(context, Path.Combine(context.WorkingFolder, file.Path), logger);
}
catch (Exception ex)
{
logger.Fatal("Failed executing powershell script " + file.Path, ex);
}
}
示例13: OnStart
protected override void OnStart(string[] args)
{
_log = LogManager.GetLogger(this.GetType());
_isStopping = false;
try
{
_log.Info("Starting minecraft");
MinecraftConfig config = ConfigurationManager.GetSection(
typeof(MinecraftConfig).Name) as MinecraftConfig;
Process startCmd = new Process();
startCmd.StartInfo.FileName = config.JavaExecutable;
startCmd.StartInfo.Arguments = string.Format("-Xmx{0}M -Xms{1}M -jar {2}\\minecraft_server.jar nogui",
config.MaxHeapInMegabytes, config.InitialHeapInMegabytes, config.MinecraftJarDirectory);
startCmd.StartInfo.WorkingDirectory = config.MinecraftJarDirectory;
startCmd.StartInfo.UseShellExecute = false;
startCmd.StartInfo.RedirectStandardInput = true;
startCmd.StartInfo.RedirectStandardOutput = true;
startCmd.StartInfo.RedirectStandardError = true;
startCmd.EnableRaisingEvents = true;
startCmd.OutputDataReceived += new DataReceivedEventHandler(startCmd_OutputDataReceived);
startCmd.ErrorDataReceived += new DataReceivedEventHandler(startCmd_ErrorDataReceived);
startCmd.Exited += new EventHandler(startCmd_Exited);
_log.InfoFormat("Executing '{0} {1}'", startCmd.StartInfo.FileName, startCmd.StartInfo.Arguments);
startCmd.Start();
startCmd.BeginOutputReadLine();
startCmd.BeginErrorReadLine();
_standardInput = startCmd.StandardInput;
}
catch (Exception ex)
{
_log.Fatal("Failed to start minecraft", ex);
}
}
示例14: Log
private void Log(ILog log, Log4NetAttribute.Levels level, string strText)
{
switch(level)
{
case Log4NetAttribute.Levels.DEBUG:
log.Debug(strText);
break;
case Log4NetAttribute.Levels.ERROR:
log.Error(strText);
break;
case Log4NetAttribute.Levels.FATAL:
log.Fatal(strText);
break;
case Log4NetAttribute.Levels.INFO:
log.Info(strText);
break;
case Log4NetAttribute.Levels.WARN:
log.Warn(strText);
break;
}
}
示例15: Log
public void Log(string message, LogLevel level, Type type)
{
_log = LogManager.GetLogger(type);
switch (level)
{
case LogLevel.Info:
_log.Info(message);
break;
case LogLevel.Debug:
_log.Debug(message);
break;
case LogLevel.Warn:
_log.Warn(message);
break;
case LogLevel.Fatal:
_log.Fatal(message);
break;
case LogLevel.Error:
_log.Error(message);
break;
default:
throw new ArgumentOutOfRangeException("level");
}
}