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


C# ILog.Warn方法代码示例

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


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

示例1: Warn

 public static void Warn(string message, Exception ex, ILog log)
 {
     if (log.IsWarnEnabled)
     {
         log.Warn(message, ex);
     }
 }
开发者ID:vgreggio,项目名称:CrossoverTest,代码行数:7,代码来源:Logging.cs

示例2: Warn

 public static void Warn(System.Type type, object message)
 {
     logger = LogManager.GetLogger(type);
     if (!logger.Logger.Repository.Configured)
         XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(GetConfigFile() + ".config"));
     logger.Warn(message);
 }
开发者ID:yancyn,项目名称:BumbleeBee,代码行数:7,代码来源:Logger.cs

示例3: LogRestWarn

 public static void LogRestWarn(ILog logger, IRestResponse restResponse, string warnHeading)
 {
     if (logger != null && restResponse != null)
     {
         var stringBuilder = BuildLoggingString(restResponse, warnHeading);
         logger.Warn(stringBuilder.ToString());
     }
 }
开发者ID:sportingsolutions,项目名称:SS.Integration.UnifiedDataAPIClient.DotNet,代码行数:8,代码来源:RestErrorHelper.cs

示例4: LogMessages

 internal static void LogMessages(ILog log)
 {
     log.Info("This is an info");
     log.InfoFormat("Base called at {0}", DateTime.Now);
     log.Debug("This is a debug");
     log.Warn("This is a warning");
     log.Error("This is an error");
 }
开发者ID:Slesa,项目名称:Playground,代码行数:8,代码来源:Program.cs

示例5: TrajectoryPlotter

        public TrajectoryPlotter(string inputDirectory, string inputFilenamePattern, string outputDirectory, string outputFilename, int width, int height, uint bailout)
        {
            _inputDirectory = inputDirectory;
            _inputFilenamePattern = inputFilenamePattern;
            _outputDirectory = outputDirectory;
            _outputFilename = outputFilename;
            _resolution = new Size(width, height);
            _bailout = bailout;

            _log = LogManager.GetLogger(GetType());

            if (width % 4 != 0)
            {
                _log.Warn("The width should be evenly divisible by 4");
            }
            if (height % 4 != 0)
            {
                _log.Warn("The height should be evenly divisible by 4");
            }

            _hitPlot = new HitPlot4x4(_resolution);
        }
开发者ID:ajalexander,项目名称:Fractals,代码行数:22,代码来源:TrajectoryPlotter.cs

示例6: BeaglePlugin

        public BeaglePlugin()
        {
            server = Daemon.Server;
            db = Daemon.DefaultDatabase;
            log = Daemon.Log;

            query = new Query ();
            query.AddDomain (QueryDomain.Neighborhood);
            query.MaxHits = 10000;

            QueryPart_Property filePart = new QueryPart_Property ();
            filePart.Type = PropertyType.Keyword;
            filePart.Key = "beagle:HitType";
            filePart.Value = "File";
            query.AddPart (filePart);

            QueryPart_Or queryUnion = new QueryPart_Or ();

            foreach (string mt in supportedMimeTypes) {
                QueryPart_Property part = new QueryPart_Property ();
                part.Type = PropertyType.Keyword;
                part.Key = "beagle:MimeType";
                part.Value = mt;
                queryUnion.Add (part);
            }

            query.AddPart (queryUnion);
            query.HitsAddedEvent += OnHitsAdded;
            query.HitsSubtractedEvent += OnHitsSubtracted;
            query.FinishedEvent += OnFinished;

            int attempts = 0;
            while (true) {
                try {
                    query.SendAsync ();
                    break;
                } catch (Exception e) {
                    if (attempts++ >= 5) {
                        log.Warn ("Failed to initialize beagle plugin");
                        query = null;
                        break;
                    }

                    // something bad happened, wait a sec and try again
                    log.Debug ("Sending query failed: " + e.Message);
                    log.Debug ("Waiting 3 seconds...");
                    Thread.Sleep (3000);
                }
            }
        }
开发者ID:snorp,项目名称:tangerine,代码行数:50,代码来源:BeaglePlugin.cs

示例7: Log

        /// <summary>
        /// Logs messages into the log output
        /// </summary>
        /// <param name="message">Message that is sent to the log ouput</param>
        /// <param name="level">Level of the message</param>
        /// <param name="prefix">Prefix of the log file. It is valid on for PackRollingFileAppender</param>
        public static void Log(string message, LogLevel level, LogFilePrefix prefix, bool throwException)
        {
            try
            {
                if (assembly == null)
                {
                    return;
                }

                log = LogManager.GetLogger(assembly, assembly.GetTypes()[0]);

                if (log == null)
                {
                    return;
                }

                   

                //Save additional information
                string logMessage = message + Environment.NewLine;
                ThreadContext.Properties[PrefixFileAppender.LOG_PREFIX] = prefix;

                switch (level)
                {
                    case LogLevel.Info:
                        log.Info(logMessage);
                        break;
                    case LogLevel.Debug:
                        log.Debug(logMessage);
                        break;
                    case LogLevel.Warn:
                        log.Warn(logMessage);
                        break;
                    case LogLevel.Error:
                        log.Error(logMessage);
                        break;
                    case LogLevel.Fatal:
                        log.Fatal(logMessage);
                        break;
                }
            }
            catch (Exception exc)
            {
                if (throwException)
                {
                    throw exc;
                }
            }
        }
开发者ID:ddksaku,项目名称:loreal,代码行数:55,代码来源:Logger.cs

示例8: 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;
     }
 }
开发者ID:cnquan,项目名称:tasker,代码行数:16,代码来源:LogHelper.cs

