/// <summary> /// Shuts down the repository for the repository specified. /// </summary> /// <param name="repository">The repository to shutdown.</param> /// <remarks> /// <para> /// Calling this method will <b>safely</b> close and remove all /// appenders in all the loggers including root contained in the /// repository for the <paramref name="repository"/> specified. /// </para> /// <para> /// Some appenders need to be closed before the application exists. /// Otherwise, pending logging events might be lost. /// </para> /// <para> /// The <c>shutdown</c> method is careful to close nested /// appenders before closing regular appenders. This is allows /// configurations where a regular appender is attached to a logger /// and again to a nested appender. /// </para> /// </remarks> public static void ShutdownRepository(string repository) { if (repository == null) { throw new ArgumentNullException("repository"); } RepositorySelector.GetRepository(repository).Shutdown(); }
/// <summary> /// Returns all the currently defined loggers in the specified assembly's repository. /// </summary> /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param> /// <returns>All the defined loggers.</returns> /// <remarks> /// <para> /// The root logger is <b>not</b> included in the returned array. /// </para> /// </remarks> public static ILogger[] GetCurrentLoggers(Assembly repositoryAssembly) { if (repositoryAssembly == null) { throw new ArgumentNullException("repositoryAssembly"); } return(RepositorySelector.GetRepository(repositoryAssembly).GetCurrentLoggers()); }
/// <summary> /// Return the default <see cref="ILoggerRepository"/> instance. /// </summary> /// <param name="repository">the repository to lookup in</param> /// <returns>Return the default <see cref="ILoggerRepository"/> instance</returns> /// <remarks> /// <para> /// Gets the <see cref="ILoggerRepository"/> for the repository specified /// by the <paramref name="repository"/> argument. /// </para> /// </remarks> public static ILoggerRepository GetRepository(string repository) { if (repository == null) { throw new ArgumentNullException("repository"); } return(RepositorySelector.GetRepository(repository)); }
/// <summary> /// Resets all values contained in this repository instance to their defaults. /// </summary> /// <param name="repositoryAssembly">The assembly to use to lookup the repository to reset.</param> /// <remarks> /// <para> /// Resets all values contained in the repository instance to their /// defaults. This removes all appenders from all loggers, sets /// the level of all non-root loggers to <c>null</c>, /// sets their additivity flag to <c>true</c> and sets the level /// of the root logger to <see cref="Level.Debug"/>. Moreover, /// message disabling is set its default "off" value. /// </para> /// </remarks> public static void ResetConfiguration(Assembly repositoryAssembly) { if (repositoryAssembly == null) { throw new ArgumentNullException("repositoryAssembly"); } RepositorySelector.GetRepository(repositoryAssembly).ResetConfiguration(); }
/// <summary> /// Shuts down the repository for the repository specified. /// </summary> /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param> /// <remarks> /// <para> /// Calling this method will <b>safely</b> close and remove all /// appenders in all the loggers including root contained in the /// repository for the repository. The repository is looked up using /// the <paramref name="repositoryAssembly"/> specified. /// </para> /// <para> /// Some appenders need to be closed before the application exists. /// Otherwise, pending logging events might be lost. /// </para> /// <para> /// The <c>shutdown</c> method is careful to close nested /// appenders before closing regular appenders. This is allows /// configurations where a regular appender is attached to a logger /// and again to a nested appender. /// </para> /// </remarks> public static void ShutdownRepository(Assembly repositoryAssembly) { if (repositoryAssembly == null) { throw new ArgumentNullException("repositoryAssembly"); } RepositorySelector.GetRepository(repositoryAssembly).Shutdown(); }
/// <summary> /// Shorthand for <see cref="M:LogManager.GetLogger(string)"/>. /// </summary> /// <param name="repositoryAssembly">the assembly to use to lookup the repository</param> /// <param name="type">The <paramref name="type"/> of which the fullname will be used as the name of the logger to retrieve.</param> /// <returns>The logger with the name specified.</returns> /// <remarks> /// <para> /// Gets the logger for the fully qualified name of the type specified. /// </para> /// </remarks> public static ILogger GetLogger(Assembly repositoryAssembly, Type type) { if (repositoryAssembly == null) { throw new ArgumentNullException("repositoryAssembly"); } if (type == null) { throw new ArgumentNullException("type"); } return(RepositorySelector.GetRepository(repositoryAssembly).GetLogger(type.FullName)); }
/// <summary> /// Retrieves or creates a named logger. /// </summary> /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param> /// <param name="name">The name of the logger to retrieve.</param> /// <returns>The logger with the name specified.</returns> /// <remarks> /// <para> /// Retrieves a logger named as the <paramref name="name"/> /// parameter. If the named logger already exists, then the /// existing instance will be returned. Otherwise, a new instance is /// created. /// </para> /// <para> /// By default, loggers do not have a set level but inherit /// it from the hierarchy. This is one of the central features of /// log4net. /// </para> /// </remarks> public static ILogger GetLogger(Assembly repositoryAssembly, string name) { if (repositoryAssembly == null) { throw new ArgumentNullException("repositoryAssembly"); } if (name == null) { throw new ArgumentNullException("name"); } return(RepositorySelector.GetRepository(repositoryAssembly).GetLogger(name)); }
/// <summary> /// Returns the named logger if it exists. /// </summary> /// <param name="repository">The repository to lookup in.</param> /// <param name="name">The fully qualified logger name to look for.</param> /// <returns> /// The logger found, or <c>null</c> if the named logger does not exist in the /// specified repository. /// </returns> /// <remarks> /// <para> /// If the named logger exists (in the specified repository) then it /// returns a reference to the logger, otherwise it returns /// <c>null</c>. /// </para> /// </remarks> public static ILogger Exists(string repository, string name) { if (repository == null) { throw new ArgumentNullException("repository"); } if (name == null) { throw new ArgumentNullException("name"); } return(RepositorySelector.GetRepository(repository).Exists(name)); }
/// <summary> /// Shorthand for <see cref="LogManager.GetLogger(string)"/>. /// </summary> /// <remarks> /// Gets the logger for the fully qualified name of the type specified. /// </remarks> /// <param name="domain">The domain to lookup in.</param> /// <param name="type">The <paramref name="type"/> opf which the fullname will be used as the name of the logger to retrieve.</param> /// <returns>The logger with the name specified.</returns> public static ILogger GetLogger(string domain, Type type) { if (domain == null) { throw new ArgumentNullException("domain"); } if (type == null) { throw new ArgumentNullException("type"); } return(RepositorySelector.GetRepository(domain).GetLogger(type.FullName)); }
/// <summary> /// Retrieves or creates a named logger. /// </summary> /// <remarks> /// <para> /// Retrieves a logger named as the <paramref name="name"/> /// parameter. If the named logger already exists, then the /// existing instance will be returned. Otherwise, a new instance is /// created. /// </para> /// <para> /// By default, loggers do not have a set level but inherit /// it from the hierarchy. This is one of the central features of /// log4net. /// </para> /// </remarks> /// <param name="domain">The domain to lookup in.</param> /// <param name="name">The name of the logger to retrieve.</param> /// <returns>The logger with the name specified.</returns> public static ILogger GetLogger(string domain, string name) { if (domain == null) { throw new ArgumentNullException("domain"); } if (name == null) { throw new ArgumentNullException("name"); } return(RepositorySelector.GetRepository(domain).GetLogger(name)); }
/// <summary> /// Returns the named logger if it exists. /// </summary> /// <remarks> /// <para>If the named logger exists (in the specified assembly's domain) then it /// returns a reference to the logger, otherwise it returns /// <c>null</c>.</para> /// </remarks> /// <param name="domainAssembly">The assembly to use to lookup the domain.</param> /// <param name="name">The fully qualified logger name to look for.</param> /// <returns> /// The logger found, or <c>null</c> if the named logger does not exist in the /// specified assembly's domain. /// </returns> public static ILogger Exists(Assembly domainAssembly, string name) { if (domainAssembly == null) { throw new ArgumentNullException("domainAssembly"); } if (name == null) { throw new ArgumentNullException("name"); } return(RepositorySelector.GetRepository(domainAssembly).Exists(name)); }