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


C# log4net.ILog.Warn方法代码示例

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


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

示例1: WriteLog

        public void WriteLog(LogEnum name, LogLevel level, string logContent)
        {
            log = log4net.LogManager.GetLogger(name.ToString());
            //log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            switch (level)
            {
                case LogLevel.DEBUG:
                    log.Debug(logContent);
                    break;
                case LogLevel.ERROR:
                    log.Error(logContent);
                    break;
                case LogLevel.FATAL:
                    log.Fatal(logContent);
                    break;
                case LogLevel.INFO:
                    log.Info(logContent);
                    break;
                case LogLevel.WARN:
                    log.Warn(logContent);
                    break;
                default:
                    log.Debug(logContent);
                    break;
            }
        }
开发者ID:mmxftp,项目名称:JSMiracle.AutoWarehouse,代码行数:27,代码来源:Net4Log.cs

示例2: LoginButton_Click

        protected void LoginButton_Click(object sender, EventArgs e)
        {
            logger = log4net.LogManager.GetLogger("LogInFile");

            HttpCookie cookie = new HttpCookie("blocoMorador");
            cookie.Value = drpBloco.SelectedItem.Text;
            cookie.Expires = DateTime.Now.AddDays(365); this.Page.Response.AppendCookie(cookie);
            Response.Cookies.Add(cookie);

            Session.Clear();

            oAPmodel.apartamento = Convert.ToInt32(txtAP.Text);
            oAPmodel.bloco = Convert.ToInt32(drpBloco.Text);
            oProprietarioModel.senha = Password.Text;

            Session["AP"] = Convert.ToInt32(txtAP.Text);
            Session["Bloco"] = Convert.ToInt32(drpBloco.Text);

            int valida = oProprietario.autenticaMorador(oAPmodel, oProprietarioModel);

            if (valida != 0)
            {

                foreach (var item in oProprietario.populaProprietario(oAPmodel, oProprietarioModel))
                {
                    Session["AP"] = item.ap.apartamento;
                    Session["Bloco"] = item.ap.bloco;
                    Session["Proprie1"] = item.proprietario1.ToString();
                    Session["Proprie2"] = item.proprietario2.ToString();
                    if (item.email != null)
                        Session["email"] = item.email.ToString();

                    //  Session["senha"] = item.senha.ToString();
                }

                if (Session["AP"].ToString() == "0" && Session["Bloco"].ToString() == "0")
                {
                    Response.Redirect("WelcomeAdmin.aspx");
                }
                else
                {

                    if (Session["AP"].ToString() != "301" && Session["Bloco"].ToString() != "6")
                    {
                        Util.SendMail oEmail = new SendMail();
                        oEmail.enviaSenha("Acesso feito com sucesso para o apartamento/bloco " + Session["AP"].ToString() + " - " + Session["Bloco"].ToString(), "Acessos", "[email protected]", 0);
                        logger.Info("Acesso feito com sucesso para o apartamento/bloco " + Session["AP"].ToString() + " - " + Session["Bloco"].ToString());
                        Response.Redirect("~/paginaInicialMoradores.aspx");
                    }
                    else
                    {
                        Response.Redirect("~/paginaInicialMoradores.aspx");
                        logger.Warn("Acesso negado!");
                    }

                }
            }
            else
            {
                FailureText.Text = "Número do Apartamento ou senha inválida";
                Session.Clear();
            }
        }
开发者ID:EdmilsonFernandes,项目名称:condominioAzuli,代码行数:63,代码来源:LoginAzulli.aspx.cs