示例9: Log

        /// <summary>
        /// Logs messages into the log output
        /// </summary>
        /// <param name="message">Message that is sent to the log ouput</param>
        /// <param name="level">Level of the message</param>
        /// <param name="prefix">Prefix of the log file. It is valid on for PackRollingFileAppender</param>
        public static void Log(string message, LogLevel level, LogFilePrefix prefix)
        {
            if (assembly == null)
            {
                return;
            }

            log = LogManager.GetLogger(assembly, assembly.GetTypes()[0]);

            ThreadContext.Properties[PackRollingFileAppender.HTTP_CONTEXT] = String.Empty;
            ThreadContext.Properties[PackRollingFileAppender.SESSION_VARS] = String.Empty;

            //Save additional information
            string logMessage = message + Environment.NewLine;
            if (level > LogLevel.Warn)
            {
                ThreadContext.Properties[PackRollingFileAppender.HTTP_CONTEXT] = AddHTTPContextInfo();
            }

            if (level > LogLevel.Debug)
            {
                ThreadContext.Properties[PackRollingFileAppender.SESSION_VARS] = SessionManager.ToString();
            }

            ThreadContext.Properties[PackRollingFileAppender.LOG_PREFIX] = prefix;

            switch (level)
            {
                case LogLevel.Info:
                    log.Info(logMessage);
                    break;
                case LogLevel.Debug:
                    log.Debug(logMessage);
                    break;
                case LogLevel.Warn:
                    log.Warn(logMessage);
                    break;
                case LogLevel.Error:
                    log.Error(logMessage);
                    break;
                case LogLevel.Fatal:
                    log.Fatal(logMessage);
                    break;
            }
        }
开发者ID:ddksaku,项目名称:canon,代码行数:51,代码来源:Logger.cs

示例10: SentAll

        public bool SentAll(IEnumerable<IDistributedEventAggregator> eventAggregators, byte[] messageContent,
            TypeDescriptor descriptor)
        {
            Logger = LogManager.GetLogger(NomadConstants.NOMAD_LOGGER_REPOSITORY, typeof (BasicTopicDeliverySubsystem));

            foreach (IDistributedEventAggregator dea in eventAggregators)
            {
                try
                {
                    dea.OnPublish(messageContent, descriptor);
                }
                catch (Exception e)
                {
                    Logger.Warn(string.Format("Could not sent message '{0}' to DEA: {1}", descriptor, dea), e);
                }
            }

            // using the reliable mechanisms of WCF devlivery is always succesfull to all proper processes
            return true;
        }
开发者ID:NomadPL,项目名称:Nomad,代码行数:20,代码来源:BasicTopicDeliverySubsystem.cs

示例11: 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");
     }
 }
开发者ID:brandongrossutti,项目名称:EventStore,代码行数:24,代码来源:ConsoleLogger.cs

示例12: GetSenderEmailAddressOrNull

 public static string GetSenderEmailAddressOrNull (AppointmentItem source, IEntityMappingLogger logger, ILog generalLogger)
 {
   try
   {
     return source.GetPropertySafe (PR_SENDER_EMAIL_ADDRESS);
   }
   catch (COMException ex)
   {
     generalLogger.Warn ("Can't access property PR_SENDER_EMAIL_ADDRESS of appointment", ex);
     logger.LogMappingWarning ("Can't access property PR_SENDER_EMAIL_ADDRESS of appointment", ex);
     return null;
   }
 }
开发者ID:aluxnimm,项目名称:outlookcaldavsynchronizer,代码行数:13,代码来源:OutlookUtility.cs

示例13: Log

 public void Log(ILog log)
 {
     string message = "{0}: {1}".AsFormat(Description, Message);
     switch (ResultType)
     {
         case Type.Success:
             log.Info(message); break;
         case Type.Warning:
             log.Warn(message); break;
         case Type.Failure:
             log.Error(message); break;
         default:
             log.Debug(message); break;
     }
 }
开发者ID:Trovarius,项目名称:simple,代码行数:15,代码来源:TaskRunner.cs

示例14: Start

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

            // Set the Thread name, is better than "1"
            Thread.CurrentThread.Name = Application.ProductName;

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

            Application.ThreadException += Application_ThreadException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            // Initialize the IniConfig
            IniConfig.Init();

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

            // 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;
                    // 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);
                }

                for(int argumentNr = 0; argumentNr < args.Length; argumentNr++) {
                    string argument = args[argumentNr];
                    // Help
                    if (argument.ToLower().Equals("/help") || argument.ToLower().Equals("/h") || argument.ToLower().Equals("/?")) {
                        // 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();
                        helpOutput.AppendLine();
                        helpOutput.AppendLine("\t/reload");
                        helpOutput.AppendLine("\t\tReload the configuration of Greenshot.");
                        helpOutput.AppendLine();
                        helpOutput.AppendLine();
                        helpOutput.AppendLine("\t/language [language code]");
                        helpOutput.AppendLine("\t\tSet the language of Greenshot, e.g. greenshot /language en-US.");
                        helpOutput.AppendLine();
                        helpOutput.AppendLine();
                        helpOutput.AppendLine("\t/inidirectory [directory]");
//.........这里部分代码省略.........
开发者ID:oneminot,项目名称:greenshot,代码行数:101,代码来源:MainForm.cs

示例15: Init

 protected void Init()
 {
     this.logger = Simply.Do.Log(this);
     try
     {
         resolver = Configure();
         ConfigureLogging();
     }
     catch (Exception e)
     {
         ConfigureLogging();
         logger.Warn("Failed to configure: {0}".AsFormat(e.Message) , e);
     }
     logger.InfoFormat("Simple.Net v{0} [{1}]", Simply.Do.Version.ToString(3), ProjectText);
 }
开发者ID:marcosli,项目名称:simpledotnet,代码行数:15,代码来源:ContextBase.cs


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