• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# log4net.ILog类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ILog类属于log4net命名空间,在下文中一共展示了ILog类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: CreateReleaseCommand

        public CreateReleaseCommand(IOctopusRepositoryFactory repositoryFactory, ILog log, IPackageVersionResolver versionResolver)
            : base(repositoryFactory, log)
        {
            this.versionResolver = versionResolver;

            DeployToEnvironmentNames = new List<string>();
            DeploymentStatusCheckSleepCycle = TimeSpan.FromSeconds(10);
            DeploymentTimeout = TimeSpan.FromMinutes(10);

            var options = Options.For("Release creation");
            options.Add("project=", "Name of the project", v => ProjectName = v);
            options.Add("channel=", "[Optional] Channel to use for the new release.", v => ChannelName = v);
            options.Add("version=|releaseNumber=", "[Optional] Release number to use for the new release.", v => VersionNumber = v);
            options.Add("packageversion=|defaultpackageversion=", "Default version number of all packages to use for this release.", v => versionResolver.Default(v));
            options.Add("package=", "[Optional] Version number to use for a package in the release. Format: --package={StepName}:{Version}", v => versionResolver.Add(v));
            options.Add("packagesFolder=", "[Optional] A folder containing NuGet packages from which we should get versions.", v => versionResolver.AddFolder(v));
            options.Add("releasenotes=", "[Optional] Release Notes for the new release.", v => ReleaseNotes = v);
            options.Add("releasenotesfile=", "[Optional] Path to a file that contains Release Notes for the new release.", ReadReleaseNotesFromFile);
            options.Add("ignoreexisting", "If a release with the version number already exists, ignore it", v => IgnoreIfAlreadyExists = true);
            options.Add("ignorechannelrules", "[Optional] Ignore package version matching rules", v => Force = true);
            options.Add("packageprerelease=", "[Optional] Pre-release for latest version of all packages to use for this release.", v => VersionPrerelease = v);

            options = Options.For("Deployment");
            options.Add("deployto=", "[Optional] Environment to automatically deploy to, e.g., Production", v => DeployToEnvironmentNames.Add(v));
        }
开发者ID:shaynevanasperen,项目名称:Octopus-Tools,代码行数:25,代码来源:CreateReleaseCommand.cs


示例13: SchedulerService

 public SchedulerService(IBus bus, IRawByteBus rawByteBus, ILog log, IScheduleRepository scheduleRepository)
 {
     this.bus = bus;
     this.scheduleRepository = scheduleRepository;
     this.rawByteBus = rawByteBus;
     this.log = log;
 }
开发者ID:octoberclub,项目名称:EasyNetQ,代码行数:7,代码来源:SchedulerService.cs


示例14: CecilSymbolManager

 public CecilSymbolManager(ICommandLine commandLine, IFilter filter, ILog logger, ITrackedMethodStrategy[] trackedMethodStrategies)
 {
     _commandLine = commandLine;
     _filter = filter;
     _logger = logger;
     _trackedMethodStrategies = trackedMethodStrategies;
 }
开发者ID:rfsouza02,项目名称:opencover,代码行数:7,代码来源:CecilSymbolManager.cs


示例15: AssemblyConfiguration

 protected AssemblyConfiguration(Dictionary<string, object> defaultValues, ILog logger)
 {
     NameValueCollection nameValues = ConfigurationManager.AppSettings;
     CreateConfiguration(defaultValues, nameValues);
     foreach (KeyValuePair<string, string> pair in usedValues)
         logger.InfoFormat("Using {0}={1}", pair.Key, pair.Value);
 }
开发者ID:domik82,项目名称:bricks-toolkit,代码行数:7,代码来源:AssemblyConfiguration.cs


示例16: GameMonitorDisplayViewModel

        public GameMonitorDisplayViewModel(ISynchronizeInvoke synchronizeInvoke, string fileNameAndPath, PollWatcherFactory pollWatcherFactory, Func<Type, ILog> loggerFactory)
        {
            this.synchronizeInvoke = synchronizeInvoke;
            logger = loggerFactory(typeof(GameMonitorDisplayViewModel));

            LoadGameToBeMonitored(fileNameAndPath, pollWatcherFactory);
        }
开发者ID:alexliu1,项目名称:GameMonitor,代码行数:7,代码来源:GameMonitorDisplayViewModel.cs


示例17: 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


示例18: 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


示例19: 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


示例20: 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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Appender.ConsoleAppender类代码示例发布时间:2022-05-26
下一篇:
C# TestClient.TestClient类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap