当前位置: 首页>>代码示例>>C#>>正文


C# ILog.FatalFormat方法代码示例

本文整理汇总了C#中log4net.ILog.FatalFormat方法的典型用法代码示例。如果您正苦于以下问题:C# ILog.FatalFormat方法的具体用法?C# ILog.FatalFormat怎么用?C# ILog.FatalFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在log4net.ILog的用法示例。


在下文中一共展示了ILog.FatalFormat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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");
     }
 }
开发者ID:hoxily,项目名称:Wuziqi,代码行数:27,代码来源:Program.cs

示例2: XInputDll

        /// <summary>
        ///     Initializes library.
        /// </summary>
        static XInputDll()
        {
            Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

            Log.InfoFormat("Library loaded by process {0} [{1}]",
                Process.GetCurrentProcess().ProcessName,
                Process.GetCurrentProcess().MainWindowTitle);

            var myself = Assembly.GetExecutingAssembly().GetName();
            var myPath = Assembly.GetExecutingAssembly().Location;
            var myName = Path.GetFileName(myPath);

            Log.InfoFormat("Initializing library {0} [{1}]", myName, myself.Version);

            try
            {
                var basePath = BasePath;
                Log.DebugFormat("ScpToolkit bin path: {0}", basePath);
                var controlPath = ScpControlPath;
                Log.DebugFormat("ScpControl bin path: {0}", controlPath);

                // resolve assembly dependencies
                AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
                {
                    var asmName = new AssemblyName(args.Name).Name;
                    var asmPath = Path.Combine(basePath, string.Format("{0}.dll", asmName));

                    Log.DebugFormat("Loading assembly {0} from {1}", asmName, asmPath);

                    return Assembly.LoadFrom(asmPath);
                };

                var scpControl = Assembly.LoadFrom(controlPath);
                var scpProxyType = scpControl.GetType("ScpControl.ScpProxy");

                Proxy = Activator.CreateInstance(scpProxyType);

                Proxy.Start();
            }
            catch (Exception ex)
            {
                Log.FatalFormat("Error during library initialization: {0}", ex);
                return;
            }

            // if no custom path specified by user, use DLL in system32 dir
            var xinputPath = !string.IsNullOrEmpty(XInputDllPath) && File.Exists(XInputDllPath)
                ? XInputDllPath
                : Path.Combine(Environment.SystemDirectory, myName);
            Log.DebugFormat("Original XInput DLL path: {0}", xinputPath);

            NativeDllHandle = Kernel32Natives.LoadLibrary(xinputPath);

            if (NativeDllHandle == IntPtr.Zero)
            {
                Log.FatalFormat("Couldn't load native DLL: {0}", new Win32Exception(Marshal.GetLastWin32Error()));
                return;
            }

            Log.Info("Library initialized");
        }
开发者ID:CheesyKek,项目名称:ScpToolkit,代码行数:64,代码来源:XInputDll.cs

示例3: LogFatal

 /// <summary>
 /// Logs the fatal message.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="provider">The provider.</param>
 /// <param name="format">The format.</param>
 /// <param name="args">The args.</param>
 public static void LogFatal( Type type, IFormatProvider provider, string format, params object[] args )
 {
     Log = LogManager.GetLogger ( type );
     Log.FatalFormat ( provider, format, args );
 }
开发者ID:camalot,项目名称:droidexplorer,代码行数:12,代码来源:Logger.cs

示例4: RunService

        private static void RunService(CommandLineParser parser, Action<StringDictionary> environment, ILog logger)
        {
            if (ServiceEnvironmentManagementEx.IsServiceDisabled(parser.Target))
            {
                logger.ErrorFormat("The service '{0}' is disabled. Please enable the service.",
                    parser.Target);
                return;
            }

            var service = new ServiceController(parser.Target);
            try
            {

                if (service.Status != ServiceControllerStatus.Stopped)
                {
                    logger.ErrorFormat(
                        "The service '{0}' is already running. The profiler cannot attach to an already running service.",
                    parser.Target);
                    return;
                }

                // now to set the environment variables
                var profilerEnvironment = new StringDictionary();
                environment(profilerEnvironment);

                var serviceEnvironment = new ServiceEnvironmentManagement();

                try
                {
                    serviceEnvironment.PrepareServiceEnvironment(
                        parser.Target,
                            parser.ServiceEnvironment,
                        (from string key in profilerEnvironment.Keys
                         select string.Format("{0}={1}", key, profilerEnvironment[key])).ToArray());

                    // now start the service
                    var old = service;
                    service = new ServiceController(parser.Target);
                    old.Dispose();

                    if (parser.Target.ToLower().Equals("w3svc"))
                    {
                        // Service will not automatically start
                        if (! TerminateCurrentW3SvcHost(logger) ||
                            !ServiceEnvironmentManagementEx.IsServiceStartAutomatic(parser.Target))
                        {
                            service.Start();
                        }
                    }
                    else
                    {
                        service.Start();
                    }
                    logger.InfoFormat("Service starting '{0}'", parser.Target);
                    service.WaitForStatus(ServiceControllerStatus.Running, parser.ServiceStartTimeout);
                    logger.InfoFormat("Service started '{0}'", parser.Target);
                }
                catch (InvalidOperationException fault)
                {
                    logger.FatalFormat("Service launch failed with '{0}'", fault);
                }
                finally
                {
                    // once the serice has started set the environment variables back - just in case
                    serviceEnvironment.ResetServiceEnvironment();
                }

                // and wait for it to stop
                service.WaitForStatus(ServiceControllerStatus.Stopped);
                logger.InfoFormat("Service stopped '{0}'", parser.Target);

                // Stopping w3svc host
                if (parser.Target.ToLower().Equals("w3svc"))
                {
                    logger.InfoFormat("Stopping svchost to clean up environment variables for w3svc", parser.Target);
                    if (ServiceEnvironmentManagementEx.IsServiceStartAutomatic(parser.Target))
                    {
                        logger.InfoFormat("Please note that the 'w3svc' service may automatically start");
                    }
                    TerminateCurrentW3SvcHost(logger);
                }
            }
            finally
            {
                service.Dispose();
            }
        }
开发者ID:jayrowe,项目名称:opencover,代码行数:87,代码来源:Program.cs

示例5: FatalFormat

 /// <summary>
 /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Fatal"/> level.
 /// </summary>
 /// <param name="format">A String containing zero or more format items</param>
 /// <param name="args">An Object array containing zero or more objects to format</param>
 /// <param name="log">The log.</param>
 /// <overloads>Log a formatted message string with the <see cref="F:log4net.Core.Level.Fatal"/> level.</overloads>
 /// <remarks>
 /// 	<para>
 /// The message is formatted using the <c>String.Format</c> method. See
 /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
 /// of the formatting.
 /// </para>
 /// 	<para>
 /// This method does not take an <see cref="T:System.Exception"/> object to include in the
 /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Fatal(System.Object)"/>
 /// methods instead.
 /// </para>
 /// </remarks>
 /// <seealso cref="M:log4net.ILog.Fatal(System.Object,System.Exception)"/>
 /// <seealso cref="P:log4net.ILog.IsFatalEnabled"/>
 public static void FatalFormat(string format, object[] args, ILog log)
 {
     log.FatalFormat(CultureInfo.InvariantCulture, format, args);
 }
开发者ID:zevinganez,项目名称:code-o-matic,代码行数:25,代码来源:Log.cs


注:本文中的log4net.ILog.FatalFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。