Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/changelog/3.5.1/340-appender-name-not-unique.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://logging.apache.org/xml/ns"
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
type="fixed">
<issue id="340" link="https://github.com/apache/logging-log4net/issues/340"/>
<description format="asciidoc">Stop documenting `IAppender.Name` as unique. Uniqueness is not
enforced, and `GetAppender(string)` and `RemoveAppender(string)` now say they act on the first
attached appender with that name (reported by @hidingmyname, fixed by @FreeAndNil)</description>
</entry>
2 changes: 1 addition & 1 deletion src/log4net/Appender/AppenderSkeleton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public virtual void ActivateOptions()
}

/// <summary>
/// Gets or sets the name that uniquely identifies this appender.
/// Gets or sets the name of this appender.
/// </summary>
public string Name { get; set; } = string.Empty;

Expand Down
19 changes: 2 additions & 17 deletions src/log4net/Appender/BufferingForwardingAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,7 @@ public virtual AppenderCollection Appenders
}
}

/// <summary>
/// Looks for the appender with the specified name.
/// </summary>
/// <param name="name">The name of the appender to lookup.</param>
/// <returns>
/// The appender with the specified name, or <see langword="null"/>.
/// </returns>
/// <inheritdoc/>
public virtual IAppender? GetAppender(string? name)
{
lock (LockObj)
Expand Down Expand Up @@ -195,16 +189,7 @@ public virtual void RemoveAllAppenders()
return null;
}

/// <summary>
/// Removes the appender with the specified name from the list of appenders.
/// </summary>
/// <param name="name">The name of the appender to remove.</param>
/// <returns>The appender removed from the list</returns>
/// <remarks>
/// The appender removed is not closed.
/// If you are discarding the appender you must call
/// <see cref="IAppender.Close"/> on the appender removed.
/// </remarks>
/// <inheritdoc/>
public virtual IAppender? RemoveAppender(string? name)
{
lock (LockObj)
Expand Down
24 changes: 2 additions & 22 deletions src/log4net/Appender/ForwardingAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,7 @@ public virtual AppenderCollection Appenders
}
}

/// <summary>
/// Looks for the appender with the specified name.
/// </summary>
/// <param name="name">The name of the appender to lookup.</param>
/// <returns>
/// The appender with the specified name, or <see langword="null"/>.
/// </returns>
/// <remarks>
/// <para>
/// Get the named appender attached to this appender.
/// </para>
/// </remarks>
/// <inheritdoc/>
public virtual IAppender? GetAppender(string? name)
{
lock (LockObj)
Expand Down Expand Up @@ -190,16 +179,7 @@ public virtual void RemoveAllAppenders()
return null;
}

/// <summary>
/// Removes the appender with the specified name from the list of appenders.
/// </summary>
/// <param name="name">The name of the appender to remove.</param>
/// <returns>The appender removed from the list</returns>
/// <remarks>
/// The appender removed is not closed.
/// If you are discarding the appender you must call
/// <see cref="IAppender.Close"/> on the appender removed.
/// </remarks>
/// <inheritdoc/>
public virtual IAppender? RemoveAppender(string? name)
{
lock (LockObj)
Expand Down
2 changes: 1 addition & 1 deletion src/log4net/Appender/IAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public interface IAppender
/// </summary>
/// <value>The name of the appender.</value>
/// <remarks>
/// <para>The name uniquely identifies the appender.</para>
/// <para>Used to look the appender up by name. Uniqueness is not enforced, and a lookup returns the first match.</para>
/// </remarks>
string Name { get; set; }
}
2 changes: 2 additions & 0 deletions src/log4net/Core/IAppenderAttachable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public interface IAppenderAttachable
/// Returns an attached appender with the <paramref name="name"/> specified.
/// If no appender with the specified name is found <see langword="null"/> will be
/// returned.
/// If several attached appenders share the name, the first one attached is returned.
/// </para>
/// </remarks>
IAppender? GetAppender(string? name);
Expand Down Expand Up @@ -109,6 +110,7 @@ public interface IAppenderAttachable
/// <returns>The appender removed from the list</returns>
/// <remarks>
/// <para>
/// If several attached appenders share the name, only the first one attached is removed.
/// The appender removed is not closed.
/// If you are discarding the appender you must call
/// <see cref="IAppender.Close"/> on the appender removed.
Expand Down
19 changes: 2 additions & 17 deletions src/log4net/Repository/Hierarchy/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,7 @@ public virtual AppenderCollection Appenders
}
}

/// <summary>
/// Look for the appender named as <paramref name="name"/>
/// </summary>
/// <param name="name">The name of the appender to lookup</param>
/// <returns>The appender with the name specified, or <see langword="null"/>.</returns>
/// <inheritdoc/>
public virtual IAppender? GetAppender(string? name)
{
_appenderLock.AcquireReaderLock();
Expand Down Expand Up @@ -295,18 +291,7 @@ public virtual void RemoveAllAppenders()
return null;
}

/// <summary>
/// Remove the appender passed as parameter form the list of appenders.
/// </summary>
/// <param name="name">The name of the appender to remove</param>
/// <returns>The appender removed from the list</returns>
/// <remarks>
/// <para>
/// The appender removed is not closed.
/// If you are discarding the appender you must call
/// <see cref="IAppender.Close"/> on the appender removed.
/// </para>
/// </remarks>
/// <inheritdoc/>
public virtual IAppender? RemoveAppender(string? name)
{
_appenderLock.AcquireWriterLock();
Expand Down
27 changes: 2 additions & 25 deletions src/log4net/Util/AppenderAttachedImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,7 @@ public AppenderCollection Appenders
}
}

/// <summary>
/// Gets an attached appender with the specified name.
/// </summary>
/// <param name="name">The name of the appender to get.</param>
/// <returns>
/// The appender with the name specified, or <see langword="null"/> if no appender with the
/// specified name is found.
/// </returns>
/// <remarks>
/// <para>
/// Lookup an attached appender by name.
/// </para>
/// </remarks>
/// <inheritdoc/>
public IAppender? GetAppender(string? name)
{
if (_appenderList is not null && name is not null)
Expand Down Expand Up @@ -288,18 +276,7 @@ public void RemoveAllAppenders()
return appender;
}

/// <summary>
/// Removes the appender with the specified name from the list of appenders.
/// </summary>
/// <param name="name">The name of the appender to remove.</param>
/// <returns>The appender removed from the list</returns>
/// <remarks>
/// <para>
/// The appender removed is not closed.
/// If you are discarding the appender you must call
/// <see cref="IAppender.Close"/> on the appender removed.
/// </para>
/// </remarks>
/// <inheritdoc/>
public IAppender? RemoveAppender(string name) => RemoveAppender(GetAppender(name));

/// <summary>
Expand Down
Loading