Does using the @Required annotation result in the same behavior?

The old code logged an ERROR level message and returned null, so the 
configuration for that appender was ignored. 

How does it behave now if a null name or filename is configured?

Remko

Sent from my iPhone

> On 2016/08/09, at 4:54, [email protected] wrote:
> 
> Repository: logging-log4j2
> Updated Branches:
>  refs/heads/master de528c5f8 -> 9401a1f1e
> 
> 
> [LOG4J2-1505] Create a Builder for FileAppender. Use @Required per
> Matt's suggestion. Thank you Matt!
> 
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/9401a1f1
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/9401a1f1
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/9401a1f1
> 
> Branch: refs/heads/master
> Commit: 9401a1f1e52e271727c2b07a5b7aeafcb7f1768b
> Parents: de528c5
> Author: Gary Gregory <[email protected]>
> Authored: Mon Aug 8 12:54:49 2016 -0700
> Committer: Gary Gregory <[email protected]>
> Committed: Mon Aug 8 12:54:49 2016 -0700
> 
> ----------------------------------------------------------------------
> .../apache/logging/log4j/core/appender/FileAppender.java | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9401a1f1/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileAppender.java
> ----------------------------------------------------------------------
> diff --git 
> a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileAppender.java
>  
> b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileAppender.java
> index 3f364cc..b13cb01 100644
> --- 
> a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileAppender.java
> +++ 
> b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileAppender.java
> @@ -28,6 +28,7 @@ import 
> org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
> import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
> import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
> import org.apache.logging.log4j.core.config.plugins.PluginElement;
> +import 
> org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
> import org.apache.logging.log4j.core.layout.PatternLayout;
> import org.apache.logging.log4j.core.net.Advertiser;
> import org.apache.logging.log4j.core.util.Booleans;
> @@ -45,6 +46,7 @@ public final class FileAppender extends 
> AbstractOutputStreamAppender<FileManager
>     public static class Builder implements 
> org.apache.logging.log4j.core.util.Builder<FileAppender> {
> 
>         @PluginBuilderAttribute
> +        @Required
>         private String fileName;
> 
>         @PluginBuilderAttribute
> @@ -54,6 +56,7 @@ public final class FileAppender extends 
> AbstractOutputStreamAppender<FileManager
>         private boolean locking;
> 
>         @PluginBuilderAttribute
> +        @Required
>         private String name;
> 
>         @PluginBuilderAttribute
> @@ -95,14 +98,6 @@ public final class FileAppender extends 
> AbstractOutputStreamAppender<FileManager
>             if (!bufferedIo && bufferSize > 0) {
>                 LOGGER.warn("The bufferSize is set to {} but bufferedIo is 
> not true: {}", bufferSize, bufferedIo);
>             }
> -            if (name == null) {
> -                LOGGER.error("No name provided for FileAppender");
> -                return null;
> -            }
> -            if (fileName == null) {
> -                LOGGER.error("No filename provided for FileAppender with 
> name {}", name);
> -                return null;
> -            }
>             if (layout == null) {
>                 layout = PatternLayout.createDefaultLayout();
>             }
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to