Log4J 在循环中将日志写到文件但只出现在一个文件中的问题

/**
 * Adds an AppenderControl to this set. If this set already contains the element, the call leaves the set unchanged
 * and returns false.
 *
 * @param control The AppenderControl to add.
 * @return true if this set did not already contain the specified element
 */
public boolean add(final AppenderControl control) {
    boolean success;
    do {
        final AppenderControl[] original = appenderArray;
        for (final AppenderControl existing : original) {
            if (existing.equals(control)) {
                return false; // the appender is already in the list
            }
        }
        final AppenderControl[] copy = Arrays.copyOf(original, original.length + 1);
        copy[copy.length - 1] = control;
        success = appenderArrayUpdater.compareAndSet(this, original, copy);
    } while (!success); // Could not swap: array was modified by another thread
    return true; // successfully added
}
// AppenderControl is a helper object whose purpose is to make it
// easier for LoggerConfig to manage and invoke Appenders.
// LoggerConfig manages Appenders by their name. To facilitate this,
// two AppenderControl objects are considered equal if and only
// if they have the same appender name.
@Override
public boolean equals(final Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof AppenderControl)) {
        return false;
    }
    final AppenderControl other = (AppenderControl) obj;
    return Objects.equals(appenderName, other.appenderName);
}q

其equals方法只比较了name,故出现问题

相关文章

显卡天梯图2024最新版,显卡是电脑进行图形处理的重要设备,...
初始化电脑时出现问题怎么办,可以使用win系统的安装介质,连...
todesk远程开机怎么设置,两台电脑要在同一局域网内,然后需...
油猴谷歌插件怎么安装,可以通过谷歌应用商店进行安装,需要...
虚拟内存这个名词想必很多人都听说过,我们在使用电脑的时候...