Note that Spring has the same annotation, but they use a default order value of Integer.MAX_VALUE. In this case, I even put an unannotated class as lower priority than that.
Also, I think I can update how the weighted ConfigurationFactory lookup. Would be nice in 2.2 to support it in general for plugins (see LOG4J2-745). On 24 September 2014 01:54, Remko Popma <[email protected]> wrote: > Never mind; I thought this was a new addition. I now realize the Order > annotation has been there for a long time and renaming it would impact > existing configurations. This is not my intention, so please disregard my > previous message. > > > On Wednesday, September 24, 2014, Remko Popma <[email protected]> > wrote: > >> Request: is it possible to rename Order to SortOrder? >> I associate orders with commercial transactions (buy Order, sell Order). >> >> Sent from my iPhone >> >> > On 2014/09/24, at 14:39, [email protected] wrote: >> > >> > Add Comparator for @Order-annotated classes. >> > >> > >> > Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo >> > Commit: >> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/4aa329af >> > Tree: >> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/4aa329af >> > Diff: >> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/4aa329af >> > >> > Branch: refs/heads/master >> > Commit: 4aa329af77abd498fb8791fdad640e120ccf2b54 >> > Parents: b61f6f9 >> > Author: Matt Sicker <[email protected]> >> > Authored: Sun Sep 21 21:20:53 2014 -0500 >> > Committer: Matt Sicker <[email protected]> >> > Committed: Wed Sep 24 00:03:01 2014 -0500 >> > >> > ---------------------------------------------------------------------- >> > .../apache/logging/log4j/core/config/Order.java | 4 +++ >> > .../log4j/core/config/OrderComparator.java | 4 +-- >> > log4j-core/src/test/resources/log4j-webvar.xml | 29 >> -------------------- >> > log4j-web/src/test/resources/log4j-webvar.xml | 29 >> ++++++++++++++++++++ >> > 4 files changed, 35 insertions(+), 31 deletions(-) >> > ---------------------------------------------------------------------- >> > >> > >> > >> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4aa329af/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Order.java >> > ---------------------------------------------------------------------- >> > diff --git >> a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Order.java >> b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Order.java >> > index eadc931..f7f8e4e 100644 >> > --- >> a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Order.java >> > +++ >> b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Order.java >> > @@ -27,5 +27,9 @@ import java.lang.annotation.Target; >> > @Retention(RetentionPolicy.RUNTIME) >> > @Target(ElementType.TYPE) >> > public @interface Order { >> > + /** >> > + * The priority of this annotated type. Larger numbers indicate >> lower priority with a lowest priority of >> > + * {@link Integer#MAX_VALUE}. >> > + */ >> > int value(); >> > } >> > >> > >> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4aa329af/log4j-core/src/main/java/org/apache/logging/log4j/core/config/OrderComparator.java >> > ---------------------------------------------------------------------- >> > diff --git >> a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/OrderComparator.java >> b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/OrderComparator.java >> > index 8c8abdd..e9fce18 100644 >> > --- >> a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/OrderComparator.java >> > +++ >> b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/OrderComparator.java >> > @@ -15,7 +15,7 @@ public class OrderComparator implements >> Comparator<Class<?>> { >> > final Order lhsOrder = Assert.requireNonNull(lhs, >> "lhs").getAnnotation(Order.class); >> > final Order rhsOrder = Assert.requireNonNull(rhs, >> "rhs").getAnnotation(Order.class); >> > if (lhsOrder == null && rhsOrder == null) { >> > - // both unannotated means we can't really compare them >> > + // both unannotated means equal priority >> > return 0; >> > } >> > // if only one class is @Order-annotated, then prefer that one >> > @@ -25,7 +25,7 @@ public class OrderComparator implements >> Comparator<Class<?>> { >> > if (lhsOrder == null) { >> > return 1; >> > } >> > - // larger value means higher priority >> > + // larger value means lower priority >> > return Integer.signum(rhsOrder.value() - lhsOrder.value()); >> > } >> > } >> > >> > >> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4aa329af/log4j-core/src/test/resources/log4j-webvar.xml >> > ---------------------------------------------------------------------- >> > diff --git a/log4j-core/src/test/resources/log4j-webvar.xml >> b/log4j-core/src/test/resources/log4j-webvar.xml >> > deleted file mode 100644 >> > index de3777a..0000000 >> > --- a/log4j-core/src/test/resources/log4j-webvar.xml >> > +++ /dev/null >> > @@ -1,29 +0,0 @@ >> > -<?xml version="1.0" encoding="UTF-8"?> >> > -<!-- >> > - ~ Licensed to the Apache Software Foundation (ASF) under one or more >> > - ~ contributor license agreements. See the NOTICE file distributed >> with >> > - ~ this work for additional information regarding copyright ownership. >> > - ~ The ASF licenses this file to You under the Apache License, >> Version 2.0 >> > - ~ (the "License"); you may not use this file except in compliance >> with >> > - ~ the License. You may obtain a copy of the License at >> > - ~ >> > - ~ http://www.apache.org/licenses/LICENSE-2.0 >> > - ~ >> > - ~ Unless required by applicable law or agreed to in writing, software >> > - ~ distributed under the License is distributed on an "AS IS" BASIS, >> > - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or >> implied. >> > - ~ See the License for the specific language governing permissions and >> > - ~ limitations under the License. >> > - --> >> > -<Configuration status="OFF"> >> > - <Appenders> >> > - <File name="file" >> fileName="${web:initParam.myapp.logdir}/myapp.log" append="true"> >> > - <PatternLayout pattern="%d [%t] %-5p %c - %m%n"/> >> > - </File> >> > - </Appenders> >> > - <Loggers> >> > - <Root level="warn"> >> > - <AppenderRef ref="file"/> >> > - </Root> >> > - </Loggers> >> > -</Configuration> >> > \ No newline at end of file >> > >> > >> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4aa329af/log4j-web/src/test/resources/log4j-webvar.xml >> > ---------------------------------------------------------------------- >> > diff --git a/log4j-web/src/test/resources/log4j-webvar.xml >> b/log4j-web/src/test/resources/log4j-webvar.xml >> > new file mode 100644 >> > index 0000000..de3777a >> > --- /dev/null >> > +++ b/log4j-web/src/test/resources/log4j-webvar.xml >> > @@ -0,0 +1,29 @@ >> > +<?xml version="1.0" encoding="UTF-8"?> >> > +<!-- >> > + ~ Licensed to the Apache Software Foundation (ASF) under one or more >> > + ~ contributor license agreements. See the NOTICE file distributed >> with >> > + ~ this work for additional information regarding copyright ownership. >> > + ~ The ASF licenses this file to You under the Apache License, >> Version 2.0 >> > + ~ (the "License"); you may not use this file except in compliance >> with >> > + ~ the License. You may obtain a copy of the License at >> > + ~ >> > + ~ http://www.apache.org/licenses/LICENSE-2.0 >> > + ~ >> > + ~ Unless required by applicable law or agreed to in writing, software >> > + ~ distributed under the License is distributed on an "AS IS" BASIS, >> > + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or >> implied. >> > + ~ See the License for the specific language governing permissions and >> > + ~ limitations under the License. >> > + --> >> > +<Configuration status="OFF"> >> > + <Appenders> >> > + <File name="file" >> fileName="${web:initParam.myapp.logdir}/myapp.log" append="true"> >> > + <PatternLayout pattern="%d [%t] %-5p %c - %m%n"/> >> > + </File> >> > + </Appenders> >> > + <Loggers> >> > + <Root level="warn"> >> > + <AppenderRef ref="file"/> >> > + </Root> >> > + </Loggers> >> > +</Configuration> >> > \ No newline at end of file >> > >> > -- Matt Sicker <[email protected]>
