本文整理汇总了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);
}
示例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);
}
示例3: NHibernateBoxQueryEvaluator
public NHibernateBoxQueryEvaluator(ILog log,
RepositoryFinder repoFinder, IComponentContext context)
{
this.log = log;
_repoFinder = repoFinder;
this.context = context;
}
示例4: ActiveFeatureFactory
public ActiveFeatureFactory(IKernel kernel, IInstanceConfiguration instanceConfiguration, ILog log, ILoggingConfiguration loggingConfiguration)
{
_kernel = kernel;
_instanceConfiguration = instanceConfiguration;
_log = log;
_loggingConfiguration = loggingConfiguration;
}
示例5: FeedZmQPublisher
public FeedZmQPublisher(string address, ILog log)
{
_log = log;
_context = NetMQContext.Create();
_socket = _context.CreatePushSocket();
_socket.Bind(address);
}
示例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
}
}
示例7: DeployReleaseCommand
public DeployReleaseCommand(IOctopusRepositoryFactory repositoryFactory, ILog log)
: base(repositoryFactory, log)
{
DeployToEnvironmentNames = new List<string>();
DeploymentStatusCheckSleepCycle = TimeSpan.FromSeconds(10);
DeploymentTimeout = TimeSpan.FromMinutes(10);
}
示例8: PackageInstallLogger
public PackageInstallLogger(
IPackageInstallTracker tracker,
ILog log)
{
Tracker = tracker;
Log = log;
}
示例9: FixtureServiceController
public FixtureServiceController(
IFixtureService fixtureService,
ILog logger)
{
this.fixtureService = fixtureService;
this.logger = logger;
}
示例10: BasePersistance
protected BasePersistance(ICommandLine commandLine, ILog logger)
{
CommandLine = commandLine;
_logger = logger;
CoverageSession = new CoverageSession();
_trackedMethodId = 0;
}
示例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();
}
示例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());
};
}
示例13: Log
//---------------------------------------------------------------------
static Log()
{
//Hierarchy hierarchy = LogManager.GetLoggerRepository() as Hierarchy;
//logger = hierarchy.Root;
//log4net.Config.XmlConfigurator.Configure();
logger = LogManager.GetLogger("Landis");
}
示例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());
}
示例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
}