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


C# log4net.ILog类代码示例

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


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

示例1: WriteLog

        public void WriteLog(ICorrelation correlation, LogEventLevel eventLevel, Exception exception, string formatMessage, params object[] args)
        {
            if (log == null)
            {
                log = loggerRepository.GetLogger(sourceType);
            }

            if (eventLevel == LogEventLevel.Verbose && !log.IsDebugEnabled)
            {
                return;
            }

            if (args != null && args.Length != 0)
            {
                formatMessage = string.Format(formatMessage, args);
            }

            log4net.Core.ILogger logger = log.Logger;

            LoggingEvent logEvent = new LoggingEvent(sourceType, logger.Repository, logger.Name, MapEventLevel(eventLevel), formatMessage, exception);

            if (correlation != null)
            {
                logEvent.Properties["CallerId"] = correlation.CallerId;
                logEvent.Properties["CorrelationId"] = correlation.CorrelationId;
            }

            logger.Log(logEvent);
        }
开发者ID:affecto,项目名称:dotnet-Logging,代码行数:29,代码来源:LogWriter.cs

示例2: S3Storage

        //--- Constructors ---
        public S3Storage(XDoc configuration, ILog log) {
            _timerFactory = TaskTimerFactory.Create(this);
            _log = log;
            _publicKey = configuration["publickey"].AsText;
            _privateKey = configuration["privatekey"].AsText;
            _bucket = configuration["bucket"].AsText;
            _prefix = configuration["prefix"].AsText;
            if(string.IsNullOrEmpty(_publicKey)) {
                throw new ArgumentException("Invalid Amazon S3 publickey");
            }
            if(string.IsNullOrEmpty(_privateKey)) {
                throw new ArgumentException("Invalid Amazon S3 privatekey");
            }
            if(string.IsNullOrEmpty(_bucket)) {
                throw new ArgumentException("Invalid Amazon S3 bucket");
            }
            if(string.IsNullOrEmpty(_prefix)) {
                throw new ArgumentException("Invalid Amazon S3 prefix");
            }
            _tempDirectory = Path.Combine(Path.GetTempPath(), "s3_cache_" + XUri.EncodeSegment(_prefix));
            if(Directory.Exists(_tempDirectory)) {
                Directory.Delete(_tempDirectory, true);
            }
            Directory.CreateDirectory(_tempDirectory);
            _allowRedirects = configuration["allowredirects"].AsBool ?? false;
            _redirectTimeout = TimeSpan.FromSeconds(configuration["redirecttimeout"].AsInt ?? 60);
            _cacheTtl = (configuration["cachetimeout"].AsInt ?? 60 * 60).Seconds();

            // initialize S3 plug
            _s3 = Plug.New("http://s3.amazonaws.com", TimeSpan.FromSeconds(configuration["timeout"].AsDouble ?? DEFAUTL_S3_TIMEOUT)).WithPreHandler(S3AuthenticationHeader).At(_bucket);
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:32,代码来源:S3Storage.cs

示例3: NHibernateBoxQueryEvaluator

 public NHibernateBoxQueryEvaluator(ILog log, 
     RepositoryFinder repoFinder, IComponentContext context)
 {
     this.log = log;
     _repoFinder = repoFinder;
     this.context = context;
 }
开发者ID:ikutsin,项目名称:BinaryAnalysis.Core,代码行数:7,代码来源:NHibernateBoxQueryEvaluator.cs

示例4: ActiveFeatureFactory

 public ActiveFeatureFactory(IKernel kernel, IInstanceConfiguration instanceConfiguration, ILog log, ILoggingConfiguration loggingConfiguration)
 {
     _kernel = kernel;
     _instanceConfiguration = instanceConfiguration;
     _log = log;
     _loggingConfiguration = loggingConfiguration;
 }
开发者ID:davidwhitney,项目名称:deployd-micro,代码行数:7,代码来源:ActiveFeatureFactory.cs

示例5: FeedZmQPublisher

 public FeedZmQPublisher(string address, ILog log)
 {
     _log = log;
     _context = NetMQContext.Create();
     _socket = _context.CreatePushSocket();
     _socket.Bind(address);
 }
开发者ID:Grovesy,项目名称:Feeds,代码行数:7,代码来源:FeedZmQPublisher.cs

示例6: Log

        public static void Log(ILog log, object message)
        {
            if (log == null) return;

            Logger logger = log.Logger as Logger;

            if (logger != null)
            {
                try
                {
                    // Save current log level and layouts
                    Dictionary<AppenderSkeleton, ILayout> existingLayout = new Dictionary<AppenderSkeleton, ILayout>();
                    Level existingLevel = logger.Level;

                    foreach (var appender in logger.Repository.GetAppenders().OfType<AppenderSkeleton>())
                    {
                        existingLayout[appender] = appender.Layout;
                        appender.Layout = _simpleLayout;
                    }

                    logger.Level = Level.Verbose;

                    logger.Log(Level.Verbose, message, null);

                    // Restore layouts and log level
                    foreach (KeyValuePair<AppenderSkeleton, ILayout> kv in existingLayout)
                    {
                        kv.Key.Layout = kv.Value;
                    }

                    logger.Level = existingLevel;
                }
                catch { } // Ignore exception
            }
        }
开发者ID:rbramwell,项目名称:OrionSDK,代码行数:35,代码来源:ForceMessageLog.cs

示例7: DeployReleaseCommand

 public DeployReleaseCommand(IOctopusRepositoryFactory repositoryFactory, ILog log)
     : base(repositoryFactory, log)
 {
     DeployToEnvironmentNames = new List<string>();
     DeploymentStatusCheckSleepCycle = TimeSpan.FromSeconds(10);
     DeploymentTimeout = TimeSpan.FromMinutes(10);
 }
开发者ID:nishanperera,项目名称:Octopus-Tools,代码行数:7,代码来源:DeployReleaseCommand.cs

示例8: PackageInstallLogger

        public PackageInstallLogger(
			IPackageInstallTracker tracker,
			ILog log)
        {
            Tracker = tracker;
            Log = log;
        }
开发者ID:Fortis-Collection,项目名称:Toolcore,代码行数:7,代码来源:PackageInstallLogger.cs

示例9: FixtureServiceController

 public FixtureServiceController(
     IFixtureService fixtureService,
     ILog logger)
 {
     this.fixtureService = fixtureService;
     this.logger = logger;
 }
开发者ID:ewan-sportingsolutions,项目名称:VersioningSample,代码行数:7,代码来源:FixtureServiceController.cs

示例10: BasePersistance

 protected BasePersistance(ICommandLine commandLine, ILog logger)
 {
     CommandLine = commandLine;
     _logger = logger;
     CoverageSession = new CoverageSession();
     _trackedMethodId = 0;
 }
开发者ID:pofman,项目名称:opencover,代码行数:7,代码来源:BasePersistance.cs

示例11: Execute

        public override void Execute(DataModel context, ILog log)
        {
            var today = DateTime.Today;
            var scannedEmployees = context.ScannedInEmployees
                .Include(e => e.InScan)
                .Where(s => DbFunctions.TruncateTime(s.InScan.CreatedAt) < today)
                .ToList();
            foreach (var scannedEmployee in scannedEmployees)
            {
                var scanIn = context.EmployeeScans.Find(scannedEmployee.ScanID);
                var scan = new EmployeeScan()
                {
                    CreatedAt = scanIn.CreatedAt,
                    EmployeeNumber = scannedEmployee.EmployeeNumber,
                    Division = scanIn.Division,
                    Details = "Out (System)",
                    ScanType = "Type",
                    PartnerID = scanIn.ID,
                    Username = "System"
                };

                log.Info($"Scanning out Employee: {scan.EmployeeNumber} from {scan.Division}");
                context.EmployeeScans.Add(scan);
            }
            context.ScannedInEmployees.RemoveRange(scannedEmployees);
            context.SaveChanges();
        }
开发者ID:robertfall,项目名称:LAD,代码行数:27,代码来源:ScanOutEmployees.cs

示例12: Init

        public static void Init()
        {
            _log = LogManager.GetLogger("AppDomain");

            var _fa =
                new FileAppender()
                {
                    Layout = new log4net.Layout.PatternLayout("%timestamp [%thread] %-5level %logger - %message%newline"),
                    File = Path.Combine(Environment.CurrentDirectory, "update.log"),
                    AppendToFile = false
                };
            _fa.ActivateOptions();
            BasicConfigurator.Configure(
                _fa,
                new ConsoleAppender()
            );

            AppDomain.CurrentDomain.AssemblyLoad += (sender, e) =>
            {
                _log.DebugFormat("Assembly load: {0}", e.LoadedAssembly.FullName);
            };
            AppDomain.CurrentDomain.ProcessExit += (sender, e) =>
            {
                _log.Info("Process exiting.");
            };
            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                _log.ErrorFormat("Unhandled exception: {0}", e.ExceptionObject.ToString());
            };
        }
开发者ID:icedream,项目名称:modernminas-launcher,代码行数:30,代码来源:Log.cs

示例13: Log

        //---------------------------------------------------------------------

        static Log()
        {
            //Hierarchy hierarchy = LogManager.GetLoggerRepository() as Hierarchy;
            //logger = hierarchy.Root;
            //log4net.Config.XmlConfigurator.Configure();
            logger = LogManager.GetLogger("Landis");
        }
开发者ID:LANDIS-II-Foundation,项目名称:Libraries,代码行数:9,代码来源:Log.cs

示例14: ReactorServiceBase

        /// <summary>
        /// Initializes a new instance of the <see cref="ReactorServiceBase"/> class.
        /// </summary>
        /// <param name="configurationAggregator">The configuration aggregator.</param>
        protected ReactorServiceBase(IConfigurationAggregator configurationAggregator)
        {
            if (configurationAggregator == null) throw new ArgumentNullException("configurationAggregator");

            ConfigurationAggregator = configurationAggregator;
            Log = LogManager.GetLogger(GetType());
        }
开发者ID:akilhoffer,项目名称:Reactor,代码行数:11,代码来源:ReactorServiceBase.cs

示例15: MyLogHelper

    /// <summary>
    ///     A logger to be used for logging statements in the code.
    ///     It is recommended to follow a pattern for instantiating this:
    ///     <code>
    ///         private static readonly JCsLogger log = new JCsLogger(typeof(YourClassName));
    ///         ...
    ///         log.*(yourLoggingStuff); // Debug/Info/Warn/Error/Fatal[Format]
    ///     </code>
    /// </summary>
    /// <param name="type">the type that is using this logger</param>
    public MyLogHelper(Type type)
    {
        MyLogHelperConfig();
#if LOG4NET
        log = log4net.LogManager.GetLogger(type);
#endif
    }
开发者ID:zhenghehe2014,项目名称:u3dframework,代码行数:17,代码来源:MyLogHelper.cs


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