示例3: Start

        public static void Start(string[] args)
        {
            bool isAlreadyRunning = false;
            List<string> filesToOpen = new List<string>();

            // Init Log4NET
            LogFileLocation = LogHelper.InitializeLog4NET();
            // Get logger
            LOG = log4net.LogManager.GetLogger(typeof(MainForm));

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            // Log the startup
            LOG.Info("Starting: " + EnvironmentInfo.EnvironmentToString(false));

            IniConfig.Init();
            AppConfig.UpgradeToIni();
            // Read configuration
            conf = IniConfig.GetIniSection<CoreConfiguration>();
            try
            {
                // Fix for Bug 2495900, Multi-user Environment
                // check whether there's an local instance running already

                try
                {
                    // Added Mutex Security, hopefully this prevents the UnauthorizedAccessException more gracefully
                    // See an example in Bug #3131534
                    SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
                    MutexSecurity mutexsecurity = new MutexSecurity();
                    mutexsecurity.AddAccessRule(new MutexAccessRule(sid, MutexRights.FullControl, AccessControlType.Allow));
                    mutexsecurity.AddAccessRule(new MutexAccessRule(sid, MutexRights.ChangePermissions, AccessControlType.Deny));
                    mutexsecurity.AddAccessRule(new MutexAccessRule(sid, MutexRights.Delete, AccessControlType.Deny));

                    bool created = false;
                    // 1) Create Mutex
                    applicationMutex = new Mutex(false, @"Local\F48E86D3-E34C-4DB7-8F8F-9A0EA55F0D08", out created, mutexsecurity);
                    // 2) Get the right to it, this returns false if it's already locked
                    if (!applicationMutex.WaitOne(0, false))
                    {
                        LOG.Debug("Greenshot seems already to be running!");
                        isAlreadyRunning = true;
                        // Clean up
                        applicationMutex.Close();
                        applicationMutex = null;
                    }
                }
                catch (AbandonedMutexException e)
                {
                    // Another Greenshot instance didn't cleanup correctly!
                    // we can ignore the exception, it happend on the "waitone" but still the mutex belongs to us
                    LOG.Warn("Greenshot didn't cleanup correctly!", e);
                }
                catch (UnauthorizedAccessException e)
                {
                    LOG.Warn("Greenshot is most likely already running for a different user in the same session, can't create mutex due to error: ", e);
                    isAlreadyRunning = true;
                }
                catch (Exception e)
                {
                    LOG.Warn("Problem obtaining the Mutex, assuming it was already taken!", e);
                    isAlreadyRunning = true;
                }

                if (args.Length > 0 && LOG.IsDebugEnabled)
                {
                    StringBuilder argumentString = new StringBuilder();
                    for (int argumentNr = 0; argumentNr < args.Length; argumentNr++)
                    {
                        argumentString.Append("[").Append(args[argumentNr]).Append("] ");
                    }
                    LOG.Debug("Greenshot arguments: " + argumentString.ToString());
                }

                for (int argumentNr = 0; argumentNr < args.Length; argumentNr++)
                {
                    string argument = args[argumentNr];
                    // Help
                    if (argument.ToLower().Equals("/help"))
                    {
                        // Try to attach to the console
                        bool attachedToConsole = Kernel32.AttachConsole(Kernel32.ATTACHCONSOLE_ATTACHPARENTPROCESS);
                        // If attach didn't work, open a console
                        if (!attachedToConsole)
                        {
                            Kernel32.AllocConsole();
                        }
                        StringBuilder helpOutput = new StringBuilder();
                        helpOutput.AppendLine();
                        helpOutput.AppendLine("Greenshot commandline options:");
                        helpOutput.AppendLine();
                        helpOutput.AppendLine();
                        helpOutput.AppendLine("\t/help");
                        helpOutput.AppendLine("\t\tThis help.");
                        helpOutput.AppendLine();
                        helpOutput.AppendLine();
                        helpOutput.AppendLine("\t/exit");
                        helpOutput.AppendLine("\t\tTries to close all running instances.");
                        helpOutput.AppendLine();
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:101,代码来源:MainForm.cs

示例4: Init

        /// <summary>
        /// Initializes the <c>SteamManager</c>.
        /// This MUST be called before other Steam operations are executed.
        /// </summary>
        /// <returns><c>true</c> if everything initialized properly, <c>false</c> otherwise.</returns>
        public static bool Init()
        {
            if (Enabled)
            {
                _log.Warn("Tried to call Init method when SteamManager has already been initialized! Aborting...");
                return false;
            }
            _log = LogManager.GetLogger(typeof(SteamManager));
            try
            {
                if (!Steamworks.Load())
                {
                    _log.Error("Steamworks failed to load, throwing exception!");
                    throw new SteamException("Steamworks failed to load.", SteamExceptionType.SteamworksLoadFail);
                }

                Client = Steamworks.CreateInterface<ISteamClient010>("SteamClient010");
                if (Client == null)
                {
                    _log.Error("Steamclient is NULL!! Throwing exception!");
                    throw new SteamException("Steamclient failed to load! Is the client running? (Sharpcraft.Steam.SteamManager.Client == null!)",
                                             SteamExceptionType.SteamLoadFail);
                }

                Pipe = Client.CreateSteamPipe();
                User = Client.ConnectToGlobalUser(Pipe);

                Friends = Steamworks.CastInterface<ISteamFriends002>(Client.GetISteamFriends(User, Pipe, "SteamFriends002"));

                if (Friends == null)
                    return false;

                FriendList = new SteamFriendList();

                _steamWatcher = new Timer(SteamCheck, null, 0, 1000);
            }
            catch (SteamException ex)
            {
                _log.Warn("Warning! SteamManager caught a SteamException exception, returning FALSE. Steam components will NOT LOAD!");
                _log.Warn("The SteamException type was: " + System.Enum.GetName(typeof(SteamExceptionType), ex.Type));
                return false;
            }
            _log.Info("SteamManager has been initialized!");
            SteamLoaded = true;
            Enabled = true;
            return true;
        }
开发者ID:SijmenSchoon,项目名称:Sharpcraft,代码行数:52,代码来源:SteamManager.cs

示例5: Main

        static void Main(string[] args)
        {
            if (string.IsNullOrEmpty(Thread.CurrentThread.Name))
                Thread.CurrentThread.Name = "Main";

            #if WINDOWS && DEBUG
            if (!System.Diagnostics.Debugger.IsAttached)
            {
                AllocConsole();
                var stdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
                var safeFileHandle = new SafeFileHandle(stdHandle, true);
                var fileStream = new FileStream(safeFileHandle, FileAccess.Write);
                var encoding = Encoding.GetEncoding(CODE_PAGE);
                var stdOut = new StreamWriter(fileStream, encoding) { AutoFlush = true };
                Console.SetOut(stdOut);
            }
            #endif

            _log = LogManager.GetLogger(typeof(Program));

            _log.Info("### !!! APPLICATION LOAD !!! ###");

            _log.Info("Deleting old log files (>7 days)...");

            // Delete log files older than 7 days
            if (Directory.Exists("logs"))
            {
                var now = DateTime.Now;
                var max = new TimeSpan(7, 0, 0, 0); // 7 days
                foreach (var file in from file in Directory.GetFiles("logs")
                                        let modTime = File.GetLastAccessTime(file)
                                        let age = now.Subtract(modTime)
                                        where age > max
                                        select file)
                {
                    try
                    {
                        File.Delete(file);
                        _log.Info("Deleted old log file: " + file);
                    }
                    catch (IOException ex)
                    {
                        _log.Warn("Failed to delete log file: " + file + "(" + ex.Message + ")");
                    }
                }
            }

            _log.Info("Old log files deleted!");

            _log.Info("Starting game...");
            using (var game = new MainGame())
                game.Run();

            #if WINDOWS && DEBUG
            _log.Debug("Unloading console...");
            FreeConsole();
            _log.Debug("Console unloaded!");
            #endif
            _log.Info("### !!! APPLICATION EXIT !!! ###");
        }
开发者ID:Sharparam,项目名称:DiseasedToast,代码行数:60,代码来源:Program.cs


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