diff --git a/logback-access/pom.xml b/logback-access/pom.xml index 13df6b597a1c870e06faf3a8e3ef8b427a23416c..db92f932e2db961cb4de526078f05b31ecd54827 100755 --- a/logback-access/pom.xml +++ b/logback-access/pom.xml @@ -7,7 +7,7 @@ ch.qos.logback logback-parent - 1.0.12-SNAPSHOT + 2.0.0-SNAPSHOT logback-access @@ -50,14 +50,6 @@ true - - - - - - - - org.eclipse.jetty jetty-server @@ -65,13 +57,6 @@ true - - - - - - - org.codehaus.janino janino @@ -99,9 +84,10 @@ org.apache.maven.plugins maven-surefire-plugin - ${surefire.version} + ${maven-surefire-plugin.version} once + plain true @@ -115,6 +101,7 @@ org.apache.maven.plugins maven-jar-plugin + ${maven-jar-plugin.version} ${project.build.outputDirectory}/META-INF/MANIFEST.MF @@ -148,6 +135,20 @@ ch.qos.logback.access.* + + + ch.qos.logback.core.rolling, + ch.qos.logback.core.rolling.helper, + javax.servlet.*;version="2.5", + javax.*;resolution:=optional, + org.apache.catalina.*;version="${tomcat.version}";resolution:=optional, + org.eclipse.jetty.*;version="${jetty.version}";resolution:=optional, + * + J2SE-1.5 diff --git a/logback-access/src/main/java/ch/qos/logback/access/AccessConstants.java b/logback-access/src/main/java/ch/qos/logback/access/AccessConstants.java index 30e20fcc972b3f638ad7b09b1065d8a49f275da1..ea45adc32cb97652979cdba88dc1d79f17bbb0fc 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/AccessConstants.java +++ b/logback-access/src/main/java/ch/qos/logback/access/AccessConstants.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/PatternLayout.java b/logback-access/src/main/java/ch/qos/logback/access/PatternLayout.java index 3ef96540120b5cb655c3f675d64728414372cfc6..601aa75fd17787021226dc0931c98522d4d35c98 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/PatternLayout.java +++ b/logback-access/src/main/java/ch/qos/logback/access/PatternLayout.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/PatternLayoutEncoder.java b/logback-access/src/main/java/ch/qos/logback/access/PatternLayoutEncoder.java index 72f86d3583123ee4dbc0241107e5bbdb218b4f94..d0c043f1417c5c047b5af0a48abd2c7963cf613e 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/PatternLayoutEncoder.java +++ b/logback-access/src/main/java/ch/qos/logback/access/PatternLayoutEncoder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/ViewStatusMessagesServlet.java b/logback-access/src/main/java/ch/qos/logback/access/ViewStatusMessagesServlet.java index e3a25bca0b1c47755fa2309f5f53ca1ae65ff6a3..e07b2c1786250eff9094432c10af99a037c4ff60 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/ViewStatusMessagesServlet.java +++ b/logback-access/src/main/java/ch/qos/logback/access/ViewStatusMessagesServlet.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/boolex/JaninoEventEvaluator.java b/logback-access/src/main/java/ch/qos/logback/access/boolex/JaninoEventEvaluator.java index 674889a505af59d7f10d8eeb3c491378617741dc..6b8a06c0ec3175baecfbe7bc92cbe12148a744f7 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/boolex/JaninoEventEvaluator.java +++ b/logback-access/src/main/java/ch/qos/logback/access/boolex/JaninoEventEvaluator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/db/DBAppender.java b/logback-access/src/main/java/ch/qos/logback/access/db/DBAppender.java index 0e91dc7baf5425053d064a97326482bcf177de27..e2e5a12229ee68866f151c22e9342df5d5608135 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/db/DBAppender.java +++ b/logback-access/src/main/java/ch/qos/logback/access/db/DBAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/db/script/mysql.sql b/logback-access/src/main/java/ch/qos/logback/access/db/script/mysql.sql index ca4687d19b6094a7e6e92981163eb44b16fc61fb..16e0e458e0e7d4862acb936df4c0b32e794ac16c 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/db/script/mysql.sql +++ b/logback-access/src/main/java/ch/qos/logback/access/db/script/mysql.sql @@ -6,7 +6,7 @@ # This SQL script creates the required tables by ch.qos.logback.access.db.DBAppender. # -# It is intended for MySQL databases. It has been tested on MySQL 5.0.22 with +# It is intended for MySQL databases. It has been tested on MySQL 5.5.31 with # INNODB tables. @@ -16,7 +16,7 @@ DROP TABLE IF EXISTS access_event; COMMIT; BEGIN; -CREATE TABLE ACCESS_EVENT +CREATE TABLE access_event ( timestmp BIGINT NOT NULL, requestURI VARCHAR(254), diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/CountingFilter.java b/logback-access/src/main/java/ch/qos/logback/access/filter/CountingFilter.java index a2437e73d4e53532522d21cf811133c52b9c9bc1..e9aad40ecd92849eb836976cf889908e8b3daecb 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/CountingFilter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/filter/CountingFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/PeriodicStats.java b/logback-access/src/main/java/ch/qos/logback/access/filter/PeriodicStats.java index ec7d128a8fa177a74ef9dde0b6bd88bce614eb8e..5091476319ce7e4e5df8aec90d70eb126c902c77 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/PeriodicStats.java +++ b/logback-access/src/main/java/ch/qos/logback/access/filter/PeriodicStats.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/StatisticalView.java b/logback-access/src/main/java/ch/qos/logback/access/filter/StatisticalView.java index cd6a3e6150bf58adb0e1b8cc80092d3c38d9868f..5b3c17a121d9589a081b8589d3f8ce2c7926bc59 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/StatisticalView.java +++ b/logback-access/src/main/java/ch/qos/logback/access/filter/StatisticalView.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/StatisticalViewImpl.java b/logback-access/src/main/java/ch/qos/logback/access/filter/StatisticalViewImpl.java index f99923d9b4afb3b486ce8563dcb2ac36e46d8dc9..c95b43c21d5e946eef1b106d9eb16905e0de73c4 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/StatisticalViewImpl.java +++ b/logback-access/src/main/java/ch/qos/logback/access/filter/StatisticalViewImpl.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByDay.java b/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByDay.java index 66a370e459a8fbb37dcb3c7866a98353ca5be591..6c11568e859b4f2803f59dcffbcfb16e95aa2717 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByDay.java +++ b/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByDay.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByHour.java b/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByHour.java index d80f0abef926b58a3b8e024fd3d1af9784bb94fb..2e2d7e781cc3dce6f6bdabf66559e6a7a7416dad 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByHour.java +++ b/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByHour.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByMinute.java b/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByMinute.java index 60d9333e905889663250830d340c7c84d0152ede..16bb262563cb3184faa0d6eb52b8e756a51201e0 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByMinute.java +++ b/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByMinute.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByMonth.java b/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByMonth.java index 1fa91cc901ec090b02bbd1e6db5ef6058c6d0a22..ce34b4b1d36ea30eda80bf9ef87aea4275aad92f 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByMonth.java +++ b/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByMonth.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByWeek.java b/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByWeek.java index c42a796ec33eb9816ac584c510e133289ba1ece4..81b845e4d28385c1fc82616ff47e86ef5d7a7199 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByWeek.java +++ b/logback-access/src/main/java/ch/qos/logback/access/filter/StatsByWeek.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/html/DefaultCssBuilder.java b/logback-access/src/main/java/ch/qos/logback/access/html/DefaultCssBuilder.java index bec5c28affe399b9ba4cd7ffcbfa7c7bb41453f1..fb0c26e8cf3046d87f82b405d9fa14768ac9094d 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/html/DefaultCssBuilder.java +++ b/logback-access/src/main/java/ch/qos/logback/access/html/DefaultCssBuilder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java b/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java index 5f23676d2c9936eac14f82b08db09e187aad75bd..4f3132186fb6302dda0f7b65f3c937cbedb7d311 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java +++ b/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/html/UrlCssBuilder.java b/logback-access/src/main/java/ch/qos/logback/access/html/UrlCssBuilder.java index aea01f65df492e39fcbc8f7860eba92a81337ae6..1202bfbeee0a35666132dba60c98a0eb5f20538c 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/html/UrlCssBuilder.java +++ b/logback-access/src/main/java/ch/qos/logback/access/html/UrlCssBuilder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/JettyServerAdapter.java b/logback-access/src/main/java/ch/qos/logback/access/jetty/JettyServerAdapter.java index 877b84b4535287421fdf6d35ad9f211a392d5783..44ca2bc7fe76befb9585cfc5cb1f9b80909a2970 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/jetty/JettyServerAdapter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/jetty/JettyServerAdapter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java b/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java index c2bb9711ae428c95dd6e71e46e9ec76161ec2fe9..16f382c6537d0782c0f6984a0646cb7ec810468a 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java +++ b/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogRegistry.java b/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogRegistry.java index 6eddce35cf81d84cba99314ed7a6f001ce355a9f..b81ca74a2141dd32e96d5de6e858e4e6df53a51a 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogRegistry.java +++ b/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogRegistry.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java b/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java index 9ad01a159ec73820c8b6eaec0af1a4b55bf8c2d0..50c7ae1045de76cfb5b5ec884670ba433107c184 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java +++ b/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -19,8 +19,6 @@ import ch.qos.logback.access.PatternLayoutEncoder; import ch.qos.logback.access.boolex.JaninoEventEvaluator; import ch.qos.logback.access.joran.action.ConfigurationAction; import ch.qos.logback.access.joran.action.EvaluatorAction; -import ch.qos.logback.access.net.SSLSocketAppender; -import ch.qos.logback.access.net.server.SSLServerSocketAppender; import ch.qos.logback.access.sift.SiftAction; import ch.qos.logback.core.AppenderBase; import ch.qos.logback.core.UnsynchronizedAppenderBase; @@ -33,9 +31,8 @@ import ch.qos.logback.core.joran.conditional.ElseAction; import ch.qos.logback.core.joran.conditional.IfAction; import ch.qos.logback.core.joran.conditional.ThenAction; import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry; -import ch.qos.logback.core.joran.spi.Pattern; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.joran.spi.RuleStore; -import ch.qos.logback.core.net.ssl.SSLConfiguration; import ch.qos.logback.core.net.ssl.SSLNestedComponentRegistryRules; @@ -51,22 +48,22 @@ public class JoranConfigurator extends JoranConfiguratorBase { public void addInstanceRules(RuleStore rs) { super.addInstanceRules(rs); - rs.addRule(new Pattern("configuration"), new ConfigurationAction()); - rs.addRule(new Pattern("configuration/appender-ref"), new AppenderRefAction()); + rs.addRule(new ElementSelector("configuration"), new ConfigurationAction()); + rs.addRule(new ElementSelector("configuration/appender-ref"), new AppenderRefAction()); - rs.addRule(new Pattern("configuration/appender/sift"), new SiftAction()); - rs.addRule(new Pattern("configuration/appender/sift/*"), new NOPAction()); + rs.addRule(new ElementSelector("configuration/appender/sift"), new SiftAction()); + rs.addRule(new ElementSelector("configuration/appender/sift/*"), new NOPAction()); - rs.addRule(new Pattern("configuration/evaluator"), new EvaluatorAction()); + rs.addRule(new ElementSelector("configuration/evaluator"), new EvaluatorAction()); // add if-then-else support - rs.addRule(new Pattern("*/if"), new IfAction()); - rs.addRule(new Pattern("*/if/then"), new ThenAction()); - rs.addRule(new Pattern("*/if/then/*"), new NOPAction()); - rs.addRule(new Pattern("*/if/else"), new ElseAction()); - rs.addRule(new Pattern("*/if/else/*"), new NOPAction()); + rs.addRule(new ElementSelector("*/if"), new IfAction()); + rs.addRule(new ElementSelector("*/if/then"), new ThenAction()); + rs.addRule(new ElementSelector("*/if/then/*"), new NOPAction()); + rs.addRule(new ElementSelector("*/if/else"), new ElseAction()); + rs.addRule(new ElementSelector("*/if/else/*"), new NOPAction()); - rs.addRule(new Pattern("configuration/include"), new IncludeAction()); + rs.addRule(new ElementSelector("configuration/include"), new IncludeAction()); } @Override @@ -78,8 +75,6 @@ public class JoranConfigurator extends JoranConfiguratorBase { registry.add(AppenderBase.class, "encoder", PatternLayoutEncoder.class); registry.add(UnsynchronizedAppenderBase.class, "encoder", PatternLayoutEncoder.class); - registry.add(SSLSocketAppender.class, "ssl", SSLConfiguration.class); - registry.add(SSLServerSocketAppender.class, "ssl", SSLConfiguration.class); SSLNestedComponentRegistryRules.addDefaultNestedComponentRegistryRules(registry); } diff --git a/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java b/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java index 21ea6b37138adf2248b7d8853eb6fe01ed0d8b23..fdb86351a89151786d71acf3d349ae0e7c87473f 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java +++ b/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/joran/action/EvaluatorAction.java b/logback-access/src/main/java/ch/qos/logback/access/joran/action/EvaluatorAction.java index b9f6c712b9111a9b8f3b21b8e80b6e10db6fb4b5..527916e9276f98dd5888413e77e022375111944e 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/joran/action/EvaluatorAction.java +++ b/logback-access/src/main/java/ch/qos/logback/access/joran/action/EvaluatorAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/AccessEventPreSerializationTransformer.java b/logback-access/src/main/java/ch/qos/logback/access/net/AccessEventPreSerializationTransformer.java index fa04e036303b1ae2cff356711e2cce03e60220ed..b5d3aa2f6110248518f1fbfc7e51fd15b3b0c7f7 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/net/AccessEventPreSerializationTransformer.java +++ b/logback-access/src/main/java/ch/qos/logback/access/net/AccessEventPreSerializationTransformer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/SMTPAppender.java b/logback-access/src/main/java/ch/qos/logback/access/net/SMTPAppender.java index b12bb7824bac34051bd9bc96875b1749d0b7be2c..cdee031143081e93ed13a591e5525c0141291b22 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/net/SMTPAppender.java +++ b/logback-access/src/main/java/ch/qos/logback/access/net/SMTPAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -86,7 +86,7 @@ public class SMTPAppender extends SMTPAppenderBase { return pl; } - protected boolean isEventMarkedForBufferRemoval(IAccessEvent eventObject) { + protected boolean eventMarksEndOfLife(IAccessEvent eventObject) { return false; } diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/SSLSocketAppender.java b/logback-access/src/main/java/ch/qos/logback/access/net/SSLSocketAppender.java index d23203aafdaf1707fb07939f2a085eafb814184a..f3de0bf3388e6a0485775e940b041a99b8e2fffb 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/net/SSLSocketAppender.java +++ b/logback-access/src/main/java/ch/qos/logback/access/net/SSLSocketAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -16,7 +16,7 @@ package ch.qos.logback.access.net; import java.net.InetAddress; import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.net.SSLSocketAppenderBase; +import ch.qos.logback.core.net.AbstractSSLSocketAppender; import ch.qos.logback.core.spi.PreSerializationTransformer; /** @@ -27,7 +27,7 @@ import ch.qos.logback.core.spi.PreSerializationTransformer; * * @author Carl Harris */ -public class SSLSocketAppender extends SSLSocketAppenderBase { +public class SSLSocketAppender extends AbstractSSLSocketAppender { private final PreSerializationTransformer pst = new AccessEventPreSerializationTransformer(); @@ -38,16 +38,17 @@ public class SSLSocketAppender extends SSLSocketAppenderBase { /** * Connects to remote server at address and port. */ + @Deprecated public SSLSocketAppender(String host, int port) { - this(getAddressByName(host), port); + super(host, port); } /** * Connects to remote server at address and port. */ + @Deprecated public SSLSocketAppender(InetAddress address, int port) { - this.address = address; - this.port = port; + super(address.getHostAddress(), port); } @Override diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/SimpleSocketServer.java b/logback-access/src/main/java/ch/qos/logback/access/net/SimpleSocketServer.java index ff51aeea55ee7f5bc9332e4122bfb1f6bc74066b..6031f408fac7c78e017d8571fcb225474ce4bb6a 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/net/SimpleSocketServer.java +++ b/logback-access/src/main/java/ch/qos/logback/access/net/SimpleSocketServer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/SocketAppender.java b/logback-access/src/main/java/ch/qos/logback/access/net/SocketAppender.java index e600389d6688099196e91a0b1f6746aafd75c8b3..4004a06be0771635520a68cc159a81a75b18cc61 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/net/SocketAppender.java +++ b/logback-access/src/main/java/ch/qos/logback/access/net/SocketAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -17,7 +17,7 @@ package ch.qos.logback.access.net; import java.net.InetAddress; import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.net.SocketAppenderBase; +import ch.qos.logback.core.net.AbstractSocketAppender; import ch.qos.logback.core.spi.PreSerializationTransformer; /** @@ -32,7 +32,7 @@ import ch.qos.logback.core.spi.PreSerializationTransformer; * */ -public class SocketAppender extends SocketAppenderBase { +public class SocketAppender extends AbstractSocketAppender { PreSerializationTransformer pst = new AccessEventPreSerializationTransformer(); @@ -42,19 +42,17 @@ public class SocketAppender extends SocketAppenderBase { /** * Connects to remote server at address and port. */ + @Deprecated public SocketAppender(InetAddress address, int port) { - this.address = address; - this.remoteHost = address.getHostName(); - this.port = port; + super(address.getHostAddress(), port); } /** * Connects to remote server at host and port. */ + @Deprecated public SocketAppender(String host, int port) { - this.port = port; - this.address = getAddressByName(host); - this.remoteHost = host; + super(host, port); } @Override diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/SocketNode.java b/logback-access/src/main/java/ch/qos/logback/access/net/SocketNode.java index 5c08870ba849d9a0581525557b7a4ef90839c172..4b8acf49d5096ebf68172958b8a960e0e430ddf0 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/net/SocketNode.java +++ b/logback-access/src/main/java/ch/qos/logback/access/net/SocketNode.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/URLEvaluator.java b/logback-access/src/main/java/ch/qos/logback/access/net/URLEvaluator.java index e638a8f5461146cc662e205e8026aa0231999b3c..589e452a1ab7b49dbd4e0430f3afb9fd97573ff8 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/net/URLEvaluator.java +++ b/logback-access/src/main/java/ch/qos/logback/access/net/URLEvaluator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/server/SSLServerSocketAppender.java b/logback-access/src/main/java/ch/qos/logback/access/net/server/SSLServerSocketAppender.java index 67826f6a4291d6c70c47c33c8ee3f3d7ad650465..6c010ddd12d48ea29af03bec848eb4970f2a0714 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/net/server/SSLServerSocketAppender.java +++ b/logback-access/src/main/java/ch/qos/logback/access/net/server/SSLServerSocketAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/server/ServerSocketAppender.java b/logback-access/src/main/java/ch/qos/logback/access/net/server/ServerSocketAppender.java index 3981cbfda4454e75623a9240f26870b6b73f0f94..775fc93d9d3990a6ff2e41a107bca4e2ff852c02 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/net/server/ServerSocketAppender.java +++ b/logback-access/src/main/java/ch/qos/logback/access/net/server/ServerSocketAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -15,7 +15,7 @@ package ch.qos.logback.access.net.server; import ch.qos.logback.access.net.AccessEventPreSerializationTransformer; import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.net.server.ServerSocketAppenderBase; +import ch.qos.logback.core.net.server.AbstractServerSocketAppender; import ch.qos.logback.core.spi.PreSerializationTransformer; /** @@ -26,7 +26,7 @@ import ch.qos.logback.core.spi.PreSerializationTransformer; * @author Carl Harris */ public class ServerSocketAppender - extends ServerSocketAppenderBase { + extends AbstractServerSocketAppender { private static final PreSerializationTransformer pst = new AccessEventPreSerializationTransformer(); diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/AccessConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/AccessConverter.java index c3c74dbe38467c5ed5d2f1f4d63ce8bef3421518..c28214b94ef56c7f625b1ad9b6fb104448c84aa3 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/AccessConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/AccessConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/ContentLengthConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/ContentLengthConverter.java index f4188fe073405f3933b9d20c795aca529aa29b83..7ac7ac847a99c164dae36bef1caa6d870ec1df88 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/ContentLengthConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/ContentLengthConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/DateConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/DateConverter.java index f6a005b8c0770fd9e312a40e9f4eead9c5851ede..08830c66ca768a2134cf8881591fb49b1d48a746 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/DateConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/DateConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/EnsureLineSeparation.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/EnsureLineSeparation.java index 566d5aa5744ba2a2c41de63ca0826eab6418f36f..28bad5fabb347893fbebe8d963009e4d1ef5fe0f 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/EnsureLineSeparation.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/EnsureLineSeparation.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/FullRequestConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/FullRequestConverter.java index 81e4f0724f1d7999d3a04cd16cbe2a58a2c8605b..ed78a4a55e366228ded9abce475aac0ac4c6fa2b 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/FullRequestConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/FullRequestConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/FullResponseConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/FullResponseConverter.java index 39505de1ebbe525758dbe8ff7a9d08fa5f1a9d15..57bd1af8596df9949270f90aec643ed64cad3019 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/FullResponseConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/FullResponseConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/LineSeparatorConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/LineSeparatorConverter.java index 31d5072814f811d0acc667074def7096b0ecffa6..d9be9120c9738de4c905d33628850822bcdbfe12 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/LineSeparatorConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/LineSeparatorConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/LocalIPAddressConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/LocalIPAddressConverter.java index db122890d743f2d144721d1d900a3ac254b1feda..ec844848b81d1ded933320517a180398ea8926de 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/LocalIPAddressConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/LocalIPAddressConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/LocalPortConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/LocalPortConverter.java index ac85063e9f0a6e2b3100efaa7aa551341e3d5599..f23f8ce8ce856824511f6fe81ab0043de950061b 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/LocalPortConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/LocalPortConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/NAConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/NAConverter.java index 6bf271bb7e5ca3e42920fb0b22dd495b8a36ddbc..c86f3bf81fa825388c5317ed249238b66a3b9568 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/NAConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/NAConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteHostConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteHostConverter.java index 741c640373dc6400016fd11afcbdb85e50758718..145691e0c6ab8c52a5ec969c30074f079e2f9b15 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteHostConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteHostConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteIPAddressConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteIPAddressConverter.java index 1cef0b696f90046386273a0889c799cde21cca1d..31e24c15383dbe91fac27dfec20850a2c7acfbd4 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteIPAddressConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteIPAddressConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteUserConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteUserConverter.java index 7c36e779549903667e859c84e4df9283f4ced114..655e362905310ba76abac772c80784add6e98abc 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteUserConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/RemoteUserConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestAttributeConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestAttributeConverter.java index ba43270aacc767bc61709b9b8ede63b7ad0e6451..bbf8a291c3a4ba7466fa7f50e0a20b37f8f4358c 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestAttributeConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestAttributeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestContentConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestContentConverter.java index 79c6904a188ce66f222c7c1342cacc3374d1f21c..22e85becdfa0e3fd04f1a5ba925b1fc5226c3e13 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestContentConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestContentConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestCookieConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestCookieConverter.java index 9d34d925f5cc649b2824cefb0e5b1574ac99c89c..b5b49a80b5e8d8a5c64f6a48f5e68c4e0d5bcc52 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestCookieConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestCookieConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestHeaderConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestHeaderConverter.java index 488fae1ab2f4ce1b118e499487e1c0a842e8a8dc..d1d4f52f5e56c31682e556d9195fbed8f048e870 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestHeaderConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestHeaderConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestMethodConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestMethodConverter.java index 8b44c5f1ee8cca29eb2dad775f471f4ac31c8ad7..6e3d3bf735e19cce84acc09aafd7c678c0f415dc 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestMethodConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestMethodConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestParameterConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestParameterConverter.java index 8c36e74d19e9cf8ec65acd4e160575181596a775..b18a83faf13c2d05f556dae60b9754d150a2c6f2 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestParameterConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestParameterConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestProtocolConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestProtocolConverter.java index bcc444f52c3fc202e530c06326572d237b2871b9..d2804fd61aa4b35c8c2dd63236e01f735a99e83c 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestProtocolConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestProtocolConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestURIConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestURIConverter.java index 5847c335c84e202eb80b866ac2282673180f229a..fa1db1e1ef3dfe3ae8d1c5ff73dec7b4e8a362e0 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestURIConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestURIConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestURLConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestURLConverter.java index ce92e1ff7d27f306b53d40970b3d3884d358d92c..de09637a6828ec64575f4787595216d7dca51f5f 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestURLConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/RequestURLConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/ResponseContentConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/ResponseContentConverter.java index 82195a91777c3bdd9cbd714c26886588b53d5bba..14e89289c8b4ba0842d78c8e839a8083c753c95d 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/ResponseContentConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/ResponseContentConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/ResponseHeaderConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/ResponseHeaderConverter.java index 75024487a7fc8b296de69bfd69140d354495302a..0945c101b7037a211587db0af89ff30a41b5f051 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/ResponseHeaderConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/ResponseHeaderConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/ServerNameConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/ServerNameConverter.java index 82a3259b0c749ee13bfd9a20fdbb34745bdc1cbd..0cb53c16a96564034e0f7f883adf11a004ba7f26 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/ServerNameConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/ServerNameConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/pattern/StatusCodeConverter.java b/logback-access/src/main/java/ch/qos/logback/access/pattern/StatusCodeConverter.java index c212d33a3947c136c72f0daa7b4650fad0162333..3c18f8a18c6224c1856285b3702b3b5e3bdd8743 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/pattern/StatusCodeConverter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/pattern/StatusCodeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeFilter.java b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeFilter.java index 7e317483f755f2af5d82cb7fa504ffa53428a960..180374b95fe69442cfd139bbd5e6c9679c4ab2da 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeFilter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeHttpServletRequest.java b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeHttpServletRequest.java index 86219fc09a93a276db754065a4ab4f1334eb8108..1eb3cb536dc8575e38e9dee7c16d923e2cbccbe8 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeHttpServletRequest.java +++ b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeHttpServletRequest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeHttpServletResponse.java b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeHttpServletResponse.java index 845b8cf9c372e2a271fa1d4b32bfc0bb90d36eaf..227fbff86ee8ea1ce9b38933856b44430031411f 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeHttpServletResponse.java +++ b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeHttpServletResponse.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletInputStream.java b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletInputStream.java index bc3f74fcbb1692e3c881227aafe347626175dab1..8d79ec8a7cad53e0c6c9e573bcac5d7fc57ad3d4 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletInputStream.java +++ b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletInputStream.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletOutputStream.java b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletOutputStream.java index 6f4a3ec64ebec6467f4451f97ae09b334118aca4..7642c3a9caf0ae543ec472605e09d0216dd0c97c 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletOutputStream.java +++ b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletOutputStream.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/servlet/Util.java b/logback-access/src/main/java/ch/qos/logback/access/servlet/Util.java index 04ac179798d50e807e3d60779928d96f0087434f..3df1811fae542e6755063b195f301dcc3a259e4b 100755 --- a/logback-access/src/main/java/ch/qos/logback/access/servlet/Util.java +++ b/logback-access/src/main/java/ch/qos/logback/access/servlet/Util.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/sift/AccessEventDiscriminator.java b/logback-access/src/main/java/ch/qos/logback/access/sift/AccessEventDiscriminator.java index 46bd1e4f0b392f1f5b5cf2eb2f04e01f89a251ca..5352463b1f964087957be3d72f82bd120c6af716 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/sift/AccessEventDiscriminator.java +++ b/logback-access/src/main/java/ch/qos/logback/access/sift/AccessEventDiscriminator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -17,8 +17,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import ch.qos.logback.access.spi.IAccessEvent; -import ch.qos.logback.core.sift.Discriminator; -import ch.qos.logback.core.spi.ContextAwareBase; +import ch.qos.logback.core.sift.AbstractDiscriminator; /** * @@ -30,10 +29,7 @@ import ch.qos.logback.core.spi.ContextAwareBase; * @author Ceki Gülcü * */ -public class AccessEventDiscriminator extends ContextAwareBase implements - Discriminator { - - boolean started = false; +public class AccessEventDiscriminator extends AbstractDiscriminator { /** * At present time the followed fields can be designated: COOKIE, @@ -120,10 +116,7 @@ public class AccessEventDiscriminator extends ContextAwareBase implements return null; } - public boolean isStarted() { - return started; - } - + @Override public void start() { int errorCount = 0; @@ -152,10 +145,6 @@ public class AccessEventDiscriminator extends ContextAwareBase implements } } - public void stop() { - started = false; - } - public void setFieldName(FieldName fieldName) { this.fieldName = fieldName; } diff --git a/logback-access/src/main/java/ch/qos/logback/access/sift/AppenderFactory.java b/logback-access/src/main/java/ch/qos/logback/access/sift/AppenderFactoryUsingJoran.java similarity index 61% rename from logback-access/src/main/java/ch/qos/logback/access/sift/AppenderFactory.java rename to logback-access/src/main/java/ch/qos/logback/access/sift/AppenderFactoryUsingJoran.java index abff1e9e832d52a752217312e148f0554dc0b96e..2610f0389ab781a149153bf305de4883b6c20b2b 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/sift/AppenderFactory.java +++ b/logback-access/src/main/java/ch/qos/logback/access/sift/AppenderFactoryUsingJoran.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -14,24 +14,22 @@ package ch.qos.logback.access.sift; import java.util.List; +import java.util.Map; import ch.qos.logback.access.spi.IAccessEvent; import ch.qos.logback.core.joran.event.SaxEvent; -import ch.qos.logback.core.sift.AppenderFactoryBase; +import ch.qos.logback.core.sift.AbstractAppenderFactoryUsingJoran; import ch.qos.logback.core.sift.SiftingJoranConfiguratorBase; -public class AppenderFactory extends AppenderFactoryBase { +public class AppenderFactoryUsingJoran extends AbstractAppenderFactoryUsingJoran { - String keyName; - - AppenderFactory(List eventList, String keyName) { - super(eventList); - this.keyName = keyName; + AppenderFactoryUsingJoran(List eventList, String key, Map parentPropertyMap) { + super(eventList, key, parentPropertyMap); } public SiftingJoranConfiguratorBase getSiftingJoranConfigurator( String keyValue) { - return new SiftingJoranConfigurator(keyName, keyValue); + return new SiftingJoranConfigurator(key, keyValue, parentPropertyMap); } } diff --git a/logback-access/src/main/java/ch/qos/logback/access/sift/SiftAction.java b/logback-access/src/main/java/ch/qos/logback/access/sift/SiftAction.java index 0498f28e3814afbe51c6547f7c19e383be1ec83d..8d952440f8b3b1d3861d36c1f885fbb5f3dc1d3e 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/sift/SiftAction.java +++ b/logback-access/src/main/java/ch/qos/logback/access/sift/SiftAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -15,6 +15,7 @@ package ch.qos.logback.access.sift; import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.xml.sax.Attributes; @@ -39,8 +40,9 @@ public class SiftAction extends Action implements InPlayListener { ic.removeInPlayListener(this); Object o = ic.peekObject(); if (o instanceof SiftingAppender) { - SiftingAppender siftingAppender = (SiftingAppender) o; - AppenderFactory appenderFactory = new AppenderFactory(seList, siftingAppender.getDiscriminatorKey()); + SiftingAppender siftingAppender = (SiftingAppender) o; + Map propertyMap = ic.getCopyOfPropertyMap(); + AppenderFactoryUsingJoran appenderFactory = new AppenderFactoryUsingJoran(seList, siftingAppender.getDiscriminatorKey(), propertyMap); siftingAppender.setAppenderFactory(appenderFactory); } } diff --git a/logback-access/src/main/java/ch/qos/logback/access/sift/SiftingAppender.java b/logback-access/src/main/java/ch/qos/logback/access/sift/SiftingAppender.java index 31f683f8a8f661928949d44633b77fb3f3d912fd..c7e27dd4f95c0f5885b0a1bc5db7f9a96425f56a 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/sift/SiftingAppender.java +++ b/logback-access/src/main/java/ch/qos/logback/access/sift/SiftingAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -40,6 +40,11 @@ public class SiftingAppender extends SiftingAppenderBase { return event.getTimeStamp(); } + @Override + protected boolean eventMarksEndOfLife(IAccessEvent event) { + return false; + } + @Override @DefaultClass(AccessEventDiscriminator.class) public void setDiscriminator(Discriminator discriminator) { diff --git a/logback-access/src/main/java/ch/qos/logback/access/sift/SiftingJoranConfigurator.java b/logback-access/src/main/java/ch/qos/logback/access/sift/SiftingJoranConfigurator.java index 6bec804cfe6b9ba7bbb0107b956baa0013f5622e..a91b9413b5da739eb04cf72974903d40eb64af81 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/sift/SiftingJoranConfigurator.java +++ b/logback-access/src/main/java/ch/qos/logback/access/sift/SiftingJoranConfigurator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -21,29 +21,28 @@ import ch.qos.logback.access.spi.IAccessEvent; import ch.qos.logback.core.Appender; import ch.qos.logback.core.joran.action.ActionConst; import ch.qos.logback.core.joran.action.AppenderAction; -import ch.qos.logback.core.joran.spi.Pattern; +import ch.qos.logback.core.joran.spi.ElementPath; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.joran.spi.RuleStore; import ch.qos.logback.core.sift.SiftingJoranConfiguratorBase; public class SiftingJoranConfigurator extends SiftingJoranConfiguratorBase { - String key; - String value; - SiftingJoranConfigurator(String key, String value) { - this.key = key; - this.value = value; + + SiftingJoranConfigurator(String key, String value, Map parentPropertyMap) { + super(key, value, parentPropertyMap); } @Override - protected Pattern initialPattern() { - return new Pattern("configuration"); + protected ElementPath initialElementPath() { + return new ElementPath("configuration"); } @Override protected void addInstanceRules(RuleStore rs) { - rs.addRule(new Pattern("configuration/appender"), new AppenderAction()); + rs.addRule(new ElementSelector("configuration/appender"), new AppenderAction()); } @Override @@ -54,6 +53,7 @@ public class SiftingJoranConfigurator extends omap.put(ActionConst.APPENDER_BAG, new HashMap()); omap.put(ActionConst.FILTER_CHAIN_BAG, new HashMap()); Map propertiesMap = new HashMap(); + propertiesMap.putAll(parentPropertyMap); propertiesMap.put(key, value); interpreter.setInterpretationContextPropertiesMap(propertiesMap); } diff --git a/logback-access/src/main/java/ch/qos/logback/access/spi/AccessContext.java b/logback-access/src/main/java/ch/qos/logback/access/spi/AccessContext.java index 716986dcf0b653b39377776ceff3d91ee02d8566..7445ad7224f9fb8771a98749b6dce973db2a4480 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/spi/AccessContext.java +++ b/logback-access/src/main/java/ch/qos/logback/access/spi/AccessContext.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java b/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java index d4779ab73f92e262c4dc4c6c0a07eb86c2709af6..3b53b516bf0ddf41bcc3d01cb68279c2bbfeea4f 100755 --- a/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java +++ b/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/spi/IAccessEvent.java b/logback-access/src/main/java/ch/qos/logback/access/spi/IAccessEvent.java index abfe06fdc2330a20c31c8580876219268bffa5d5..7837d1b8d017599ba96b54f3e357fefd210b7b9f 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/spi/IAccessEvent.java +++ b/logback-access/src/main/java/ch/qos/logback/access/spi/IAccessEvent.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/spi/ServerAdapter.java b/logback-access/src/main/java/ch/qos/logback/access/spi/ServerAdapter.java index 06b2653024fa2c5dcd0a32bfce4c47a43e129ae5..b28a5796d4cbd6d59bb25c7a93f66171885207f1 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/spi/ServerAdapter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/spi/ServerAdapter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/spi/Util.java b/logback-access/src/main/java/ch/qos/logback/access/spi/Util.java index f29036451617b420a8fa4d6a96c7d9795046ecf7..65c2ed824ba0546f64ae32e37db4e5bf42103746 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/spi/Util.java +++ b/logback-access/src/main/java/ch/qos/logback/access/spi/Util.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java b/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java index e5656b04002cf89d810c560b190627ea93a12701..f534959aa7a018d2751bef051cd78499803cd7e4 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java +++ b/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -19,14 +19,11 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.concurrent.*; +import java.util.concurrent.ExecutorService; import javax.servlet.ServletContext; import javax.servlet.ServletException; -import ch.qos.logback.access.spi.IAccessEvent; -//import org.apache.catalina.Lifecycle; -import ch.qos.logback.core.spi.*; import org.apache.catalina.Lifecycle; import org.apache.catalina.LifecycleException; import org.apache.catalina.LifecycleListener; @@ -38,17 +35,28 @@ import org.apache.catalina.valves.ValveBase; import ch.qos.logback.access.AccessConstants; import ch.qos.logback.access.joran.JoranConfigurator; import ch.qos.logback.access.spi.AccessEvent; +import ch.qos.logback.access.spi.IAccessEvent; import ch.qos.logback.core.Appender; import ch.qos.logback.core.BasicStatusManager; import ch.qos.logback.core.Context; import ch.qos.logback.core.CoreConstants; +import ch.qos.logback.core.LifeCycleManager; import ch.qos.logback.core.filter.Filter; import ch.qos.logback.core.joran.spi.JoranException; +import ch.qos.logback.core.spi.AppenderAttachable; +import ch.qos.logback.core.spi.AppenderAttachableImpl; +import ch.qos.logback.core.spi.FilterAttachable; +import ch.qos.logback.core.spi.FilterAttachableImpl; +import ch.qos.logback.core.spi.FilterReply; +import ch.qos.logback.core.spi.LifeCycle; +import ch.qos.logback.core.spi.LogbackLock; import ch.qos.logback.core.status.InfoStatus; import ch.qos.logback.core.status.StatusManager; import ch.qos.logback.core.status.WarnStatus; +import ch.qos.logback.core.util.ExecutorServiceUtil; import ch.qos.logback.core.util.OptionHelper; import ch.qos.logback.core.util.StatusPrinter; +//import org.apache.catalina.Lifecycle; /** * This class is an implementation of tomcat's Valve interface, by extending @@ -68,6 +76,8 @@ public class LogbackValve extends ValveBase implements Lifecycle, Context, public final static String DEFAULT_CONFIG_FILE = "conf" + File.separatorChar + "logback-access.xml"; + private final LifeCycleManager lifeCycleManager = new LifeCycleManager(); + private long birthTime = System.currentTimeMillis(); LogbackLock configurationLock = new LogbackLock(); @@ -87,10 +97,7 @@ public class LogbackValve extends ValveBase implements Lifecycle, Context, boolean started; boolean alreadySetLogbackStatusManager = false; - // 0 idle threads, 2 maximum threads, no idle waiting - ExecutorService executorService = new ThreadPoolExecutor(0, 2, - 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue()); + private ExecutorService executorService; public LogbackValve() { putObject(CoreConstants.EVALUATOR_MAP, new HashMap()); @@ -101,12 +108,23 @@ public class LogbackValve extends ValveBase implements Lifecycle, Context, } public void startInternal() throws LifecycleException { - System.out.println("***startInternal() called"); + executorService = ExecutorServiceUtil.newExecutorService(); if (filename == null) { - String tomcatHomeProperty = OptionHelper - .getSystemProperty("catalina.home"); - - filename = tomcatHomeProperty + File.separatorChar + DEFAULT_CONFIG_FILE; + String tomcatBaseProperty = OptionHelper + .getSystemProperty("catalina.base"); + + filename = tomcatBaseProperty + File.separatorChar + DEFAULT_CONFIG_FILE; + + File baseConfigFile = new File(filename); + if (!baseConfigFile.exists()) { + + String tomcatHomeProperty = OptionHelper + .getSystemProperty("catalina.home"); + + filename = tomcatHomeProperty + File.separatorChar + + DEFAULT_CONFIG_FILE; + } + getStatusManager().add( new InfoStatus("filename property not set. Assuming [" + filename + "]", this)); @@ -115,7 +133,6 @@ public class LogbackValve extends ValveBase implements Lifecycle, Context, if (configFile.exists()) { try { - System.out.println("***startInternal() JoranConfigurator"); JoranConfigurator jc = new JoranConfigurator(); jc.setContext(this); jc.doConfigure(filename); @@ -188,6 +205,11 @@ public class LogbackValve extends ValveBase implements Lifecycle, Context, protected void stopInternal() throws LifecycleException { started = false; setState(LifecycleState.STOPPING); + lifeCycleManager.reset(); + if (executorService != null) { + ExecutorServiceUtil.shutdown(executorService); + executorService = null; + } } public void addAppender(Appender newAppender) { @@ -292,6 +314,10 @@ public class LogbackValve extends ValveBase implements Lifecycle, Context, return configurationLock; } + public void register(LifeCycle component) { + lifeCycleManager.register(component); + } + // ====== Methods from catalina Lifecycle ===== public void addLifecycleListener(LifecycleListener arg0) { diff --git a/logback-access/src/main/java/ch/qos/logback/access/tomcat/TomcatServerAdapter.java b/logback-access/src/main/java/ch/qos/logback/access/tomcat/TomcatServerAdapter.java index fde500875f81ff828fd0155990592998052b6dd1..5e8cc1f184780a31210bc61c47412f042648ffcc 100644 --- a/logback-access/src/main/java/ch/qos/logback/access/tomcat/TomcatServerAdapter.java +++ b/logback-access/src/main/java/ch/qos/logback/access/tomcat/TomcatServerAdapter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/AllAccessTest.java b/logback-access/src/test/java/ch/qos/logback/access/AllAccessTest.java index b490949b97d233f0cab040d46d0d1295c96888f3..a66243752d3abac9ae06b8cc69f0a2afb32d2ec7 100755 --- a/logback-access/src/test/java/ch/qos/logback/access/AllAccessTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/AllAccessTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/TeztConstants.java b/logback-access/src/test/java/ch/qos/logback/access/TeztConstants.java index 6632f163414d6e2645f03891e81f48918dac3327..5340742b6e01ed53b7e86d3b4fb2f4c0835e2ea5 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/TeztConstants.java +++ b/logback-access/src/test/java/ch/qos/logback/access/TeztConstants.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/boolex/JaninoEventEvaluatorTest.java b/logback-access/src/test/java/ch/qos/logback/access/boolex/JaninoEventEvaluatorTest.java index daa18e78d12e3179c4a48416247f3dcb84e60e97..34d10017c4168ea5ae6e97609c42f7eef637d23f 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/boolex/JaninoEventEvaluatorTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/boolex/JaninoEventEvaluatorTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/boolex/PackageTest.java b/logback-access/src/test/java/ch/qos/logback/access/boolex/PackageTest.java index 9e615392a450e4148f2181f919930260fadbb22c..ed7e82f3dbe17dc454ade89c6465f0e22eab1881 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/boolex/PackageTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/boolex/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderHSQLTest.java b/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderHSQLTest.java index 6a5a3913bad68608cc6a8834667334498029b84d..013dcd7b2a9137be376b1c6950e191ab89fe93e5 100755 --- a/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderHSQLTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderHSQLTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -45,20 +45,20 @@ public class DBAppenderHSQLTest { DBAppender appender; DriverManagerConnectionSource connectionSource; - int existingRowCount; + int existingEventTableRowCount; Statement stmt; @BeforeClass static public void fixtureSetUp() throws SQLException { DB_APPENDER_HSQL_TEST_FIXTURE = new DBAppenderHSQLTestFixture(); DB_APPENDER_HSQL_TEST_FIXTURE.setUp(); - } - + } + @AfterClass - static public void fixtureTearDown() throws SQLException { + static public void fixtureTearDown() throws SQLException { DB_APPENDER_HSQL_TEST_FIXTURE.tearDown(); } - + @Before public void setUp() throws SQLException { context = new AccessContext(); @@ -76,7 +76,7 @@ public class DBAppenderHSQLTest { appender.setConnectionSource(connectionSource); stmt = connectionSource.getConnection().createStatement(); - existingRowCount = existingRowCount(stmt); + existingEventTableRowCount = existingEventTableRowCount(stmt); } @After @@ -87,7 +87,7 @@ public class DBAppenderHSQLTest { stmt.close(); } - int existingRowCount(Statement stmt) throws SQLException { + int existingEventTableRowCount(Statement stmt) throws SQLException { ResultSet rs = stmt.executeQuery("SELECT count(*) FROM access_event"); int result = -1; if (rs.next()) { @@ -109,10 +109,10 @@ public class DBAppenderHSQLTest { IAccessEvent event = createAccessEvent(); appender.append(event); - + Statement stmt = connectionSource.getConnection().createStatement(); ResultSet rs = null; - rs = stmt.executeQuery("SELECT * FROM access_event where EVENT_ID = "+ existingRowCount); + rs = stmt.executeQuery("SELECT * FROM access_event where EVENT_ID = " + existingEventTableRowCount); if (rs.next()) { assertEquals(event.getTimeStamp(), rs.getLong(1)); assertEquals(event.getRequestURI(), rs.getString(2)); @@ -130,33 +130,33 @@ public class DBAppenderHSQLTest { rs.close(); stmt.close(); } - - + + @Test public void testCheckNoHeadersAreInserted() throws Exception { setInsertHeadersAndStart(false); - + IAccessEvent event = createAccessEvent(); appender.append(event); StatusPrinter.print(context.getStatusManager()); - + //Check that no headers were inserted Statement stmt = connectionSource.getConnection().createStatement(); ResultSet rs = null; - rs = stmt.executeQuery("SELECT * FROM access_event_header"); - + rs = stmt.executeQuery("SELECT * FROM access_event_header where EVENT_ID = " + existingEventTableRowCount); + assertFalse(rs.next()); rs.close(); stmt.close(); } @Test - public void testAppendHeaders() throws SQLException { + public void testAppendHeaders() throws SQLException { setInsertHeadersAndStart(true); - + IAccessEvent event = createAccessEvent(); appender.append(event); - + Statement stmt = connectionSource.getConnection().createStatement(); ResultSet rs = null; rs = stmt.executeQuery("SELECT * FROM access_event_header"); @@ -195,10 +195,10 @@ public class DBAppenderHSQLTest { } StatusPrinter.print(context); - + Statement stmt = connectionSource.getConnection().createStatement(); ResultSet rs = null; - rs = stmt.executeQuery("SELECT * FROM access_event where requestURI='"+uri+"'"); + rs = stmt.executeQuery("SELECT * FROM access_event where requestURI='" + uri + "'"); int count = 0; while (rs.next()) { count++; @@ -210,9 +210,9 @@ public class DBAppenderHSQLTest { } private IAccessEvent createAccessEvent() { - return createAccessEvent(""); + return createAccessEvent(""); } - + private IAccessEvent createAccessEvent(String uri) { DummyRequest request = new DummyRequest(); request.setRequestUri(uri); diff --git a/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderHSQLTestFixture.java b/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderHSQLTestFixture.java index b70420a3ed4bb6d810e7700b2067faf8c8617111..7e8efa5e44a054eb57f4f9ae0f31e10a575cd005 100755 --- a/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderHSQLTestFixture.java +++ b/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderHSQLTestFixture.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderIntegrationTest.java b/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderIntegrationTest.java index ec7ca9675edd2a4ec8a02d0e6615405198464897..35614fb88021ef2c137e46e24a457a1ece333b23 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderIntegrationTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderIntegrationTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/db/PackageTest.java b/logback-access/src/test/java/ch/qos/logback/access/db/PackageTest.java index a38f5f86a5b329c35a087dc45cc55455362d6833..aa98437158ef6538e510b7d417cac88df8e8a5c2 100755 --- a/logback-access/src/test/java/ch/qos/logback/access/db/PackageTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/db/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,14 +13,11 @@ */ package ch.qos.logback.access.db; -import junit.framework.*; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; -public class PackageTest extends TestCase { +@RunWith(Suite.class) +@Suite.SuiteClasses({DBAppenderHSQLTest.class, DBAppenderIntegrationTest.class}) +public class PackageTest { - public static Test suite() { - TestSuite suite = new TestSuite(); - suite.addTest(new JUnit4TestAdapter(DBAppenderHSQLTest.class)); - suite.addTest(new JUnit4TestAdapter(DBAppenderIntegrationTest.class)); - return suite; - } } \ No newline at end of file diff --git a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyAccessEventBuilder.java b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyAccessEventBuilder.java index 7916b3cc169069aaaeaaae63f01d25a93e863692..7f537c739c5c30a348e332442543aa052c816cd8 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyAccessEventBuilder.java +++ b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyAccessEventBuilder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyRequest.java b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyRequest.java index db3d9f277a2609bedfafec49b0808f7e14db1616..360fb923c56f8aea22153bf37f431807a1b90428 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyRequest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyRequest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyResponse.java b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyResponse.java index 2281eec7be37bbbc886ac304a461a94c2511d2ba..ef0a28418f246b760afaeab5f36794b304015eec 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyResponse.java +++ b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyResponse.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyServerAdapter.java b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyServerAdapter.java index 4053fbde3346cd187ef1aba9ed10f9f902c1177a..886cce6bb174dbd958fff9ca6d725a90c4df68ab 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyServerAdapter.java +++ b/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyServerAdapter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/filter/PackageTest.java b/logback-access/src/test/java/ch/qos/logback/access/filter/PackageTest.java index c48fbe26603c49c5187447021f3ec3523d4dff24..174916bcf3980aca4f5badd391e18417a9b4987b 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/filter/PackageTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/filter/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/filter/StatsByDayTest.java b/logback-access/src/test/java/ch/qos/logback/access/filter/StatsByDayTest.java index 5420d780021581275f5c6bbbc1e9748d36a93fe8..e2b92f03260ef47d5e798fcb91bad01400a07385 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/filter/StatsByDayTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/filter/StatsByDayTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java b/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java index b6a9d5845fb5eea8090ce2c36c89ad3f0a8fec90..744712dcf34a2706ca869e1609a4b18ac8a0ec7b 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureBase.java b/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureBase.java index e4279cbe13fbc0cb4c258789e7b7e598609b572e..21eb7b563ed1bb03453b71f73ce0b8353d53cf2e 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureBase.java +++ b/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureWithListAndConsoleAppenders.java b/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureWithListAndConsoleAppenders.java index 9f40a10f84aea6be2f286545c1828387b2d0cf4d..bf04d51f24d55797282075dc919a160336fb1844 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureWithListAndConsoleAppenders.java +++ b/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyFixtureWithListAndConsoleAppenders.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/jetty/PackageTest.java b/logback-access/src/test/java/ch/qos/logback/access/jetty/PackageTest.java index aa9f33f5a664d28bd4b0d13070a9443a828add7d..c9ea6d5e762cdc23001c31dd85525873b2dffa00 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/jetty/PackageTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/jetty/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/joran/ConditionalTest.java b/logback-access/src/test/java/ch/qos/logback/access/joran/ConditionalTest.java index 9ab337ac0e082c358e499be714768faf92eafbeb..2d7dee1d158ee7b48981bde919c9271918a33c2e 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/joran/ConditionalTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/joran/ConditionalTest.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.access.joran; import ch.qos.logback.access.TeztConstants; diff --git a/logback-access/src/test/java/ch/qos/logback/access/joran/JoranConfiguratorTest.java b/logback-access/src/test/java/ch/qos/logback/access/joran/JoranConfiguratorTest.java index 7d0b5ad0054bdf640eb7816de23575b8372c16da..e7bce84c819b10e51eebbe380f4ca7e4dc4bb0e9 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/joran/JoranConfiguratorTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/joran/JoranConfiguratorTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/joran/PackageTest.java b/logback-access/src/test/java/ch/qos/logback/access/joran/PackageTest.java index b79b7cacf724a540e2d16edf247acd40f897df61..229e44e1291756a4c7e871cc077befee2b86f77d 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/joran/PackageTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/joran/PackageTest.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.access.joran; import org.junit.runner.RunWith; diff --git a/logback-access/src/test/java/ch/qos/logback/access/net/MockSocketServer.java b/logback-access/src/test/java/ch/qos/logback/access/net/MockSocketServer.java deleted file mode 100644 index 10b4e00424892413318f0b401a86e7d341459493..0000000000000000000000000000000000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/net/MockSocketServer.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.net; - -import java.io.BufferedInputStream; -import java.io.ObjectInputStream; -import java.net.ServerSocket; -import java.net.Socket; -import java.util.ArrayList; -import java.util.List; - -//import ch.qos.logback.access.spi.AccessEvent; -import ch.qos.logback.access.spi.IAccessEvent; - - -/** - * @author Sébastien Pennec - */ -public class MockSocketServer extends Thread { - - static final int PORT = 4560; - - final int loopLen; - - List accessEventList = new ArrayList(); - boolean finished = false; - - MockSocketServer(int loopLen) { - super(); - this.loopLen = loopLen; - } - - @Override - public void run() { - ObjectInputStream ois = null; - ServerSocket serverSocket = null; - // Object readObject; - try { - serverSocket = new ServerSocket(PORT); - Socket socket = serverSocket.accept(); - ois = new ObjectInputStream(new BufferedInputStream(socket - .getInputStream())); - for (int i = 0; i < loopLen; i++) { - IAccessEvent event = (IAccessEvent) ois.readObject(); - accessEventList.add(event); - } - } catch (Exception se) { - se.printStackTrace(); - } finally { - - if (ois != null) { - try { - ois.close(); - } catch (Exception e) { - } - } - if (serverSocket != null) { - try { - serverSocket.close(); - } catch (Exception e) { - } - } - } - finished = true; - } -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/net/NOPOutputStream.java b/logback-access/src/test/java/ch/qos/logback/access/net/NOPOutputStream.java index 96127e1f606e1f39a86719abde2f62329bd44946..261177d1b7b952796330e271be45afecba1b24da 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/net/NOPOutputStream.java +++ b/logback-access/src/test/java/ch/qos/logback/access/net/NOPOutputStream.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/net/PackageTest.java b/logback-access/src/test/java/ch/qos/logback/access/net/PackageTest.java index 2a4d88d4aa61c34235df4c60505b3236d0b1e031..786063616e90eca518138bc369a8f5b99daa8b7e 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/net/PackageTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/net/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -20,6 +20,6 @@ import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) -@SuiteClasses({URLEvaluatorTest.class, SocketAppenderTest.class}) +@SuiteClasses({URLEvaluatorTest.class}) public class PackageTest extends TestCase { } \ No newline at end of file diff --git a/logback-access/src/test/java/ch/qos/logback/access/net/SerializationPerfTest.java b/logback-access/src/test/java/ch/qos/logback/access/net/SerializationPerfTest.java index dcc82b5f4cb8baec1aab987b60f4b08f735d9efc..318a14f8f8bf67521abfafb086bd6e59bba7e1bc 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/net/SerializationPerfTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/net/SerializationPerfTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/net/SocketAppenderTest.java b/logback-access/src/test/java/ch/qos/logback/access/net/SocketAppenderTest.java deleted file mode 100644 index 0b6981a3d993b02c6a57e42909a666434b63e6f9..0000000000000000000000000000000000000000 --- a/logback-access/src/test/java/ch/qos/logback/access/net/SocketAppenderTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.access.net; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import ch.qos.logback.access.spi.IAccessEvent; -import org.junit.Test; - -import ch.qos.logback.access.dummy.DummyRequest; -import ch.qos.logback.access.dummy.DummyResponse; -import ch.qos.logback.access.dummy.DummyServerAdapter; -import ch.qos.logback.access.spi.AccessContext; -import ch.qos.logback.access.spi.AccessEvent; - - -public class SocketAppenderTest { - - private AccessContext context; - private MockSocketServer mockSocketServer; - - @Test - public void testStartFailNoRemoteHost() { - context = new AccessContext(); - SocketAppender appender = new SocketAppender(); - appender.setContext(context); - appender.setPort(123); - appender.start(); - assertEquals(1, context.getStatusManager().getCount()); - } - - @Test - public void testRecieveMessage() throws InterruptedException { - startServer(1); - configureClient(); - - context.callAppenders(buildNewAccessEvent()); - // Wait max 2 seconds for mock server to finish. However, it should - // finish much sooner than that. - mockSocketServer.join(2000); - assertTrue(mockSocketServer.finished); - assertEquals(1, mockSocketServer.accessEventList.size()); - - IAccessEvent remoteEvent = mockSocketServer.accessEventList.get(0); - //check that the values are available although the request and response - //objects did not survive serialization - assertEquals("headerValue1", remoteEvent.getRequestHeader("headerName1")); - assertEquals("testHost", remoteEvent.getRemoteHost()); - } - - private void startServer(int expectedEventNumber) throws InterruptedException { - mockSocketServer = new MockSocketServer(expectedEventNumber); - mockSocketServer.start(); - // give MockSocketServer head start - Thread.sleep(100); - } - - private void configureClient() { - context = new AccessContext(); - context.setName("test"); - SocketAppender socketAppender = new SocketAppender(); - socketAppender.setContext(context); - socketAppender.setName("socket"); - socketAppender.setPort(MockSocketServer.PORT); - socketAppender.setRemoteHost("localhost"); - context.addAppender(socketAppender); - socketAppender.start(); - } - - private IAccessEvent buildNewAccessEvent() { - DummyRequest request = new DummyRequest(); - DummyResponse response = new DummyResponse(); - DummyServerAdapter adapter = new DummyServerAdapter(request, response); - - return new AccessEvent(request, response, adapter); - } -} diff --git a/logback-access/src/test/java/ch/qos/logback/access/net/URLEvaluatorTest.java b/logback-access/src/test/java/ch/qos/logback/access/net/URLEvaluatorTest.java index 86b47e729ca89f47f7dc5ae1c714782154a99cd3..e56ab635f3c8e7cfa3030114abcf6243182708b7 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/net/URLEvaluatorTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/net/URLEvaluatorTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/pattern/ConverterTest.java b/logback-access/src/test/java/ch/qos/logback/access/pattern/ConverterTest.java index 812c517523f88a988413353527bd7733e14b56be..39bfb7e5ae3d17a6812ea59cb37a50af7ea980a4 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/pattern/ConverterTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/pattern/ConverterTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/pattern/PackageTest.java b/logback-access/src/test/java/ch/qos/logback/access/pattern/PackageTest.java index 5e5ad14c36ac0b0e6fba2b5fdf856c599dcbca0f..710ce09cb478516680704a7cfc7acb4cba4735e6 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/pattern/PackageTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/pattern/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/servlet/PackageTest.java b/logback-access/src/test/java/ch/qos/logback/access/servlet/PackageTest.java index 0bf8aa8db5177902d49156226f5fc7615aaf3cc1..7e3aa72104d7a97e98757b3d70e7c6bc8e6a0a98 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/servlet/PackageTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/servlet/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/servlet/TeeFilterTest.java b/logback-access/src/test/java/ch/qos/logback/access/servlet/TeeFilterTest.java index 5e62088b323deb8db829cf03707adf8abb44cb51..045905db7ee1d6ac50e89b05b71ccbcb93d9127a 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/servlet/TeeFilterTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/servlet/TeeFilterTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/sift/PackageTest.java b/logback-access/src/test/java/ch/qos/logback/access/sift/PackageTest.java index fb04885f5d8aca540a052f5abee1464369f6d360..5e7d738ffff2812ae57c4933db78556b59accf3f 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/sift/PackageTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/sift/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/sift/SiftingAppenderTest.java b/logback-access/src/test/java/ch/qos/logback/access/sift/SiftingAppenderTest.java index 7e7231d6a41734c4fd0a2b83c3e8f08fa1e40b26..141a331aaff756cd75b70b6611087df921210e22 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/sift/SiftingAppenderTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/sift/SiftingAppenderTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -17,8 +17,8 @@ import static org.junit.Assert.assertEquals; import java.net.HttpURLConnection; import java.net.URL; -import java.util.ArrayList; -import java.util.List; +import java.util.LinkedHashSet; +import java.util.Set; import ch.qos.logback.access.jetty.JettyFixtureBase; import org.junit.After; @@ -55,33 +55,31 @@ public class SiftingAppenderTest { public void invokingDifferentPathShouldBeSiftedAccordingly() throws Exception { rli.setFileName(PREFIX + "sifting.xml"); jettyFixture.start(); - StatusPrinter.print(rli); invokeServer("/"); invokeServer("/x"); invokeServer("/x"); invokeServer("/y"); + StatusPrinter.print(rli); SiftingAppender siftingAppender = (SiftingAppender) rli .getAppender("SIFTING"); - List keyList = siftingAppender.getAppenderTracker().keyList(); - assertEquals(3, keyList.size()); - - List witnessList = new ArrayList(); - witnessList.add("NA"); - witnessList.add("x"); - witnessList.add("y"); - assertEquals(witnessList, keyList); + Set keySet = siftingAppender.getAppenderTracker().allKeys(); + assertEquals(3, keySet.size()); - long now = System.currentTimeMillis(); - check(siftingAppender, "NA", 1, now); - check(siftingAppender, "x", 2, now); - check(siftingAppender, "y", 1, now); + Set witnessSet = new LinkedHashSet(); + witnessSet.add("NA"); + witnessSet.add("x"); + witnessSet.add("y"); + assertEquals(witnessSet, keySet); + check(siftingAppender, "NA", 1); + check(siftingAppender, "x", 2); + check(siftingAppender, "y", 1); } - private void check(SiftingAppender siftingAppender, String key, int expectedCount, long now) { + private void check(SiftingAppender siftingAppender, String key, int expectedCount) { ListAppender listAppender = (ListAppender) siftingAppender - .getAppenderTracker().get(key, now); + .getAppenderTracker().find(key); assertEquals(expectedCount, listAppender.list.size()); } diff --git a/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventSerializationTest.java b/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventSerializationTest.java index 821eab0221dcc9557adf7781da51cf7bd7dbad13..0c36ef18d550a71008d524e7faa981171c1c8d17 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventSerializationTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventSerializationTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/spi/PackageTest.java b/logback-access/src/test/java/ch/qos/logback/access/spi/PackageTest.java index b0d162ad80ac9f169a67ee1c4c9052118a10c4ad..4d6744710756223debed9fb5c416efae0c406b1b 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/spi/PackageTest.java +++ b/logback-access/src/test/java/ch/qos/logback/access/spi/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-access/src/test/java/ch/qos/logback/access/testUtil/NotifyingListAppender.java b/logback-access/src/test/java/ch/qos/logback/access/testUtil/NotifyingListAppender.java index c87a73a9a05a168a1d7f1c827835491112a40368..7e747482ae59ca81570a6e69a8d7df97a2cfa1e3 100644 --- a/logback-access/src/test/java/ch/qos/logback/access/testUtil/NotifyingListAppender.java +++ b/logback-access/src/test/java/ch/qos/logback/access/testUtil/NotifyingListAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/pom.xml b/logback-classic/pom.xml index 9b12ee3c66ef793b2623181fc10181ac1091bd8b..fee588cdb4ce10f78d87dd818acef2ef2d3d7b2a 100755 --- a/logback-classic/pom.xml +++ b/logback-classic/pom.xml @@ -7,7 +7,7 @@ ch.qos.logback logback-parent - 1.0.12-SNAPSHOT + 2.0.0-SNAPSHOT logback-classic @@ -196,15 +196,6 @@ - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - org.codehaus.gmaven gmaven-plugin @@ -235,6 +226,7 @@ org.apache.maven.plugins maven-jar-plugin + ${maven-jar-plugin.version} @@ -308,10 +300,11 @@ org.apache.maven.plugins maven-surefire-plugin - ${surefire.version} + ${maven-surefire-plugin.version} once + plain false diff --git a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ComponentDelegate.groovy b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ComponentDelegate.groovy index 6cfdf387566e36ca30cce20f5065c8cee66c58f9..98edd5e78cbe4301c99593e14461d3d32522a619 100644 --- a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ComponentDelegate.groovy +++ b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ComponentDelegate.groovy @@ -25,7 +25,7 @@ class ComponentDelegate extends ContextAwareBase { final Object component; - final List fieldsToCaccade = []; + final List fieldsToCascade = []; ComponentDelegate(Object component) { this.component = component; @@ -74,7 +74,7 @@ class ComponentDelegate extends ContextAwareBase { } void cascadeFields(ComponentDelegate subDelegate) { - for (String k: fieldsToCaccade) { + for (String k: fieldsToCascade) { subDelegate.metaClass."${k}" = this."${k}" } } diff --git a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy index a9a5f4a278b6a06a086aadc8fdbe6d172f79324e..8149979c3f34f5d1b05fc2370c1ebe12be70df63 100644 --- a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy +++ b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy @@ -19,6 +19,7 @@ import ch.qos.logback.classic.Logger import ch.qos.logback.classic.LoggerContext import ch.qos.logback.classic.jmx.JMXConfigurator import ch.qos.logback.classic.jmx.MBeanUtil +import ch.qos.logback.classic.net.ReceiverBase import ch.qos.logback.classic.turbo.ReconfigureOnChangeFilter import ch.qos.logback.classic.turbo.TurboFilter import ch.qos.logback.core.Appender @@ -146,6 +147,24 @@ public class ConfigurationDelegate extends ContextAwareBase { } } + void receiver(String name, Class aClass, Closure closure = null) { + addInfo("About to instantiate receiver of type [" + clazz.name + "]"); + ReceiverBase receiver = aClass.newInstance(); + receiver.context = context; + if(closure != null) { + ComponentDelegate componentDelegate = new ComponentDelegate(receiver); + componentDelegate.context = context; + closure.delegate = componentDelegate; + closure.resolveStrategy = Closure.DELEGATE_FIRST + closure(); + } + try { + receiver.start() + } catch (RuntimeException e) { + addError("Failed to start receiver of type [" + aClass.getName() + "]", e) + } + } + private void copyContributions(AppenderDelegate appenderDelegate, Appender appender) { if (appender instanceof ConfigurationContributor) { ConfigurationContributor cc = (ConfigurationContributor) appender; diff --git a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/GafferConfigurator.groovy b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/GafferConfigurator.groovy index 7e50db6aedb276b53350baf22fd593a4579ad598..fc55b3bbf775bf8c759c5c95cd480de1c0b37323 100644 --- a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/GafferConfigurator.groovy +++ b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/GafferConfigurator.groovy @@ -67,12 +67,13 @@ class GafferConfigurator { protected ImportCustomizer importCustomizer() { def customizer = new ImportCustomizer() - customizer.addImports(PatternLayoutEncoder.class.name, SiftingAppender.class.name) def core = 'ch.qos.logback.core' customizer.addStarImports(core, "${core}.encoder", "${core}.read", "${core}.rolling", "${core}.status", "ch.qos.logback.classic.net") + customizer.addImports(PatternLayoutEncoder.class.name) + customizer.addStaticStars(Level.class.name) customizer.addStaticImport('off', Level.class.name, 'OFF') diff --git a/logback-classic/src/main/groovy/ch/qos/logback/classic/sift/GSiftingAppender.groovy b/logback-classic/src/main/groovy/ch/qos/logback/classic/sift/GSiftingAppender.groovy deleted file mode 100644 index 58c0b7d432e1a43485df8f1b7ae1fd3e88093dd0..0000000000000000000000000000000000000000 --- a/logback-classic/src/main/groovy/ch/qos/logback/classic/sift/GSiftingAppender.groovy +++ /dev/null @@ -1,154 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2010, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.classic.sift - -import ch.qos.logback.core.AppenderBase -import ch.qos.logback.classic.spi.ILoggingEvent -import ch.qos.logback.core.sift.AppenderTrackerImpl -import ch.qos.logback.core.sift.Discriminator -import ch.qos.logback.core.sift.AppenderTracker -import ch.qos.logback.core.Appender - -import ch.qos.logback.classic.gaffer.ConfigurationContributor -import ch.qos.logback.core.CoreConstants -import ch.qos.logback.core.helpers.NOPAppender - -/** - * @author Ceki Gücü - */ - -// The GMaven plugin does not support generics, so we use AppenderBase instead of AppenderBase -class GSiftingAppender extends AppenderBase implements ConfigurationContributor { - - - protected AppenderTracker appenderTracker = new AppenderTrackerImpl(); - Discriminator discriminator; - Closure builderClosure; - - def Map getMappings() { - return [sift: "sift"] - } - - @Override - public void start() { - int errors = 0; - if (discriminator == null) { - addError("Missing discriminator. Aborting"); - errors++; - } - if (!discriminator?.isStarted()) { - addError("Discriminator has not started successfully. Aborting"); - errors++; - } - - if (builderClosure == null) { - addError("Missing builder closure. Aborting"); - errors++; - } - if (errors == 0) { - super.start(); - } - } - - @Override - public void stop() { - for (Appender appender: appenderTracker.valueList()) { - appender.stop(); - } - } - - protected long getTimestamp(ILoggingEvent event) { - return event.getTimeStamp(); - } - - Appender buildAppender(String value) { - String key = getDiscriminatorKey() - - ZSiftingDelegate zd = new ZSiftingDelegate(getDiscriminatorKey(), value) - zd.context = context - zd.metaClass."$key" = value - - //Closure newBuilder = builderClosure.clone() - builderClosure.delegate = zd; - builderClosure.resolveStrategy = Closure.DELEGATE_FIRST - Appender a = builderClosure() - return a - } - - @Override - public void append(Object object) { - ILoggingEvent event = (ILoggingEvent) object; - if (!isStarted()) { - return; - } - - String discriminatingValue = discriminator.getDiscriminatingValue(event); - long timestamp = getTimestamp(event); - - Appender appender = appenderTracker.get(discriminatingValue, timestamp); - if (appender == null) { - try { - appender = buildAppender(discriminatingValue); - if (appender == null) { - appender = buildNOPAppender(discriminatingValue); - } - appenderTracker.put(discriminatingValue, appender, timestamp); - - } catch (Throwable e) { - addError("Failed to build appender for [" + discriminatingValue + "]", - e); - return; - } - } - appenderTracker.stopStaleAppenders(timestamp); - - appender.doAppend(event); - } - - int nopaWarningCount = 0; - - NOPAppender buildNOPAppender(String discriminatingValue) { - if (nopaWarningCount < CoreConstants.MAX_ERROR_COUNT) { - nopaWarningCount++; - addError("Failed to build an appender for discriminating value [" + discriminatingValue + "]"); - } - NOPAppender nopa = new NOPAppender(); - nopa.setContext(context); - nopa.start(); - return nopa; - } - - void build() { - int r = builderClosure(); - println "r=$r" - - } - - void sift(Closure clo) { - builderClosure = clo; - } - - - public AppenderTracker getAppenderTracker() { - return appenderTracker; - } - - public String getDiscriminatorKey() { - if (discriminator != null) { - return discriminator.getKey(); - } else { - return null; - } - } -} diff --git a/logback-classic/src/main/groovy/ch/qos/logback/classic/sift/ZSiftingDelegate.groovy b/logback-classic/src/main/groovy/ch/qos/logback/classic/sift/ZSiftingDelegate.groovy deleted file mode 100644 index 8218e58a3d702faa2e98fdc68f8b559884d15dcd..0000000000000000000000000000000000000000 --- a/logback-classic/src/main/groovy/ch/qos/logback/classic/sift/ZSiftingDelegate.groovy +++ /dev/null @@ -1,39 +0,0 @@ -package ch.qos.logback.classic.sift - -import ch.qos.logback.core.spi.ContextAwareBase -import ch.qos.logback.core.Appender -import ch.qos.logback.classic.gaffer.AppenderDelegate -import ch.qos.logback.core.util.StatusPrinter - -/** - * @author Ceki Gücü - */ -class ZSiftingDelegate extends ContextAwareBase { - - String key - String value - - ZSiftingDelegate(String key, String value) { - this.key = key - this.value = value - } - - Appender appender(String name, Class clazz, Closure closure = null) { - addInfo("About to instantiate appender of type [" + clazz.name + "]"); - Appender appender = clazz.newInstance(); - addInfo("Naming appender as [" + name + "]"); - appender.name = name - appender.context = context - if (closure != null) { - AppenderDelegate ad = new AppenderDelegate(appender); - ad.metaClass."${key}" = value - ad.fieldsToCaccade << "${key}" - ad.context = context; - closure.delegate = ad; - closure.resolveStrategy = Closure.DELEGATE_FIRST - closure(); - } - appender.start(); - return appender; - } -} diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/AsyncAppender.java b/logback-classic/src/main/java/ch/qos/logback/classic/AsyncAppender.java index 2e0925545f8e9435bc491e7eef2ca32154e2a184..bee7299e576b2c912c20e9e46623afee0517551e 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/AsyncAppender.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/AsyncAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/BasicConfigurator.java b/logback-classic/src/main/java/ch/qos/logback/classic/BasicConfigurator.java index 8c8de836b83562432a3c2ede2bc2d0eeed6e0e01..93bfe3dd72159a3cb6207e3a908ba91b2323b7d0 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/BasicConfigurator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/BasicConfigurator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/ClassicConstants.java b/logback-classic/src/main/java/ch/qos/logback/classic/ClassicConstants.java index 46e17fa71e46447a076e00fc25f31fb9b7e3e470..f673736e73ce274516b3952785eed7259c9a2033 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/ClassicConstants.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/ClassicConstants.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -45,5 +45,6 @@ public class ClassicConstants { public static final String GAFFER_CONFIGURATOR_FQCN = "ch.qos.logback.classic.gaffer.GafferConfigurator"; - public static final Marker FINALIZE_SESSION_MARKER = MarkerFactory.getMarker("FINALIZE_SESSION"); + public static final String FINALIZE_SESSION = "FINALIZE_SESSION"; + public static final Marker FINALIZE_SESSION_MARKER = MarkerFactory.getMarker(FINALIZE_SESSION); } diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/Level.java b/logback-classic/src/main/java/ch/qos/logback/classic/Level.java index a6b92ad87742bc0c406735cf3c885e34b005e61e..bc43baabee4d80056eccc78cb5adeb1d267c4b79 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/Level.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/Level.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java b/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java index 1fdb1da526453b2b86241884960a57153b2a7912..3b594f3a0e18aab883a70b6104f65717534ca635 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java b/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java index b9cb22b822420a615ecd76a7025e8d43aaeb14fb..0ee60ea718a62272d7c72b3c0ef169a1116e397f 100755 --- a/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -58,8 +58,6 @@ public class LoggerContext extends ContextBase implements ILoggerFactory, private int maxCallerDataDepth = ClassicConstants.DEFAULT_MAX_CALLEDER_DATA_DEPTH; - boolean started = false; - int resetCount = 0; private List frameworkPackages; @@ -235,7 +233,7 @@ public class LoggerContext extends ContextBase implements ILoggerFactory, } /** - * First stop all registered turbo filters and then clear the registration + * First processPriorToRemoval all registered turbo filters and then clear the registration * list. */ public void resetTurboFilterList() { @@ -329,12 +327,8 @@ public class LoggerContext extends ContextBase implements ILoggerFactory, // === end listeners ============================================== - public boolean isStarted() { - return started; - } - public void start() { - started = true; + super.start(); fireOnStart(); } @@ -342,7 +336,7 @@ public class LoggerContext extends ContextBase implements ILoggerFactory, reset(); fireOnStop(); resetAllListeners(); - started = false; + super.stop(); } @Override diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/PatternLayout.java b/logback-classic/src/main/java/ch/qos/logback/classic/PatternLayout.java index 2185dd492189fb2f97cd1fef3a47bf2fcac9661c..17b184a0c2d979871123dc777a29790edc83fb7a 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/PatternLayout.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/PatternLayout.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -16,27 +16,7 @@ package ch.qos.logback.classic; import java.util.HashMap; import java.util.Map; -import ch.qos.logback.classic.pattern.CallerDataConverter; -import ch.qos.logback.classic.pattern.ClassOfCallerConverter; -import ch.qos.logback.classic.pattern.ContextNameConverter; -import ch.qos.logback.classic.pattern.PropertyConverter; -import ch.qos.logback.classic.pattern.DateConverter; -import ch.qos.logback.classic.pattern.EnsureExceptionHandling; -import ch.qos.logback.classic.pattern.ExtendedThrowableProxyConverter; -import ch.qos.logback.classic.pattern.FileOfCallerConverter; -import ch.qos.logback.classic.pattern.LevelConverter; -import ch.qos.logback.classic.pattern.LineOfCallerConverter; -import ch.qos.logback.classic.pattern.LineSeparatorConverter; -import ch.qos.logback.classic.pattern.LoggerConverter; -import ch.qos.logback.classic.pattern.MDCConverter; -import ch.qos.logback.classic.pattern.MarkerConverter; -import ch.qos.logback.classic.pattern.MessageConverter; -import ch.qos.logback.classic.pattern.MethodOfCallerConverter; -import ch.qos.logback.classic.pattern.NopThrowableInformationConverter; -import ch.qos.logback.classic.pattern.RelativeTimeConverter; -import ch.qos.logback.classic.pattern.RootCauseFirstThrowableProxyConverter; -import ch.qos.logback.classic.pattern.ThreadConverter; -import ch.qos.logback.classic.pattern.ThrowableProxyConverter; +import ch.qos.logback.classic.pattern.*; import ch.qos.logback.classic.pattern.color.HighlightingCompositeConverter; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.CoreConstants; @@ -149,6 +129,7 @@ public class PatternLayout extends PatternLayoutBase { defaultConverterMap.put("boldWhite", BoldWhiteCompositeConverter.class.getName()); defaultConverterMap.put("highlight", HighlightingCompositeConverter.class.getName()); + defaultConverterMap.put("lsn", LocalSequenceNumberConverter.class.getName()); } diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/ViewStatusMessagesServlet.java b/logback-classic/src/main/java/ch/qos/logback/classic/ViewStatusMessagesServlet.java index b040c1b724f90d625dbdaf09822060b8f48c328f..fb371952edfe2ee4092c74a4871c09eea84cc195 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/ViewStatusMessagesServlet.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/ViewStatusMessagesServlet.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/boolex/GEventEvaluator.java b/logback-classic/src/main/java/ch/qos/logback/classic/boolex/GEventEvaluator.java index 0fd8b4874372ecf1d74eef1c8202890f7307bdcd..c6e5ee6dcd3a80ea0f7e291f28026ceb10436107 100755 --- a/logback-classic/src/main/java/ch/qos/logback/classic/boolex/GEventEvaluator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/boolex/GEventEvaluator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/boolex/IEvaluator.java b/logback-classic/src/main/java/ch/qos/logback/classic/boolex/IEvaluator.java index e20659ed5c7fe3430ef966f7bba88cc7062f461b..68ba82432407e39330f84895b828b6519cac3e0d 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/boolex/IEvaluator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/boolex/IEvaluator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/boolex/JaninoEventEvaluator.java b/logback-classic/src/main/java/ch/qos/logback/classic/boolex/JaninoEventEvaluator.java index af911a0cdfbc5296d38c40ec3db5560ecab41f79..2c6c6270f75f0caab1b5b31c73610969920ecff1 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/boolex/JaninoEventEvaluator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/boolex/JaninoEventEvaluator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/boolex/OnErrorEvaluator.java b/logback-classic/src/main/java/ch/qos/logback/classic/boolex/OnErrorEvaluator.java index 5e557a4e637038af8026b2f52b564022071fe946..80baf5b8d3a19fc878c5013171a9e4508a2e63ca 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/boolex/OnErrorEvaluator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/boolex/OnErrorEvaluator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/boolex/OnMarkerEvaluator.java b/logback-classic/src/main/java/ch/qos/logback/classic/boolex/OnMarkerEvaluator.java index c1cdd572f114d65199b1666e627b8e45528b722c..b600340eb74bbbfa91c57d74770a235466b7cab4 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/boolex/OnMarkerEvaluator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/boolex/OnMarkerEvaluator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/DBAppender.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/DBAppender.java index 283c7136129e9a0fde38a3c8a70e854e63b385d3..ca31bbe1e72461bf02110933ae43c9cf502c4142 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/db/DBAppender.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/DBAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -27,7 +27,6 @@ import ch.qos.logback.classic.db.names.DefaultDBNameResolver; import ch.qos.logback.classic.spi.*; import ch.qos.logback.core.CoreConstants; import ch.qos.logback.core.db.DBAppenderBase; -import static ch.qos.logback.core.CoreConstants.EMPTY_STRING; /** * The DBAppender inserts logging events into three database tables in a format @@ -163,14 +162,23 @@ public class DBAppender extends DBAppenderBase { void bindCallerDataWithPreparedStatement(PreparedStatement stmt, StackTraceElement[] callerDataArray) throws SQLException { - StackTraceElement callerData = EMPTY_CALLER_DATA; - if(callerDataArray != null && callerDataArray[0] != null) - callerData = callerDataArray[0]; + StackTraceElement caller = extractFirstCaller(callerDataArray); - stmt.setString(CALLER_FILENAME_INDEX, callerData.getFileName()); - stmt.setString(CALLER_CLASS_INDEX, callerData.getClassName()); - stmt.setString(CALLER_METHOD_INDEX, callerData.getMethodName()); - stmt.setString(CALLER_LINE_INDEX, Integer.toString(callerData.getLineNumber())); + stmt.setString(CALLER_FILENAME_INDEX, caller.getFileName()); + stmt.setString(CALLER_CLASS_INDEX, caller.getClassName()); + stmt.setString(CALLER_METHOD_INDEX, caller.getMethodName()); + stmt.setString(CALLER_LINE_INDEX, Integer.toString(caller.getLineNumber())); + } + + private StackTraceElement extractFirstCaller(StackTraceElement[] callerDataArray) { + StackTraceElement caller = EMPTY_CALLER_DATA; + if(hasAtLeastOneNonNullElement(callerDataArray)) + caller = callerDataArray[0]; + return caller; + } + + private boolean hasAtLeastOneNonNullElement(StackTraceElement[] callerDataArray) { + return callerDataArray != null && callerDataArray.length > 0 && callerDataArray[0] != null; } Map mergePropertyMaps(ILoggingEvent event) { diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/DBHelper.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/DBHelper.java index 7a3260747c5ae0878302721e0db2dac9689f6bf8..50bdfa679a706f7651b7e41c719b09a92abf625a 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/db/DBHelper.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/DBHelper.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/SQLBuilder.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/SQLBuilder.java index 2d3c36253cf3fc718b11d8dab24b51316fa26e03..195ae0487eb09ec63e66648452d2496425d286c9 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/db/SQLBuilder.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/SQLBuilder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/ColumnName.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/ColumnName.java index 9c01775c4d4c34323ea199e0a07b324ffbf920f3..e03e429057b2d71a3eb452ba4ca7ddb759ce4ff8 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/ColumnName.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/ColumnName.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DBNameResolver.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DBNameResolver.java index cf69ff85d09f20d1ecd0fb390b0ff452dc54e6ad..d42a79402f70edfc3dc260c8ac68475cf4df78c4 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DBNameResolver.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DBNameResolver.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DefaultDBNameResolver.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DefaultDBNameResolver.java index 992844b9638d39c87ff95f707c00f0455b4cbfbd..3946509471df016206abfbeb8a6ad0716f0e9c91 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DefaultDBNameResolver.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DefaultDBNameResolver.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/SimpleDBNameResolver.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/SimpleDBNameResolver.java index dd23aa283f7709d9aed93ba28741c01d47b0ba2f..ce28d84b7050fe79b5979608bffbc5903d634679 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/SimpleDBNameResolver.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/SimpleDBNameResolver.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/TableName.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/TableName.java index 0605317bfdab177fc10b457bfdc3f00d2796f08a..bfbe286945113d1b4416ea6b573facc43ddab741 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/TableName.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/TableName.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/encoder/PatternLayoutEncoder.java b/logback-classic/src/main/java/ch/qos/logback/classic/encoder/PatternLayoutEncoder.java index 9e9782ea29a2cfb1058f0fb18f7216805052d5e9..6ac1600d694ad94172472ea2d0002527d6ef8578 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/encoder/PatternLayoutEncoder.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/encoder/PatternLayoutEncoder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/filter/LevelFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/filter/LevelFilter.java index d5d4ea373904811c7f30600995d543f759d86bd2..9a3537c0dbdbb93661c5cda07dbe1426ce8ce8e2 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/filter/LevelFilter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/filter/LevelFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/filter/ThresholdFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/filter/ThresholdFilter.java index 953844fd5b0e674615ac785044e7591131b134c4..33117ab1f2070efc0a3760ee69fdfe7a078e6321 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/filter/ThresholdFilter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/filter/ThresholdFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/gaffer/GafferUtil.java b/logback-classic/src/main/java/ch/qos/logback/classic/gaffer/GafferUtil.java index e5d121a1a386d923824ebd85b24cc5f9e4ee3432..81bdbdf75805c8ca732fd67b5f57d358f08a4adf 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/gaffer/GafferUtil.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/gaffer/GafferUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/helpers/MDCInsertingServletFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/helpers/MDCInsertingServletFilter.java index d23cb07f77f73c6ff956e1d57683a3124882da71..c7df3bef958383e9cf1e21e46d79fd4c7094765d 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/helpers/MDCInsertingServletFilter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/helpers/MDCInsertingServletFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultCssBuilder.java b/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultCssBuilder.java index f81ddb4a5641f1f39853ff9c959518168aeffc51..4255937d38463aadc83cd526685c4c2d6996ecb7 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultCssBuilder.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultCssBuilder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultThrowableRenderer.java b/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultThrowableRenderer.java index c2ec351273fced2d0db8cdccbccc19933f09e75f..ea45e0e0197fe36ff410c6fc8fd6fd2522be55ca 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultThrowableRenderer.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultThrowableRenderer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -50,7 +50,7 @@ public class DefaultThrowableRenderer implements if (commonFrames > 0) { sbuf.append(TRACE_PREFIX); - sbuf.append("\t... " + commonFrames).append(" common frames omitted") + sbuf.append("\t... ").append(commonFrames).append(" common frames omitted") .append(CoreConstants.LINE_SEPARATOR); } } diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java b/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java index 0ea93ea98e1f1a6ae26a10e5ad5d2476f9818ebf..255301fc7887ba8578756cd536d01db0a6044205 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/html/UrlCssBuilder.java b/logback-classic/src/main/java/ch/qos/logback/classic/html/UrlCssBuilder.java index 2ddf8c64a4af6c75f737c4136ab59837eee8d2e6..e8c408d6a6f868ac380068e0b87b2c8c06e00ad8 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/html/UrlCssBuilder.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/html/UrlCssBuilder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/jmx/JMXConfigurator.java b/logback-classic/src/main/java/ch/qos/logback/classic/jmx/JMXConfigurator.java index 0aa88cac533eeed77b46e1cedacbdfb2c51c8e4a..fe2ecf2ded652f7e61adda1dbd38bdbb1da2bd86 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/jmx/JMXConfigurator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/jmx/JMXConfigurator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/jmx/JMXConfiguratorMBean.java b/logback-classic/src/main/java/ch/qos/logback/classic/jmx/JMXConfiguratorMBean.java index 4cdde15c9662b9a0b27afb08057563439d27bb28..7d67a8bf78104bbed926555cb065621ef7ab5360 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/jmx/JMXConfiguratorMBean.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/jmx/JMXConfiguratorMBean.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/jmx/MBeanUtil.java b/logback-classic/src/main/java/ch/qos/logback/classic/jmx/MBeanUtil.java index 5c861f76ec907d6185338462cca6ffe549b9ad30..546f40bce7ce76aca079aabedd95d25a4b58c528 100755 --- a/logback-classic/src/main/java/ch/qos/logback/classic/jmx/MBeanUtil.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/jmx/MBeanUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java index 4ce26cead028a0607a2e4622afd4b2cd6fb62360..64957e6dc52920c9a655abed99221f25cfe103dd 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -25,11 +25,11 @@ import ch.qos.logback.core.joran.conditional.ElseAction; import ch.qos.logback.core.joran.conditional.IfAction; import ch.qos.logback.core.joran.conditional.ThenAction; import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry; -import ch.qos.logback.core.joran.spi.Pattern; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.joran.spi.RuleStore; /** - * This JoranConfiguratorclass adds rules specific to logback-classic. + * JoranConfigurator class adds rules specific to logback-classic. * * @author Ceki Gülcü */ @@ -40,54 +40,51 @@ public class JoranConfigurator extends JoranConfiguratorBase { // parent rules already added super.addInstanceRules(rs); - rs.addRule(new Pattern("configuration"), new ConfigurationAction()); + rs.addRule(new ElementSelector("configuration"), new ConfigurationAction()); - rs.addRule(new Pattern("configuration/contextName"), + rs.addRule(new ElementSelector("configuration/contextName"), new ContextNameAction()); - rs.addRule(new Pattern("configuration/contextListener"), + rs.addRule(new ElementSelector("configuration/contextListener"), new LoggerContextListenerAction()); - rs.addRule(new Pattern("configuration/insertFromJNDI"), + rs.addRule(new ElementSelector("configuration/insertFromJNDI"), new InsertFromJNDIAction()); - rs.addRule(new Pattern("configuration/evaluator"), new EvaluatorAction()); + rs.addRule(new ElementSelector("configuration/evaluator"), new EvaluatorAction()); - rs.addRule(new Pattern("configuration/appender/sift"), new SiftAction()); - rs.addRule(new Pattern("configuration/appender/sift/*"), new NOPAction()); + rs.addRule(new ElementSelector("configuration/appender/sift"), new SiftAction()); + rs.addRule(new ElementSelector("configuration/appender/sift/*"), new NOPAction()); - rs.addRule(new Pattern("configuration/logger"), new LoggerAction()); - rs.addRule(new Pattern("configuration/logger/level"), new LevelAction()); + rs.addRule(new ElementSelector("configuration/logger"), new LoggerAction()); + rs.addRule(new ElementSelector("configuration/logger/level"), new LevelAction()); - rs.addRule(new Pattern("configuration/root"), new RootLoggerAction()); - rs.addRule(new Pattern("configuration/root/level"), new LevelAction()); - rs.addRule(new Pattern("configuration/logger/appender-ref"), + rs.addRule(new ElementSelector("configuration/root"), new RootLoggerAction()); + rs.addRule(new ElementSelector("configuration/root/level"), new LevelAction()); + rs.addRule(new ElementSelector("configuration/logger/appender-ref"), new AppenderRefAction()); - rs.addRule(new Pattern("configuration/root/appender-ref"), + rs.addRule(new ElementSelector("configuration/root/appender-ref"), new AppenderRefAction()); // add if-then-else support - rs.addRule(new Pattern("*/if"), new IfAction()); - rs.addRule(new Pattern("*/if/then"), new ThenAction()); - rs.addRule(new Pattern("*/if/then/*"), new NOPAction()); - rs.addRule(new Pattern("*/if/else"), new ElseAction()); - rs.addRule(new Pattern("*/if/else/*"), new NOPAction()); + rs.addRule(new ElementSelector("*/if"), new IfAction()); + rs.addRule(new ElementSelector("*/if/then"), new ThenAction()); + rs.addRule(new ElementSelector("*/if/then/*"), new NOPAction()); + rs.addRule(new ElementSelector("*/if/else"), new ElseAction()); + rs.addRule(new ElementSelector("*/if/else/*"), new NOPAction()); // add jmxConfigurator only if we have JMX available. // If running under JDK 1.4 (retrotranslateed logback) then we // might not have JMX. if (PlatformInfo.hasJMXObjectName()) { - rs.addRule(new Pattern("configuration/jmxConfigurator"), + rs.addRule(new ElementSelector("configuration/jmxConfigurator"), new JMXConfiguratorAction()); } - rs.addRule(new Pattern("configuration/include"), new IncludeAction()); + rs.addRule(new ElementSelector("configuration/include"), new IncludeAction()); - rs.addRule(new Pattern("configuration/consolePlugin"), + rs.addRule(new ElementSelector("configuration/consolePlugin"), new ConsolePluginAction()); - rs.addRule(new Pattern("configuration/server"), - new ServerAction()); - - rs.addRule(new Pattern("configuration/remote"), - new SocketRemoteAction()); - + rs.addRule(new ElementSelector("configuration/receiver"), + new ReceiverAction()); + } @Override diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java index 1a7dfb62c6924ca5d6bb13332644dd9bcac098ab..840c48e2153e34838109368bc1c9dc90a83f2933 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -39,7 +39,7 @@ public class ConfigurationAction extends Action { // See LOGBACK-527 (the system property is looked up first. Thus, it overrides // the equivalent property in the config file. This reversal of scope priority is justified // by the use case: the admin trying to chase rogue config file - String debugAttrib = System.getProperty(DEBUG_SYSTEM_PROPERTY_KEY); + String debugAttrib = getSystemProperty(DEBUG_SYSTEM_PROPERTY_KEY); if (debugAttrib == null) { debugAttrib = ic.subst(attributes.getValue(INTERNAL_DEBUG_ATTR)); } @@ -66,6 +66,18 @@ public class ConfigurationAction extends Action { ic.pushObject(getContext()); } + String getSystemProperty(String name) { + /* + * LOGBACK-743: accessing a system property in the presence of a + * SecurityManager (e.g. applet sandbox) can result in a SecurityException. + */ + try { + return System.getProperty(name); + } catch (SecurityException ex) { + return null; + } + } + void processScanAttrib(InterpretationContext ic, Attributes attributes) { String scanAttrib = ic.subst(attributes.getValue(SCAN_ATTR)); if (!OptionHelper.isEmpty(scanAttrib) diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConsolePluginAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConsolePluginAction.java index 38b7e43436adfcf9378a13d059b107c9ad3defcb..67c365b55ccb1c90d89bdd57cddaf8db6bb96e39 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConsolePluginAction.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConsolePluginAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ContextNameAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ContextNameAction.java index ee6c5a807d93f76ac1481f0aa23843910772151b..d06f2caa11cedaa49a4c866a918d7428336f04c5 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ContextNameAction.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ContextNameAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/EvaluatorAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/EvaluatorAction.java index d0be728f38c4ac9cb0230bdd696f227c49ceb203..f2fcc5c01ec407f1b8bd26ac993396acefb587c1 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/EvaluatorAction.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/EvaluatorAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/InsertFromJNDIAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/InsertFromJNDIAction.java index db76891772afe1f4e584dc5e4aeec3adcced95f1..502976564207acd66bc417a61ec99a65710eb9e2 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/InsertFromJNDIAction.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/InsertFromJNDIAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/JMXConfiguratorAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/JMXConfiguratorAction.java index 31a85d836e69060b8b8c50b0c863112256405f64..61a4f6be9b7b6589ebb837558b28922153d92391 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/JMXConfiguratorAction.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/JMXConfiguratorAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LevelAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LevelAction.java index 7ee3796923eccce424532f38ea9c27cb2e3377dd..bbdfe2696760984b39fc5190fe9403726fc69b4a 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LevelAction.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LevelAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoggerAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoggerAction.java index 85d0aab753176123801b8ffd99bdc7213903df9a..665846614a49b119af222958c2747168aca3dab2 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoggerAction.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoggerAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoggerContextListenerAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoggerContextListenerAction.java index 9a5d8e9f18d87091ec9b4bc170c6fa209ad46bb5..8da3efa6627eb14ce55060165c7d2c69bb69a2d4 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoggerContextListenerAction.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoggerContextListenerAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/SocketRemoteAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ReceiverAction.java similarity index 61% rename from logback-classic/src/main/java/ch/qos/logback/classic/joran/action/SocketRemoteAction.java rename to logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ReceiverAction.java index cc087be9931bd71e367b8cd4814dac1ca114aef2..7a79afde94c497e12e10a80a7a081723581fdf47 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/SocketRemoteAction.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ReceiverAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -15,42 +15,47 @@ package ch.qos.logback.classic.joran.action; import org.xml.sax.Attributes; -import ch.qos.logback.classic.net.SocketRemote; +import ch.qos.logback.classic.net.ReceiverBase; +import ch.qos.logback.classic.net.SocketReceiver; import ch.qos.logback.core.joran.action.Action; import ch.qos.logback.core.joran.spi.ActionException; import ch.qos.logback.core.joran.spi.InterpretationContext; import ch.qos.logback.core.util.OptionHelper; /** - * A Joran {@link Action} for a {@link SocketRemote} configuration. + * A Joran {@link Action} for a {@link SocketReceiver} configuration. * * @author Carl Harris */ -public class SocketRemoteAction extends Action { +public class ReceiverAction extends Action { - private SocketRemote remote; + private ReceiverBase receiver; private boolean inError; @Override public void begin(InterpretationContext ic, String name, Attributes attributes) throws ActionException { + String className = attributes.getValue(CLASS_ATTRIBUTE); if (OptionHelper.isEmpty(className)) { - className = SocketRemote.class.getCanonicalName(); + addError("Missing class name for receiver. Near [" + name + + "] line " + getLineNumber(ic)); + inError = true; + return; } try { - addInfo("About to instantiate remote of type [" + className + "]"); - - remote = (SocketRemote) OptionHelper.instantiateByClassName( - className, SocketRemote.class, context); - remote.setContext(context); + addInfo("About to instantiate receiver of type [" + className + "]"); - ic.pushObject(remote); + receiver = (ReceiverBase) OptionHelper.instantiateByClassName( + className, ReceiverBase.class, context); + receiver.setContext(context); + + ic.pushObject(receiver); } catch (Exception ex) { inError = true; - addError("Could not create a remote of type [" + className + "].", ex); + addError("Could not create a receiver of type [" + className + "].", ex); throw new ActionException(ex); } } @@ -61,10 +66,11 @@ public class SocketRemoteAction extends Action { if (inError) return; - remote.start(); - + ic.getContext().register(receiver); + receiver.start(); + Object o = ic.peekObject(); - if (o != remote) { + if (o != receiver) { addWarn("The object at the of the stack is not the remote " + "pushed earlier."); } else { diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/RootLoggerAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/RootLoggerAction.java index fc4c4817e5a5ad0106dce5e15aa3e64faaf3148d..a52eb06c09928e34a9db9ce76041003188fd5e23 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/RootLoggerAction.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/RootLoggerAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ServerAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ServerAction.java deleted file mode 100644 index 5d0c4b11bf833c2eb51c048d17687522bd266f6d..0000000000000000000000000000000000000000 --- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ServerAction.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.classic.joran.action; - -import org.xml.sax.Attributes; - -import ch.qos.logback.classic.net.server.SocketServer; -import ch.qos.logback.core.joran.action.Action; -import ch.qos.logback.core.joran.spi.ActionException; -import ch.qos.logback.core.joran.spi.InterpretationContext; -import ch.qos.logback.core.util.OptionHelper; - -/** - * A Joran {@link Action} for a server configuration. - * - * @author Carl Harris - */ -public class ServerAction extends Action { - - private SocketServer server; - private boolean inError; - - @Override - public void begin(InterpretationContext ic, String name, - Attributes attributes) throws ActionException { - String className = attributes.getValue(CLASS_ATTRIBUTE); - if (OptionHelper.isEmpty(className)) { - className = SocketServer.class.getCanonicalName(); - } - try { - addInfo("About to instantiate server of type [" + className + "]"); - - server = (SocketServer) OptionHelper.instantiateByClassName(className, - SocketServer.class, context); - server.setContext(context); - ic.pushObject(server); - } - catch (Exception ex) { - inError = true; - addError("Could not create a server of type [" + className + "].", ex); - throw new ActionException(ex); - } - } - - @Override - public void end(InterpretationContext ic, String name) - throws ActionException { - - if (inError) return; - - server.start(); - - Object o = ic.peekObject(); - if (o != server) { - addWarn("The object at the of the stack is not the server " + - "pushed earlier."); - } else { - ic.popObject(); - } - } - -} diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/jul/JULHelper.java b/logback-classic/src/main/java/ch/qos/logback/classic/jul/JULHelper.java index 0ee1afb6048572423a6c91b7301ecc1d3f2a9f7e..121cd0a217094c87a420cf5806c1dcd55a42fa9a 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/jul/JULHelper.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/jul/JULHelper.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/jul/LevelChangePropagator.java b/logback-classic/src/main/java/ch/qos/logback/classic/jul/LevelChangePropagator.java index 2c90cec1c08746237958b9e01902fa9a4b97a2a5..a7fa5a22d59b52f39544fdd8457b3698f66de12f 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/jul/LevelChangePropagator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/jul/LevelChangePropagator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java b/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java index a5c9def061b8ddad2fcae320a2ed5fe5cf4db432..6516c80d9478ab2f084c2d09982073a8588f95e6 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueAppender.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueAppender.java index 90de734eb8df9b373782cb655207bd7b4336f13e..05f8510ad57006c6221b2baa9387a1e1d084de4d 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueAppender.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueSink.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueSink.java index fcf84a6fa219cc96daf82f5b0f815b3af963d2f6..0e951f725dff422d6bfc65b0935a5ebac1aa1240 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueSink.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueSink.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicAppender.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicAppender.java index c88e6963e291cb2568c5b985693c962860deb21d..1e3f46113d39d05127235fc46296ef97bac7b5e2 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicAppender.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicSink.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicSink.java index 7556fb5b2530ed9d11a780988006c080cb0870e4..88bee446c30f36e338368cc9129b1f5fab9af50f 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicSink.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicSink.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/LoggingEventPreSerializationTransformer.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/LoggingEventPreSerializationTransformer.java index 635102212a178a659fd0c67ff774c7bed4269bf2..68727fa63fe691b27a6b926119cfba4f0de90922 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/LoggingEventPreSerializationTransformer.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/LoggingEventPreSerializationTransformer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/ReceiverBase.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/ReceiverBase.java new file mode 100644 index 0000000000000000000000000000000000000000..e6c0ded3a824b5e1c3402d2c10f90b66a8f5f070 --- /dev/null +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/ReceiverBase.java @@ -0,0 +1,87 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package ch.qos.logback.classic.net; + +import ch.qos.logback.core.spi.ContextAwareBase; +import ch.qos.logback.core.spi.LifeCycle; + +/** + * An abstract base for components that receive logging events from a remote + * peer and log according to local policy + * + * @author Carl Harris + */ +public abstract class ReceiverBase extends ContextAwareBase + implements LifeCycle { + + private boolean started; + + /** + * {@inheritDoc} + */ + public final void start() { + if (isStarted()) return; + if (getContext() == null) { + throw new IllegalStateException("context not set"); + } + if (shouldStart()) { + getContext().getExecutorService().execute(getRunnableTask()); + started = true; + } + } + + /** + * {@inheritDoc} + */ + public final void stop() { + if (!isStarted()) return; + try { + onStop(); + } + catch (RuntimeException ex) { + addError("on stop: " + ex, ex); + } + started = false; + } + + /** + * {@inheritDoc} + */ + public final boolean isStarted() { + return started; + } + + /** + * Determines whether this receiver should start. + *

+ * Subclasses will implement this method to do any subclass-specific + * validation. The subclass's {@link #getRunnableTask()} method will be + * invoked (and the task returned will be submitted to the executor) + * if and only if this method returns {@code true} + * @return flag indicating whether this receiver should start + */ + protected abstract boolean shouldStart(); + + /** + * Allows a subclass to participate in receiver shutdown. + */ + protected abstract void onStop(); + + /** + * Provides the runnable task this receiver will execute. + * @return runnable task + */ + protected abstract Runnable getRunnableTask(); + +} diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SMTPAppender.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SMTPAppender.java index d35bd51fccc38c80a23fad047fa63ccd9e3c5ec3..4192297a2cb1fe7479388be6b52c0de7adb0bef7 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SMTPAppender.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SMTPAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -93,7 +93,7 @@ public class SMTPAppender extends SMTPAppenderBase { } } - protected boolean isEventMarkedForBufferRemoval(ILoggingEvent eventObject) { + protected boolean eventMarksEndOfLife(ILoggingEvent eventObject) { Marker marker = eventObject.getMarker(); if(marker == null) return false; diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketAppender.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketAppender.java index 788d509ef694266071b7fd83fd4a55512110de08..dd26701636871f256c5b10bd05fd709b1e08e75e 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketAppender.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -16,7 +16,7 @@ package ch.qos.logback.classic.net; import java.net.InetAddress; import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.net.SSLSocketAppenderBase; +import ch.qos.logback.core.net.AbstractSSLSocketAppender; import ch.qos.logback.core.spi.PreSerializationTransformer; /** @@ -27,7 +27,7 @@ import ch.qos.logback.core.spi.PreSerializationTransformer; * * @author Carl Harris */ -public class SSLSocketAppender extends SSLSocketAppenderBase { +public class SSLSocketAppender extends AbstractSSLSocketAppender { private final PreSerializationTransformer pst = new LoggingEventPreSerializationTransformer(); @@ -40,16 +40,17 @@ public class SSLSocketAppender extends SSLSocketAppenderBase { /** * Connects to remote server at address and port. */ + @Deprecated public SSLSocketAppender(String host, int port) { - this(getAddressByName(host), port); + super(host, port); } /** * Connects to remote server at address and port. */ + @Deprecated public SSLSocketAppender(InetAddress address, int port) { - this.address = address; - this.port = port; + super(address.getHostAddress(), port); } @Override diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketRemote.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketReceiver.java similarity index 82% rename from logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketRemote.java rename to logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketReceiver.java index e6cfc88b507336c1ab3e7ba11a4fdc0c88a8bbbe..913a194d685341ad148c293396fc0f29e6ac0eca 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketRemote.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketReceiver.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,29 +11,30 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.classic.net; import javax.net.SocketFactory; import javax.net.ssl.SSLContext; import ch.qos.logback.core.net.ssl.ConfigurableSSLSocketFactory; +import ch.qos.logback.core.net.ssl.SSLComponent; import ch.qos.logback.core.net.ssl.SSLConfiguration; import ch.qos.logback.core.net.ssl.SSLParametersConfiguration; /** - * A {@link SocketRemote} that supports SSL. + * A {@link SocketReceiver} that supports SSL. * * @author Carl Harris */ -public class SSLSocketRemote extends SocketRemote { +public class SSLSocketReceiver extends SocketReceiver + implements SSLComponent { private SSLConfiguration ssl; private SocketFactory socketFactory; /** * Gets an {@link SocketFactory} that produces SSL sockets using an - * {@link SSLContext} that is derived from the remote's configuration. + * {@link SSLContext} that is derived from the receiver's configuration. * @return socket factory */ @Override @@ -45,17 +46,18 @@ public class SSLSocketRemote extends SocketRemote { * {@inheritDoc} */ @Override - public void start() { + protected boolean shouldStart() { try { SSLContext sslContext = getSsl().createContext(this); SSLParametersConfiguration parameters = getSsl().getParameters(); parameters.setContext(getContext()); socketFactory = new ConfigurableSSLSocketFactory(parameters, sslContext.getSocketFactory()); - super.start(); + return super.shouldStart(); } catch (Exception ex) { addError(ex.getMessage(), ex); + return false; } } diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SimpleSSLSocketServer.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SimpleSSLSocketServer.java index 85056f765c87dcac422b87b77a26c59e4a4fa884..7dde76093fd67768c9296992f8412091211a7a56 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SimpleSSLSocketServer.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SimpleSSLSocketServer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SimpleSocketServer.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SimpleSocketServer.java index fab43b3339c86f5e8ac2d9028e5ec10f84975e4f..ae832e412fbf22adecf8bf2e1038189283f6b4b9 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SimpleSocketServer.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SimpleSocketServer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAcceptor.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAcceptor.java index c5d782f34cec1fefc060988bcfb11813c08f2a3b..87d4391427a76d7484daabd87f734e656cf008b6 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAcceptor.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAcceptor.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java index 27eb4d3ea94dbe5b6b35fb24aa1392561e63f24a..3396c7013d5aa18879b84f53f99035d3166052bb 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -17,7 +17,7 @@ package ch.qos.logback.classic.net; import java.net.InetAddress; import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.net.SocketAppenderBase; +import ch.qos.logback.core.net.AbstractSocketAppender; import ch.qos.logback.core.spi.PreSerializationTransformer; /** @@ -31,31 +31,30 @@ import ch.qos.logback.core.spi.PreSerializationTransformer; * @author Sébastien Pennec */ -public class SocketAppender extends SocketAppenderBase { +public class SocketAppender extends AbstractSocketAppender { - boolean includeCallerData = false; - - PreSerializationTransformer pst = new LoggingEventPreSerializationTransformer(); + private static final PreSerializationTransformer pst = + new LoggingEventPreSerializationTransformer(); + private boolean includeCallerData = false; + public SocketAppender() { } /** - * Connects to remote server at address and port. + * Connects to remote server at host and port. */ - public SocketAppender(InetAddress address, int port) { - this.address = address; - this.remoteHost = address.getHostName(); - this.port = port; + @Deprecated + public SocketAppender(String host, int port) { + super(host, port); } /** - * Connects to remote server at host and port. + * Connects to remote server at address and port. */ - public SocketAppender(String host, int port) { - this.port = port; - this.address = getAddressByName(host); - this.remoteHost = host; + @Deprecated + public SocketAppender(InetAddress address, int port) { + super(address.getHostAddress(), port); } @Override diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java index ac6b510929a671483aa463fa76ce1670b31a12da..9356c26d27efc6a3afee0d28a317c6ec3f9e1d70 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketReceiver.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketReceiver.java new file mode 100644 index 0000000000000000000000000000000000000000..708af5a0dea28226c1201bc09f7da03cb6c0bd13 --- /dev/null +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketReceiver.java @@ -0,0 +1,225 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package ch.qos.logback.classic.net; + +import java.io.EOFException; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.net.ConnectException; +import java.net.InetAddress; +import java.net.Socket; +import java.net.UnknownHostException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.RejectedExecutionException; + +import javax.net.SocketFactory; + +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.net.DefaultSocketConnector; +import ch.qos.logback.core.net.AbstractSocketAppender; +import ch.qos.logback.core.net.SocketConnector; +import ch.qos.logback.core.util.CloseUtil; + +/** + * A component that receives serialized {@link ILoggingEvent} objects from a + * remote appender over a {@link Socket}. + * + * @author Carl Harris + */ +public class SocketReceiver extends ReceiverBase + implements Runnable, SocketConnector.ExceptionHandler { + + private static final int DEFAULT_ACCEPT_CONNECTION_DELAY = 5000; + + private String remoteHost; + private InetAddress address; + private int port; + private int reconnectionDelay; + private int acceptConnectionTimeout = DEFAULT_ACCEPT_CONNECTION_DELAY; + + private String receiverId; + private volatile Socket socket; + private Future connectorTask; + + /** + * {@inheritDoc} + */ + protected boolean shouldStart() { + int errorCount = 0; + if (port == 0) { + errorCount++; + addError("No port was configured for receiver. " + + "For more information, please visit http://logback.qos.ch/codes.html#receiver_no_port"); + } + + if (remoteHost == null) { + errorCount++; + addError("No host name or address was configured for receiver. " + + "For more information, please visit http://logback.qos.ch/codes.html#receiver_no_host"); + } + + if (reconnectionDelay == 0) { + reconnectionDelay = AbstractSocketAppender.DEFAULT_RECONNECTION_DELAY; + } + + if (errorCount == 0) { + try { + address = InetAddress.getByName(remoteHost); + } catch (UnknownHostException ex) { + addError("unknown host: " + remoteHost); + errorCount++; + } + } + + if (errorCount == 0) { + receiverId = "receiver " + remoteHost + ":" + port + ": "; + } + + return errorCount == 0; + } + + /** + * {@inheritDoc} + */ + protected void onStop() { + if (socket != null) { + CloseUtil.closeQuietly(socket); + } + } + + @Override + protected Runnable getRunnableTask() { + return this; + } + + /** + * {@inheritDoc} + */ + public void run() { + try { + LoggerContext lc = (LoggerContext) getContext(); + while (!Thread.currentThread().isInterrupted()) { + SocketConnector connector = createConnector(address, port, 0, + reconnectionDelay); + connectorTask = activateConnector(connector); + if (connectorTask == null) + break; + socket = waitForConnectorToReturnASocket(); + if (socket == null) + break; + dispatchEvents(lc); + } + } catch (InterruptedException ex) { + assert true; // ok... we'll exit now + } + addInfo("shutting down"); + } + + private SocketConnector createConnector(InetAddress address, int port, + int initialDelay, int retryDelay) { + SocketConnector connector = newConnector(address, port, initialDelay, + retryDelay); + connector.setExceptionHandler(this); + connector.setSocketFactory(getSocketFactory()); + return connector; + } + + + private Future activateConnector(SocketConnector connector) { + try { + return getContext().getExecutorService().submit(connector); + } catch (RejectedExecutionException ex) { + return null; + } + } + + private Socket waitForConnectorToReturnASocket() throws InterruptedException { + try { + Socket s = connectorTask.get(); + connectorTask = null; + return s; + } catch (ExecutionException e) { + return null; + } + } + + private void dispatchEvents(LoggerContext lc) { + try { + socket.setSoTimeout(acceptConnectionTimeout); + ObjectInputStream ois = new ObjectInputStream(socket.getInputStream()); + socket.setSoTimeout(0); + addInfo(receiverId + "connection established"); + while (true) { + ILoggingEvent event = (ILoggingEvent) ois.readObject(); + Logger remoteLogger = lc.getLogger(event.getLoggerName()); + if (remoteLogger.isEnabledFor(event.getLevel())) { + remoteLogger.callAppenders(event); + } + } + } catch (EOFException ex) { + addInfo(receiverId + "end-of-stream detected"); + } catch (IOException ex) { + addInfo(receiverId + "connection failed: " + ex); + } catch (ClassNotFoundException ex) { + addInfo(receiverId + "unknown event class: " + ex); + } finally { + CloseUtil.closeQuietly(socket); + socket = null; + addInfo(receiverId + "connection closed"); + } + } + + /** + * {@inheritDoc} + */ + public void connectionFailed(SocketConnector connector, Exception ex) { + if (ex instanceof InterruptedException) { + addInfo("connector interrupted"); + } else if (ex instanceof ConnectException) { + addInfo(receiverId + "connection refused"); + } else { + addInfo(receiverId + ex); + } + } + + + protected SocketConnector newConnector(InetAddress address, + int port, int initialDelay, int retryDelay) { + return new DefaultSocketConnector(address, port, initialDelay, retryDelay); + } + + protected SocketFactory getSocketFactory() { + return SocketFactory.getDefault(); + } + + public void setRemoteHost(String remoteHost) { + this.remoteHost = remoteHost; + } + + public void setPort(int port) { + this.port = port; + } + + public void setReconnectionDelay(int reconnectionDelay) { + this.reconnectionDelay = reconnectionDelay; + } + + public void setAcceptConnectionTimeout(int acceptConnectionTimeout) { + this.acceptConnectionTimeout = acceptConnectionTimeout; + } + +} diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketRemote.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketRemote.java deleted file mode 100644 index 525a795897f3aef89eaf78841fe40a9f51190ecb..0000000000000000000000000000000000000000 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketRemote.java +++ /dev/null @@ -1,259 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ - -package ch.qos.logback.classic.net; - -import java.io.EOFException; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.net.ConnectException; -import java.net.InetAddress; -import java.net.Socket; -import java.net.UnknownHostException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.RejectedExecutionException; - -import javax.net.SocketFactory; - -import org.slf4j.ILoggerFactory; -import org.slf4j.LoggerFactory; - -import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.net.SocketAppenderBase; -import ch.qos.logback.core.net.SocketConnector; -import ch.qos.logback.core.net.SocketConnectorBase; -import ch.qos.logback.core.spi.ContextAwareBase; -import ch.qos.logback.core.spi.LifeCycle; -import ch.qos.logback.core.util.CloseUtil; - -/** - * A component that receives serialized {@link ILoggingEvent} objects from a - * remote appender over a {@link Socket}. - * - * @author Carl Harris - */ -public class SocketRemote extends ContextAwareBase - implements LifeCycle, SocketConnector.ExceptionHandler, Runnable { - - private static final int DEFAULT_ACCEPT_CONNECTION_DELAY = 5000; - - private String host; - private InetAddress address; - private int port; - private int reconnectionDelay; - private int acceptConnectionTimeout = DEFAULT_ACCEPT_CONNECTION_DELAY; - - private ExecutorService executor; - private boolean started; - private String remoteId; - private volatile Socket socket; - - /** - * {@inheritDoc} - */ - public void start() { - if (isStarted()) return; - - if (getContext() == null) { - throw new IllegalStateException("context not set"); - } - - int errorCount = 0; - if (port == 0) { - errorCount++; - addError("No port was configured for remote. " - + "For more information, please visit http://logback.qos.ch/codes.html#receiver_no_port"); - } - - if (host == null) { - errorCount++; - addError("No host name or address was configured for remote. " - + "For more information, please visit http://logback.qos.ch/codes.html#receiver_no_host"); - } - - if (reconnectionDelay == 0) { - reconnectionDelay = SocketAppenderBase.DEFAULT_RECONNECTION_DELAY; - } - - if (errorCount == 0) { - try { - address = InetAddress.getByName(host); - } - catch (UnknownHostException ex) { - addError("unknown host: " + host); - errorCount++; - } - } - - if (errorCount == 0) { - remoteId = "remote " + host + ":" + port + ": "; - executor = createExecutorService(); - executor.execute(this); - started = true; - } - } - - /** - * {@inheritDoc} - */ - public void stop() { - if (!isStarted()) return; - if (socket != null) { - CloseUtil.closeQuietly(socket); - } - executor.shutdownNow(); - started = false; - } - - /** - * {@inheritDoc} - */ - public boolean isStarted() { - return started; - } - - /** - * {@inheritDoc} - */ - public void run() { - try { - LoggerContext lc = awaitConfiguration(); - SocketConnector connector = createConnector(address, port, 0, - reconnectionDelay); - while (!executor.isShutdown() && - !Thread.currentThread().isInterrupted()) { - try { - executor.execute(connector); - } - catch (RejectedExecutionException ex) { - // executor is shutting down... - continue; - } - socket = connector.awaitConnection(); - dispatchEvents(lc); - connector = createConnector(address, port, reconnectionDelay); - } - } - catch (InterruptedException ex) { - assert true; // ok... we'll exit now - } - addInfo("shutting down"); - } - - private LoggerContext awaitConfiguration() throws InterruptedException { - ILoggerFactory factory = LoggerFactory.getILoggerFactory(); - while (!(factory instanceof LoggerContext) - && !Thread.currentThread().isInterrupted()) { - Thread.sleep(500); - factory = LoggerFactory.getILoggerFactory(); - } - return (LoggerContext) factory; - } - - private void dispatchEvents(LoggerContext lc) { - try { - socket.setSoTimeout(acceptConnectionTimeout); - ObjectInputStream ois = new ObjectInputStream(socket.getInputStream()); - socket.setSoTimeout(0); - addInfo(remoteId + "connection established"); - while (true) { - ILoggingEvent event = (ILoggingEvent) ois.readObject(); - Logger remoteLogger = lc.getLogger(event.getLoggerName()); - if (remoteLogger.isEnabledFor(event.getLevel())) { - remoteLogger.callAppenders(event); - } - } - } - catch (EOFException ex) { - addInfo(remoteId + "end-of-stream detected"); - } - catch (IOException ex) { - addInfo(remoteId + "connection failed: " + ex); - } - catch (ClassNotFoundException ex) { - addInfo(remoteId + "unknown event class: " + ex); - } - finally { - CloseUtil.closeQuietly(socket); - socket = null; - addInfo(remoteId + "connection closed"); - } - } - - /** - * {@inheritDoc} - */ - public void connectionFailed(SocketConnector connector, Exception ex) { - if (ex instanceof InterruptedException) { - addInfo("connector interrupted"); - } - else if (ex instanceof ConnectException) { - addInfo(remoteId + "connection refused"); - } - else { - addInfo(remoteId + ex); - } - } - - private SocketConnector createConnector(InetAddress address, int port, - int delay) { - return createConnector(address, port, delay, delay); - } - - private SocketConnector createConnector(InetAddress address, int port, - int initialDelay, int retryDelay) { - SocketConnector connector = newConnector(address, port, initialDelay, - retryDelay); - connector.setExceptionHandler(this); - connector.setSocketFactory(getSocketFactory()); - return connector; - } - - protected SocketConnector newConnector(InetAddress address, - int port, int initialDelay, int retryDelay) { - return new SocketConnectorBase(address, port, initialDelay, retryDelay); - } - - protected SocketFactory getSocketFactory() { - return SocketFactory.getDefault(); - } - - protected ExecutorService createExecutorService() { - return Executors.newCachedThreadPool(); - } - - public void setHost(String host) { - this.host = host; - } - - public void setRemoteHost(String host) { - setHost(host); - } - - public void setPort(int port) { - this.port = port; - } - - public void setReconnectionDelay(int reconnectionDelay) { - this.reconnectionDelay = reconnectionDelay; - } - - public void setAcceptConnectionTimeout(int acceptConnectionTimeout) { - this.acceptConnectionTimeout = acceptConnectionTimeout; - } - -} diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SyslogAppender.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SyslogAppender.java index ebc67d5ccf05ee56a1775561d946410985af06d6..657574758f4f991d60489dee8f04c9c4253bc44d 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SyslogAppender.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SyslogAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderClient.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderClient.java index e49d0b943fd156f0be334dab9aaffd50042d6f0e..3e93404b5a41cf22a488ed19752e5f1737ca5174 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderClient.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderClient.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderServerListener.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderServerListener.java index e71d1356e77cadcf247dc99bb38f0bbfef9cb566..2eed08ec8629c5bc64fa8e29da64b1a2ba8ec14f 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderServerListener.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderServerListener.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.classic.net.server; import java.io.IOException; diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderServerRunner.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderServerRunner.java index 99ed788363960923b3bcc411e4864a10faccc40c..a0ad2d745a25a9bd3b5d0c8a23726b1763c68979 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderServerRunner.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderServerRunner.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.classic.net.server; import java.util.concurrent.Executor; diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderStreamClient.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderStreamClient.java index 6d8d40951923c37cc15b64461111c8d08dbdc8d2..2a96018eb34b6d65ea09a31e565b3a820c3ecb93 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderStreamClient.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderStreamClient.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SSLServerSocketAppender.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SSLServerSocketAppender.java index 03c3689aa58980e9c78f015ca253586298a99147..dcb2c03cc31539d907893541c993419f98536932 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SSLServerSocketAppender.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SSLServerSocketAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.classic.net.server; import ch.qos.logback.classic.net.LoggingEventPreSerializationTransformer; diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SSLSocketServer.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SSLServerSocketReceiver.java similarity index 87% rename from logback-classic/src/main/java/ch/qos/logback/classic/net/server/SSLSocketServer.java rename to logback-classic/src/main/java/ch/qos/logback/classic/net/server/SSLServerSocketReceiver.java index 05af69688cfdee553779c6d9672e071750d00344..b4e0932eeb92c723fcd24bdb592fdeba8bf717db 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SSLSocketServer.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SSLServerSocketReceiver.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -17,15 +17,17 @@ import javax.net.ServerSocketFactory; import javax.net.ssl.SSLContext; import ch.qos.logback.core.net.ssl.ConfigurableSSLServerSocketFactory; +import ch.qos.logback.core.net.ssl.SSLComponent; import ch.qos.logback.core.net.ssl.SSLConfiguration; import ch.qos.logback.core.net.ssl.SSLParametersConfiguration; /** - * A {@link SocketServer} that supports SSL. + * A {@link ServerSocketReceiver} that supports SSL. * * @author Carl Harris */ -public class SSLSocketServer extends SocketServer { +public class SSLServerSocketReceiver extends ServerSocketReceiver + implements SSLComponent { private SSLConfiguration ssl; private ServerSocketFactory socketFactory; diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/ServerSocketAppender.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/ServerSocketAppender.java index 272b3cf230f9643a0b8a63c97fbe989fdd5a1e80..b08d836efcfe5b6904791a1aa0a659c7683a1a0d 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/ServerSocketAppender.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/ServerSocketAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,12 +11,11 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.classic.net.server; import ch.qos.logback.classic.net.LoggingEventPreSerializationTransformer; import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.net.server.ServerSocketAppenderBase; +import ch.qos.logback.core.net.server.AbstractServerSocketAppender; import ch.qos.logback.core.spi.PreSerializationTransformer; /** @@ -27,7 +26,7 @@ import ch.qos.logback.core.spi.PreSerializationTransformer; * @author Carl Harris */ public class ServerSocketAppender - extends ServerSocketAppenderBase { + extends AbstractServerSocketAppender { private static final PreSerializationTransformer pst = new LoggingEventPreSerializationTransformer(); diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SocketServer.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/ServerSocketReceiver.java similarity index 67% rename from logback-classic/src/main/java/ch/qos/logback/classic/net/server/SocketServer.java rename to logback-classic/src/main/java/ch/qos/logback/classic/net/server/ServerSocketReceiver.java index ee958793f36f5eae1c2f25e0a082eda859983d55..be0b8c11ff5edb922781391c8f04029a998745e5 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SocketServer.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/ServerSocketReceiver.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -18,54 +18,54 @@ import java.net.InetAddress; import java.net.ServerSocket; import java.net.UnknownHostException; import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; import javax.net.ServerSocketFactory; -import ch.qos.logback.core.net.SocketAppenderBase; +import ch.qos.logback.classic.net.ReceiverBase; +import ch.qos.logback.core.net.AbstractSocketAppender; import ch.qos.logback.core.net.server.ServerListener; import ch.qos.logback.core.net.server.ServerRunner; -import ch.qos.logback.core.net.server.ThreadPoolFactoryBean; -import ch.qos.logback.core.spi.ContextAwareBase; -import ch.qos.logback.core.spi.LifeCycle; +import ch.qos.logback.core.util.CloseUtil; /** * A logging socket server that is configurable using Joran. * * @author Carl Harris */ -public class SocketServer extends ContextAwareBase implements LifeCycle { +public class ServerSocketReceiver extends ReceiverBase { /** * Default {@link ServerSocket} backlog */ public static final int DEFAULT_BACKLOG = 50; - private int port = SocketAppenderBase.DEFAULT_PORT; + private int port = AbstractSocketAppender.DEFAULT_PORT; private int backlog = DEFAULT_BACKLOG; private String address; - private ThreadPoolFactoryBean threadPool; + private ServerSocket serverSocket; private ServerRunner runner; - private ExecutorService executor; /** * Starts the server. */ - public final void start() { - if (isStarted()) return; + protected boolean shouldStart() { try { - ServerSocket socket = getServerSocketFactory().createServerSocket( + ServerSocket serverSocket = getServerSocketFactory().createServerSocket( getPort(), getBacklog(), getInetAddress()); - ServerListener listener = createServerListener(socket); - executor = getThreadPool().createExecutor(); - runner = createServerRunner(listener, executor); + + ServerListener listener = + createServerListener(serverSocket); + + runner = createServerRunner(listener, getContext().getExecutorService()); runner.setContext(getContext()); - runner.start(); + return true; } catch (Exception ex) { addError("server startup error: " + ex, ex); + CloseUtil.closeQuietly(serverSocket); + return false; } } @@ -80,28 +80,24 @@ public class SocketServer extends ContextAwareBase implements LifeCycle { return new RemoteAppenderServerRunner(listener, executor); } + @Override + protected Runnable getRunnableTask() { + return runner; + } + /** - * Stops the server. + * {@inheritDoc} */ - public final void stop() { - if (!isStarted()) return; + protected void onStop() { try { + if (runner == null) return; runner.stop(); - executor.shutdownNow(); } catch (IOException ex) { addError("server shutdown error: " + ex, ex); } } - /** - * Gets a flag indicating whether the server is running. - * @return flag state - */ - public final boolean isStarted() { - return runner != null && runner.isStarted(); - } - /** * Gets the server socket factory. *

@@ -147,7 +143,7 @@ public class SocketServer extends ContextAwareBase implements LifeCycle { * @return queue depth * @see java.net.ServerSocket */ - public Integer getBacklog() { + public int getBacklog() { return backlog; } @@ -159,7 +155,7 @@ public class SocketServer extends ContextAwareBase implements LifeCycle { * @param backlog the queue depth to set * @see java.net.ServerSocket */ - public void setBacklog(Integer backlog) { + public void setBacklog(int backlog) { this.backlog = backlog; } @@ -179,24 +175,4 @@ public class SocketServer extends ContextAwareBase implements LifeCycle { this.address = address; } - /** - * Gets the server's thread pool configuration. - * @return thread pool configuration; if no thread pool configuration was - * provided, a default configuration is returned - */ - public ThreadPoolFactoryBean getThreadPool() { - if (threadPool == null) { - return new ThreadPoolFactoryBean(); - } - return threadPool; - } - - /** - * Sets the server's thread pool configuration. - * @param threadPool the configuration to set - */ - public void setThreadPool(ThreadPoolFactoryBean threadPool) { - this.threadPool = threadPool; - } - } diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SocketServerNestedComponentRegistryRules.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SocketServerNestedComponentRegistryRules.java deleted file mode 100644 index 148789b570a5350fa76eafe931ccce048622d3d3..0000000000000000000000000000000000000000 --- a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SocketServerNestedComponentRegistryRules.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.classic.net.server; - -import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry; -import ch.qos.logback.core.net.server.ThreadPoolFactoryBean; -import ch.qos.logback.core.net.ssl.SSLConfiguration; - -/** - * Nested component registry rules for {@link SocketServer}. - * - * @author Carl Harris - */ -public class SocketServerNestedComponentRegistryRules { - - public static void addDefaultNestedComponentRegistryRules( - DefaultNestedComponentRegistry registry) { - - registry.add(SocketServer.class, "threadPool", - ThreadPoolFactoryBean.class); - registry.add(SSLSocketServer.class, "ssl", - SSLConfiguration.class); - } - -} diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/Abbreviator.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/Abbreviator.java index b2a98926607c29c676120edd7abefd0b66f6980d..26b19a264bd091c7c4f7639dd9d9105f5634e972 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/Abbreviator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/Abbreviator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/CallerDataConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/CallerDataConverter.java index 81bc67e8f9f17e405f7d677af39c4960fdb85517..46acd05b1c0beac1d1e8765096a42e936ff2d319 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/CallerDataConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/CallerDataConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ClassNameOnlyAbbreviator.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ClassNameOnlyAbbreviator.java index 7a7fa97732c00454efa75a7605796dab66083f44..563f28886ea4018057e9e4383eeed2956dc17412 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ClassNameOnlyAbbreviator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ClassNameOnlyAbbreviator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ClassOfCallerConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ClassOfCallerConverter.java index 2d9642371321a05405bcebd1de38ddab81c816d5..b38528a5bab3315cb39e7e4232f0b83c88d5901f 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ClassOfCallerConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ClassOfCallerConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ClassicConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ClassicConverter.java index ce7bb7efcdb5ca15ab9c67c437e557fa49eef6b8..e2dd5c1ec21007ed8c659a7bd4fadf485263b4fe 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ClassicConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ClassicConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ContextNameConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ContextNameConverter.java index 6fd60e72622b07f45d3624c5192394b9608398f4..809e45e305e1fd3b83fc1c9c09288d6b0eb15b33 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ContextNameConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ContextNameConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/DateConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/DateConverter.java index b29a422a01bcb9bb9caf8ff556fa87165e5afc4b..081de3d396ba4e67a1c25a63f61417367a84fec0 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/DateConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/DateConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/EnsureExceptionHandling.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/EnsureExceptionHandling.java index c946474ad24692f4e2f21cec4214c71dde5940c3..a174cadd82c7d1501d4eda43ae540e05e07b5111 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/EnsureExceptionHandling.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/EnsureExceptionHandling.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverter.java index ad6b947b978619c36f76fb6a09c9ab7d0f329667..d3f9984958137c52ec84f361d3d65dba6b0ef7d7 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/FileOfCallerConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/FileOfCallerConverter.java index 5af9e9cad0761ba9e6b4316ed95c2a56c72f12b9..740e9f2667773f871d50f2b75dd8e0151947d7c1 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/FileOfCallerConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/FileOfCallerConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LevelConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LevelConverter.java index 05101c325ddc83775ab39490e30da748284bf143..6a63bc63f574c2f70e2ce97d218fbd646cc0c943 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LevelConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LevelConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LineOfCallerConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LineOfCallerConverter.java index 6de5d17ddccaec3276bfb124cd99cadce6cdfff8..8f40a620cbf85d70e3784afc9ab994413b8ba2c7 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LineOfCallerConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LineOfCallerConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LineSeparatorConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LineSeparatorConverter.java index 1840cd7d594e78c4aeb12c6827a434698e2b00e6..139d963524f64deeaaad66808ca01ac4f6aa30bd 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LineSeparatorConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LineSeparatorConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LocalSequenceNumberConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LocalSequenceNumberConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..b4d5fe2ae2adf521911eec7f39a3e07d28f00051 --- /dev/null +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LocalSequenceNumberConverter.java @@ -0,0 +1,36 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package ch.qos.logback.classic.pattern; + +import ch.qos.logback.classic.spi.ILoggingEvent; +import java.util.concurrent.atomic.AtomicLong; + +/** + * A converters based on a a locally incremented sequence number. The sequence number is + * initialized to the number of milliseconds elapsed since 1970-01-01 until this instance + * is initialized. + * + *

+ * EXPERIMENTAL This class is experimental and may be removed in the future. + * + */ +public class LocalSequenceNumberConverter extends ClassicConverter { + + AtomicLong sequenceNumber = new AtomicLong(System.currentTimeMillis()); + + @Override + public String convert(ILoggingEvent event) { + return Long.toString(sequenceNumber.getAndIncrement()); + } +} diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LoggerConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LoggerConverter.java index 6d5b19b698382a8dce3b78dcfd009fb58b342837..2adc2abf16990ae33329aaca2a096285d7c1470b 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LoggerConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/LoggerConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MDCConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MDCConverter.java index e97ceb3b774c2c2f26b2b13f4b545b54f6fc4ac0..08b2b591be29b12466762e0ddea70cbbe8e0de3d 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MDCConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MDCConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,20 +13,24 @@ */ package ch.qos.logback.classic.pattern; -import java.util.Iterator; +import ch.qos.logback.classic.spi.ILoggingEvent; + import java.util.Map; -import java.util.Set; -import ch.qos.logback.classic.spi.ILoggingEvent; +import static ch.qos.logback.core.util.OptionHelper.extractDefaultReplacement; public class MDCConverter extends ClassicConverter { - String key; - private static final String EMPTY_STRING = ""; + private String key; + private String defaultValue = ""; @Override public void start() { - key = getFirstOption(); + String[] keyInfo = extractDefaultReplacement(getFirstOption()); + key = keyInfo[0]; + if (keyInfo[1] != null) { + defaultValue = keyInfo[1]; + } super.start(); } @@ -41,7 +45,7 @@ public class MDCConverter extends ClassicConverter { Map mdcPropertyMap = event.getMDCPropertyMap(); if (mdcPropertyMap == null) { - return EMPTY_STRING; + return defaultValue; } if (key == null) { @@ -52,7 +56,7 @@ public class MDCConverter extends ClassicConverter { if (value != null) { return value; } else { - return EMPTY_STRING; + return defaultValue; } } } @@ -60,7 +64,6 @@ public class MDCConverter extends ClassicConverter { /** * if no key is specified, return all the values present in the MDC, in the format "k1=v1, k2=v2, ..." */ - private String outputMDCForAllKeys(Map mdcPropertyMap) { StringBuilder buf = new StringBuilder(); boolean first = true; diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MarkerConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MarkerConverter.java index ffe89045f7292ce926a0c130767d7ce0fe982b00..739e6c09c61c3683d72197e6d2eb6a2644689ed2 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MarkerConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MarkerConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MessageConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MessageConverter.java index 77dac6eb75ebd4d0ff0a999c2d43336b79eb563e..b89e4f0ef88f73805756b6759d7d3e35e5524f25 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MessageConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MessageConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MethodOfCallerConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MethodOfCallerConverter.java index 736c8fb43c5337056fa9dd8de0025db31b96b9cf..b40674b99de0ef1f2b9796d2cb1455042857cda2 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MethodOfCallerConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MethodOfCallerConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/NamedConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/NamedConverter.java index e7f5140ab7c7303961568c7188f08a96a601ef23..bad8a1d07751feb1f250c51e6c1dff9ca8508d6d 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/NamedConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/NamedConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/NopThrowableInformationConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/NopThrowableInformationConverter.java index 23d62f5aa7e74c6db776ed0956f6b59b4ad1b10b..be8dadeff3013d7a89c81eadcc68cb0d53599bba 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/NopThrowableInformationConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/NopThrowableInformationConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/PropertyConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/PropertyConverter.java index a38824b282b919e79d46c2d4e14fb327633a7276..f70b0984d8211402af6f99950eea62a2a4573dff 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/PropertyConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/PropertyConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/RelativeTimeConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/RelativeTimeConverter.java index 2de704a01f7dc99d52286db9f37aeb6d5cc95e7d..ef43dc08402f31c9f67df0fec9b3ecca5d8c7c40 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/RelativeTimeConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/RelativeTimeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/RootCauseFirstThrowableProxyConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/RootCauseFirstThrowableProxyConverter.java index 804f6f96f1522251df01b85965545994b27ac6ae..cd8c29bb3f48e451f784d1231fc648e19c681031 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/RootCauseFirstThrowableProxyConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/RootCauseFirstThrowableProxyConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/SyslogStartConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/SyslogStartConverter.java index 1b0ce8362cf588f2ba29b1bb58a7a401f266a6c1..479b6c1609f6e805ae41b973ee44b3440333debb 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/SyslogStartConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/SyslogStartConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviator.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviator.java index b4a8dd8761fed4e33bb9f9d6b87d544a65e6f685..7a8ee244a03971dbbcce74a6f2c6c256ec2fb4eb 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThreadConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThreadConverter.java index d95338a1f78235e9aa8ed46c2c9d67bb60cfa0e3..c852e85ce9fa1b5809d5587c31226e8d8c26f5fa 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThreadConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThreadConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableHandlingConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableHandlingConverter.java index cd1aa42c1183c85f14d00cf32af688c835fad0cf..5642711742f12296612850dbe9e2d5de69c0e0d5 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableHandlingConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableHandlingConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableProxyConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableProxyConverter.java index d8decc33218697c943e0275466d49dc69c78f808..a981ebf1cc8cc38d999b281ba4d03f627690f71b 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableProxyConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableProxyConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -51,11 +51,10 @@ public class ThrowableProxyConverter extends ThrowableHandlingConverter { if ("full".equals(lengthStr)) { lengthOption = Integer.MAX_VALUE; } else if ("short".equals(lengthStr)) { - lengthOption = 2; + lengthOption = 1; } else { try { - // we add one because, printing starts at offset 1 - lengthOption = Integer.parseInt(lengthStr) + 1; + lengthOption = Integer.parseInt(lengthStr); } catch (NumberFormatException nfe) { addError("Could not parse [" + lengthStr + "] as an integer"); lengthOption = Integer.MAX_VALUE; diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/Util.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/Util.java index 6d0953691261355bdb20232fb2f5a5817cf93efc..f391417c9c3ac66fd847284f992f35b72dcfd90d 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/Util.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/Util.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/color/HighlightingCompositeConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/color/HighlightingCompositeConverter.java index 73186f214fd1ee008c89efe48e3247f6779ed801..c5e333869df39f25afb05f450b3d895eaf0f30eb 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/color/HighlightingCompositeConverter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/color/HighlightingCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java b/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java index 5274f2ad87eff1329cda68dcd93240f52523d75d..936feea90dd24c73e60867f2180f33fa3fd0c234 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextSelector.java b/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextSelector.java index 41c419ce085a995b03f5ca1bc59f982326ab6a98..f5a8aa1588aad371b8ec8af4ba1aa42c9dc44948 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextSelector.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextSelector.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/selector/DefaultContextSelector.java b/logback-classic/src/main/java/ch/qos/logback/classic/selector/DefaultContextSelector.java index ddc402356abbd5fabdecaa46d5c71dbd5d34bca1..ca3e4e73340d3717a4a9f637344318d40638b579 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/selector/DefaultContextSelector.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/selector/DefaultContextSelector.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java b/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java index 37b5098e2ea602c7d1cfa822956a1ebf20070151..0c0a65677792d3b4c8bb7c3350944d5a6809649a 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -42,6 +42,10 @@ public class ContextDetachingSCL implements ServletContextListener { System.out.println("About to detach context named " + loggerContextName); ContextSelector selector = ContextSelectorStaticBinder.getSingleton().getContextSelector(); + if(selector == null) { + System.out.println("Selector is null, cannot detach context. Skipping."); + return; + } LoggerContext context = selector.detachLoggerContext(loggerContextName); if (context != null) { Logger logger = context.getLogger(Logger.ROOT_LOGGER_NAME); diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/LoggerContextFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/LoggerContextFilter.java index 832b889f9ec2bee0315fa16b753074b49cf25ac8..85bc38ec5e4403366206b09d0228726041bf5012 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/LoggerContextFilter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/LoggerContextFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/sift/AppenderFactory.java b/logback-classic/src/main/java/ch/qos/logback/classic/sift/AppenderFactoryUsingJoran.java similarity index 65% rename from logback-classic/src/main/java/ch/qos/logback/classic/sift/AppenderFactory.java rename to logback-classic/src/main/java/ch/qos/logback/classic/sift/AppenderFactoryUsingJoran.java index ae019bedbe02c7b8a0454ce00694781c7bbee048..98de9ba2b5953056b429aabac72aa019310a7852 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/sift/AppenderFactory.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/sift/AppenderFactoryUsingJoran.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -14,23 +14,25 @@ package ch.qos.logback.classic.sift; import java.util.List; +import java.util.Map; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.joran.event.SaxEvent; -import ch.qos.logback.core.sift.AppenderFactoryBase; +import ch.qos.logback.core.sift.AbstractAppenderFactoryUsingJoran; import ch.qos.logback.core.sift.SiftingJoranConfiguratorBase; -public class AppenderFactory extends AppenderFactoryBase{ +/** + * + */ +public class AppenderFactoryUsingJoran extends AbstractAppenderFactoryUsingJoran { + - String key; - - AppenderFactory(List eventList, String key) { - super(eventList); - this.key = key; + AppenderFactoryUsingJoran(List eventList, String key, Map parentPropertyMap) { + super(eventList, key, parentPropertyMap); } public SiftingJoranConfiguratorBase getSiftingJoranConfigurator(String discriminatingValue) { - return new SiftingJoranConfigurator(key, discriminatingValue); + return new SiftingJoranConfigurator(key, discriminatingValue, parentPropertyMap); } } diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/sift/ContextBasedDiscriminator.java b/logback-classic/src/main/java/ch/qos/logback/classic/sift/ContextBasedDiscriminator.java index 619fb3f7a4d9bb79cdd246a022dd5014c7ff8067..db13f31e7cf031a1e0936d2c5c3deb7947eac9d2 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/sift/ContextBasedDiscriminator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/sift/ContextBasedDiscriminator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -14,8 +14,7 @@ package ch.qos.logback.classic.sift; import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.sift.Discriminator; -import ch.qos.logback.core.spi.ContextAwareBase; +import ch.qos.logback.core.sift.AbstractDiscriminator; /** * This discriminator returns the value context to which this event is attached @@ -27,12 +26,10 @@ import ch.qos.logback.core.spi.ContextAwareBase; * @author Ceki Gülcü * */ -public class ContextBasedDiscriminator extends ContextAwareBase implements - Discriminator { +public class ContextBasedDiscriminator extends AbstractDiscriminator { private static final String KEY = "contextName"; private String defaultValue; - private boolean started = false; /** * Return the name of the current context name as found in the logging event. @@ -47,18 +44,6 @@ public class ContextBasedDiscriminator extends ContextAwareBase implements } } - public boolean isStarted() { - return started; - } - - public void start() { - started = true; - } - - public void stop() { - started = false; - } - public String getKey() { return KEY; } diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/sift/JNDIBasedContextDiscriminator.java b/logback-classic/src/main/java/ch/qos/logback/classic/sift/JNDIBasedContextDiscriminator.java index 39375ca0a7c1e1d3481d9e91a12e10e336afa952..5c6bfb166b1865213900d3132cffdb5d1b5cf17e 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/sift/JNDIBasedContextDiscriminator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/sift/JNDIBasedContextDiscriminator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -17,8 +17,7 @@ import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.selector.ContextSelector; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.util.ContextSelectorStaticBinder; -import ch.qos.logback.core.sift.Discriminator; -import ch.qos.logback.core.spi.ContextAwareBase; +import ch.qos.logback.core.sift.AbstractDiscriminator; /** * This discriminator returns the value context as determined by JNDI. If the @@ -30,12 +29,10 @@ import ch.qos.logback.core.spi.ContextAwareBase; * @author Ceki Gülcü * */ -public class JNDIBasedContextDiscriminator extends ContextAwareBase implements - Discriminator { +public class JNDIBasedContextDiscriminator extends AbstractDiscriminator { private static final String KEY = "contextName"; private String defaultValue; - private boolean started = false; /** * Return the name of the current context name as found in the logging event. @@ -56,18 +53,6 @@ public class JNDIBasedContextDiscriminator extends ContextAwareBase implements return lc.getName(); } - public boolean isStarted() { - return started; - } - - public void start() { - started = true; - } - - public void stop() { - started = false; - } - public String getKey() { return KEY; } diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/sift/MDCBasedDiscriminator.java b/logback-classic/src/main/java/ch/qos/logback/classic/sift/MDCBasedDiscriminator.java index 7e15f5bfa37b6b0e5bcf13c0dee9ced7d9258e82..65447afdbc2694d0beeeee539633fa608c9da64f 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/sift/MDCBasedDiscriminator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/sift/MDCBasedDiscriminator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -14,8 +14,7 @@ package ch.qos.logback.classic.sift; import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.sift.Discriminator; -import ch.qos.logback.core.spi.ContextAwareBase; +import ch.qos.logback.core.sift.AbstractDiscriminator; import ch.qos.logback.core.util.OptionHelper; import java.util.Map; @@ -28,12 +27,10 @@ import java.util.Map; * * @author Ceki Gülcü */ -public class MDCBasedDiscriminator extends ContextAwareBase implements - Discriminator { +public class MDCBasedDiscriminator extends AbstractDiscriminator { private String key; private String defaultValue; - private boolean started = false; /** * Return the value associated with an MDC entry designated by the Key @@ -54,10 +51,7 @@ public class MDCBasedDiscriminator extends ContextAwareBase implements } } - public boolean isStarted() { - return started; - } - + @Override public void start() { int errors = 0; if (OptionHelper.isEmpty(key)) { @@ -73,10 +67,6 @@ public class MDCBasedDiscriminator extends ContextAwareBase implements } } - public void stop() { - started = false; - } - public String getKey() { return key; } diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftAction.java index e57f4b7940c4930767e86647e4a13855240e09fd..764722e63e2f12b7dc3d524a29239f3417aa82f1 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftAction.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -15,6 +15,7 @@ package ch.qos.logback.classic.sift; import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.xml.sax.Attributes; @@ -40,8 +41,9 @@ public class SiftAction extends Action implements InPlayListener { Object o = ic.peekObject(); if (o instanceof SiftingAppender) { SiftingAppender sa = (SiftingAppender) o; - AppenderFactory appenderFactory = new AppenderFactory(seList, sa - .getDiscriminatorKey()); + Map propertyMap = ic.getCopyOfPropertyMap(); + AppenderFactoryUsingJoran appenderFactory = new AppenderFactoryUsingJoran(seList, sa + .getDiscriminatorKey(), propertyMap); sa.setAppenderFactory(appenderFactory); } } diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingAppender.java b/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingAppender.java index 98fcd63f0c99704a3ee717be3daee2e3a4233e9c..b5cf0e114059b0e0b590a06bfae2b41f80a91a48 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingAppender.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,10 +13,12 @@ */ package ch.qos.logback.classic.sift; +import ch.qos.logback.classic.ClassicConstants; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.joran.spi.DefaultClass; import ch.qos.logback.core.sift.Discriminator; import ch.qos.logback.core.sift.SiftingAppenderBase; +import org.slf4j.Marker; /** * This appender can contains other appenders which it can build dynamically @@ -42,4 +44,11 @@ public class SiftingAppender extends SiftingAppenderBase { super.setDiscriminator(discriminator); } + protected boolean eventMarksEndOfLife(ILoggingEvent event) { + Marker marker = event.getMarker(); + if(marker == null) + return false; + + return marker.contains(ClassicConstants.FINALIZE_SESSION_MARKER); + } } diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingJoranConfigurator.java b/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingJoranConfigurator.java index 481cc1089842d3fe281ac4ca687253a03a44ba8b..367f380d313306ed55f88ce23bfb7f091ea8bbfe 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingJoranConfigurator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingJoranConfigurator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -23,28 +23,27 @@ import ch.qos.logback.core.Appender; import ch.qos.logback.core.joran.action.ActionConst; import ch.qos.logback.core.joran.action.AppenderAction; import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry; -import ch.qos.logback.core.joran.spi.Pattern; +import ch.qos.logback.core.joran.spi.ElementPath; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.joran.spi.RuleStore; import ch.qos.logback.core.sift.SiftingJoranConfiguratorBase; public class SiftingJoranConfigurator extends SiftingJoranConfiguratorBase { - String key; - String value; - - SiftingJoranConfigurator(String key, String value) { - this.key = key; - this.value = value; + + SiftingJoranConfigurator(String key, String value, Map parentPropertyMap) { + super(key, value, parentPropertyMap); } @Override - protected Pattern initialPattern() { - return new Pattern("configuration"); + protected ElementPath initialElementPath() { + return new ElementPath("configuration"); } @Override protected void addInstanceRules(RuleStore rs) { - rs.addRule(new Pattern("configuration/appender"), new AppenderAction()); + super.addInstanceRules(rs); + rs.addRule(new ElementSelector("configuration/appender"), new AppenderAction()); } @@ -61,6 +60,7 @@ public class SiftingJoranConfigurator extends SiftingJoranConfiguratorBase propertiesMap = new HashMap(); + propertiesMap.putAll(parentPropertyMap); propertiesMap.put(key, value); interpreter.setInterpretationContextPropertiesMap(propertiesMap); } diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/CallerData.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/CallerData.java index aac922652eea6a80da029db91a660d52d5ae4e44..bf9fa62265661c69d57ce8eb00f7724c46d87c22 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/CallerData.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/CallerData.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ClassPackagingData.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ClassPackagingData.java index 7e447070c9742a2003d69ec746370a078e0f601f..eb712b7818d01b8c60d65da9835a2448e2e618dc 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ClassPackagingData.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ClassPackagingData.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/EventArgUtil.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/EventArgUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..5b33c0d4b1f99dea591e30baa47580fb3cf34c77 --- /dev/null +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/EventArgUtil.java @@ -0,0 +1,54 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package ch.qos.logback.classic.spi; + +public class EventArgUtil { + + + public static final Throwable extractThrowable(Object[] argArray) { + if (argArray == null || argArray.length == 0) { + return null; + } + + final Object lastEntry = argArray[argArray.length - 1]; + if (lastEntry instanceof Throwable) { + return (Throwable) lastEntry; + } + return null; + } + + /** + * This method should be called only if {@link #successfulExtraction(Throwable)} returns true. + * + * @param argArray + * @return + */ + public static Object[] trimmedCopy(Object[] argArray) { + if (argArray == null || argArray.length == 0) { + throw new IllegalStateException("non-sensical empty or null argument array"); + } + final int trimemdLen = argArray.length - 1; + Object[] trimmed = new Object[trimemdLen]; + System.arraycopy(argArray, 0, trimmed, 0, trimemdLen); + return trimmed; + } + + public static Object[] arrangeArguments(Object[] argArray) { + return argArray; + } + + public static boolean successfulExtraction(Throwable throwable) { + return throwable != null; + } +} diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ILoggingEvent.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ILoggingEvent.java index 1abeff744e2cd87295b4c19ad661902a8a81885c..cb97aab213fdc58d9fc14e29534a9bef9b551a7b 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ILoggingEvent.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ILoggingEvent.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/IThrowableProxy.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/IThrowableProxy.java index 8e841c8f430c2f5d51be43c401a34d120b67695f..27573c5e65c8bdc0c5780569973929e8ea00a6b2 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/IThrowableProxy.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/IThrowableProxy.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerComparator.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerComparator.java index a58a26dfbb25b56de6dc3e893fedf7e9f0ebf358..0f1b3fa2ece24a9cd92b078c6a2349b20c73e701 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerComparator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerComparator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextAware.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextAware.java index ae9ad6fd78d73b0ddaf95cc2c9925f7373e7cb13..c4c289fe08919a1fe9ac03159a7c61106b6c5c19 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextAware.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextAware.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextAwareBase.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextAwareBase.java index 30b27240ee57db7fed854b83f48f6095542b8eb4..a335a4428322d25c350d6e560004b1c9565f4ed0 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextAwareBase.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextAwareBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextListener.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextListener.java index c210ad0acc842f8a23619c672f7daf815ec374c8..5a5279a26631fd6d3eba9eb5a32f8935d8fd48fe 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextListener.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextListener.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextVO.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextVO.java index ebc4799ba5230c8685028badaa601abba6f44292..022b7892572041c94240877db8a4ed31c8b9ca07 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextVO.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerContextVO.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerRemoteView.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerRemoteView.java index 45bef0e9110ea37077c9c824a9d0b253f0734035..7e264cc59887f8bd6bcaab536cc68e595460ce77 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerRemoteView.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerRemoteView.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java old mode 100644 new mode 100755 index 25fe3808658d10846090032deeee630c41af3b81..73ed8230529b08fcca7468ca151156a93d74253d --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -80,7 +80,7 @@ public class LoggingEvent implements ILoggingEvent { // we gain significant space at serialization time by marking // formattedMessage as transient and constructing it lazily in // getFormattedMessage() - private transient String formattedMessage; + transient String formattedMessage; private transient Object[] argumentArray; @@ -111,15 +111,10 @@ public class LoggingEvent implements ILoggingEvent { this.level = level; this.message = message; + this.argumentArray = argArray; - FormattingTuple ft = MessageFormatter.arrayFormat(message, argArray); - formattedMessage = ft.getMessage(); - - if (throwable == null) { - argumentArray = ft.getArgArray(); - throwable = ft.getThrowable(); - } else { - this.argumentArray = argArray; + if(throwable == null) { + throwable = extractThrowableAnRearrangeArguments(argArray); } if (throwable != null) { @@ -133,6 +128,14 @@ public class LoggingEvent implements ILoggingEvent { timeStamp = System.currentTimeMillis(); } + private Throwable extractThrowableAnRearrangeArguments(Object[] argArray) { + Throwable extractedThrowable = EventArgUtil.extractThrowable(argArray); + if(EventArgUtil.successfulExtraction(extractedThrowable)) { + this.argumentArray = EventArgUtil.trimmedCopy(argArray); + } + return extractedThrowable; + } + public void setArgumentArray(Object[] argArray) { if (this.argumentArray != null) { throw new IllegalStateException("argArray has been already set"); @@ -286,8 +289,7 @@ public class LoggingEvent implements ILoggingEvent { return loggerContextVO.getBirthTime(); } - // computer formatted lazy as suggested in - // http://jira.qos.ch/browse/LBCLASSIC-47 + // lazy computation as suggested in LOGBACK-495 public String getFormattedMessage() { if (formattedMessage != null) { return formattedMessage; @@ -353,7 +355,7 @@ public class LoggingEvent implements ILoggingEvent { /** * LoggerEventVO instances should be used for serialization. Use - * {@link LoggingEventVO#build(LoggingEvent) build} method to create the LoggerEventVO instance. + * {@link LoggingEventVO#build(ILoggingEvent) build} method to create the LoggerEventVO instance. * * @since 1.0.11 */ diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventVO.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventVO.java index 5e2ea32da26b2a91d76871116daddbceaacd5eec..f9a924635508cf881d8137d25783cb8da7cbf840 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventVO.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventVO.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/PackagingDataCalculator.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/PackagingDataCalculator.java index f9fff783827a597d2445ab5501e1170f9c4be84f..4b89ac8f255c4954ba6602747a17005f36251edb 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/PackagingDataCalculator.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/PackagingDataCalculator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -14,6 +14,7 @@ package ch.qos.logback.classic.spi; import java.net.URL; +import java.security.CodeSource; import java.util.HashMap; import sun.reflect.Reflection; @@ -162,15 +163,18 @@ public class PackagingDataCalculator { try { if (type != null) { // file:/C:/java/maven-2.0.8/repo/com/icegreen/greenmail/1.3/greenmail-1.3.jar - URL resource = type.getProtectionDomain().getCodeSource().getLocation(); - if (resource != null) { - String locationStr = resource.toString(); - // now lets remove all but the file name - String result = getCodeLocation(locationStr, '/'); - if (result != null) { - return result; + CodeSource codeSource = type.getProtectionDomain().getCodeSource(); + if (codeSource != null) { + URL resource = codeSource.getLocation(); + if (resource != null) { + String locationStr = resource.toString(); + // now lets remove all but the file name + String result = getCodeLocation(locationStr, '/'); + if (result != null) { + return result; + } + return getCodeLocation(locationStr, '\\'); } - return getCodeLocation(locationStr, '\\'); } } } catch (Exception e) { diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/PlatformInfo.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/PlatformInfo.java index 25f8f16644ecd81200b19498be0a29d1b6f19e7c..4747d059c8c08169bc6c7e817cbf07efa798e301 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/PlatformInfo.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/PlatformInfo.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/STEUtil.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/STEUtil.java index 42d0a83b007475f0e8316a456b4d8359595ab9ed..438ef7e7914613f60fbc7c44cc035a4a00584930 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/STEUtil.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/STEUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/StackTraceElementProxy.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/StackTraceElementProxy.java index b9476f772f92aa8cd86f37ddf1998b350e92a686..c3466db769d47d387ee0b9d6c57bdf292ded6790 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/StackTraceElementProxy.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/StackTraceElementProxy.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java index edb0b9badc64f26b8d9aaed4d035691f30cfbb6a..d289b29239405d2bce2faa5b2b3ac778cda2443a 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyUtil.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyUtil.java index 40950d77ded816438e1e651eb4b81c7d82c4ddcc..9f0d7f9656d4cfbc5515d3e3f94df78f442c66c0 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyUtil.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyVO.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyVO.java index 45b3f7dadf86c1c2ca68426bca323e906ab044dc..9b5fda5ae8c38ab55e2eac8971faea1f4bf9b497 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyVO.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyVO.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/TurboFilterList.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/TurboFilterList.java index df1de73fa10841a40c546bb386e3a46d89b459bd..f1837af0c161e8d430f8c4af75ff5e8bb607793e 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/TurboFilterList.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/TurboFilterList.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/DuplicateMessageFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/DuplicateMessageFilter.java index a2c15fabd0d1c55d2d967aaea752868890b8c1a3..77c349f0bf11e4ef81c966b9dbcc705445aafccc 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/DuplicateMessageFilter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/DuplicateMessageFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/DynamicThresholdFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/DynamicThresholdFilter.java index 9729d5f67de9c239ff2878491e9eecb5986fd8ec..f06c7a27aeeeb80b9ac0fc4f2f790a2435f16edc 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/DynamicThresholdFilter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/DynamicThresholdFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/LRUMessageCache.java b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/LRUMessageCache.java index 46e74cd4dc50056224490783b85654eadbb090e2..d1923e6ed62e005598a471fb13a8ffa13ebea26a 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/LRUMessageCache.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/LRUMessageCache.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MDCFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MDCFilter.java index 5e00e1c38ac881e30093e1f32295dddcf429cc3b..7cfd922f9e4ce523d065d70a87a01d8a6d69be6b 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MDCFilter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MDCFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MDCValueLevelPair.java b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MDCValueLevelPair.java index bd9372047b451b457c117209103b7f60c5062abf..e227f0835d5f9c6b2cfb6247fa364ab364e9d8f6 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MDCValueLevelPair.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MDCValueLevelPair.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MarkerFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MarkerFilter.java index ca84d34e93a7d21999ba332c427942ec86c9bba5..c71cf3677c0cb3eecead36418d677f6273ef586b 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MarkerFilter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MarkerFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MatchingFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MatchingFilter.java index 806453939af9a96f9d43e505f4fd0fc462087782..7e7fa55a6dd0e26bbd9672e6e4cf7e065944e12b 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MatchingFilter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/MatchingFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java index 02af906378b5a033d908c4fca5a9a8723f469ad8..f8e0d29034949c7c901506c076e2655e4f3d3eb8 100755 --- a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/TurboFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/TurboFilter.java index e32c802702b456a41767b87e5318ae402f879f72..31d76a2fe5932b578e3c672cf9878bf32b54d957 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/TurboFilter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/TurboFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java index a579ead4086353efeac34ba26d281ce5c61b35dc..502f6525090c186a4f8797cd7249aa748db0a263 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextSelectorStaticBinder.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextSelectorStaticBinder.java index 5c1175783643b7da5668e2f44679fb7dfae12307..56a2aa630bb3047b0d0182cacf7eb88d6558afef 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextSelectorStaticBinder.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextSelectorStaticBinder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/CopyOnInheritThreadLocal.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/CopyOnInheritThreadLocal.java index 689195d0a094490a4a5bc42d583356586f1176df..fd456e8bdcccdd714f16f0a6813d5ebade258436 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/util/CopyOnInheritThreadLocal.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/CopyOnInheritThreadLocal.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/DefaultNestedComponentRules.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/DefaultNestedComponentRules.java index e1f2e750dc147fa8b28c6aa8f8fb6b6c47b5865d..01ce7a32739e406295d458b4cc5578ca845ff2aa 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/util/DefaultNestedComponentRules.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/DefaultNestedComponentRules.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -16,15 +16,10 @@ package ch.qos.logback.classic.util; import ch.qos.logback.classic.PatternLayout; import ch.qos.logback.classic.boolex.JaninoEventEvaluator; import ch.qos.logback.classic.encoder.PatternLayoutEncoder; -import ch.qos.logback.classic.net.SSLSocketAppender; -import ch.qos.logback.classic.net.SSLSocketRemote; -import ch.qos.logback.classic.net.server.SSLServerSocketAppender; -import ch.qos.logback.classic.net.server.SocketServerNestedComponentRegistryRules; import ch.qos.logback.core.AppenderBase; import ch.qos.logback.core.UnsynchronizedAppenderBase; import ch.qos.logback.core.filter.EvaluatorFilter; import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry; -import ch.qos.logback.core.net.ssl.SSLConfiguration; import ch.qos.logback.core.net.ssl.SSLNestedComponentRegistryRules; /** @@ -47,11 +42,7 @@ public class DefaultNestedComponentRules { registry .add(EvaluatorFilter.class, "evaluator", JaninoEventEvaluator.class); - registry.add(SSLSocketAppender.class, "ssl", SSLConfiguration.class); - registry.add(SSLSocketRemote.class, "ssl", SSLConfiguration.class); - registry.add(SSLServerSocketAppender.class, "ssl", SSLConfiguration.class); SSLNestedComponentRegistryRules.addDefaultNestedComponentRegistryRules(registry); - SocketServerNestedComponentRegistryRules.addDefaultNestedComponentRegistryRules(registry); } } diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/EnvUtil.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/EnvUtil.java index 4bec238cfc49bdefdb96eb932589b2acf646c5de..49af99af8ee00c1a713d7ed8792405cce3214eee 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/util/EnvUtil.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/EnvUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/JNDIUtil.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/JNDIUtil.java index da8b6e6566423996d5fc694fb27252c87fd2ced0..75acc3c43495444e951c45d0dfe191087706619c 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/util/JNDIUtil.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/JNDIUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -35,9 +35,10 @@ public class JNDIUtil { return null; } try { - return (String) ctx.lookup(name); + Object lookup = ctx.lookup(name); + return lookup == null ? null : lookup.toString(); } catch (NamingException e) { return null; } } -} \ No newline at end of file +} diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/LevelToSyslogSeverity.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/LevelToSyslogSeverity.java index 05df1efb71a07e669010f67a50c8ad43f023b5dc..5652d9bc2d2d176b8f5bfab57ea80445549da134 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/util/LevelToSyslogSeverity.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/LevelToSyslogSeverity.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/LogbackMDCAdapter.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/LogbackMDCAdapter.java index 7b752d1a9a4ca52b75d08be97caca75941747044..c467590e3f0d795723acf9e49f47ad62eca9df72 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/util/LogbackMDCAdapter.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/LogbackMDCAdapter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerNameUtil.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerNameUtil.java index 29273b4ace97791cb7b1e6044f5ac6b23be57939..7f70179a8e10dd11d07b3d8840c7df4f81505ebc 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerNameUtil.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerNameUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.classic.util; import ch.qos.logback.core.CoreConstants; @@ -38,12 +37,14 @@ public class LoggerNameUtil { * @return */ public static int getSeparatorIndexOf(String name, int fromIndex) { - int i = name.indexOf(CoreConstants.DOT, fromIndex); - if (i != -1) { - return i; - } else { - return name.indexOf(CoreConstants.DOLLAR, fromIndex); - } + int dotIndex = name.indexOf(CoreConstants.DOT, fromIndex); + int dollarIndex = name.indexOf(CoreConstants.DOLLAR, fromIndex); + + if (dotIndex == -1 && dollarIndex == -1) return -1; + if (dotIndex == -1) return dollarIndex; + if (dollarIndex == -1) return dotIndex; + + return dotIndex < dollarIndex ? dotIndex : dollarIndex; } public static List computeNameParts(String loggerName) { diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/StatusListenerConfigHelper.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/StatusListenerConfigHelper.java index 7296244840122225f5e975acaf627d0b3bb0fc70..42737ffdb99cb6afcb3dd627d3020784f4f7220f 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/util/StatusListenerConfigHelper.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/StatusListenerConfigHelper.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -30,26 +30,35 @@ public class StatusListenerConfigHelper { } } - static void addStatusListener(LoggerContext loggerContext, + private static void addStatusListener(LoggerContext loggerContext, String listenerClass) { StatusListener listener = null; if (ContextInitializer.SYSOUT.equalsIgnoreCase(listenerClass)) { listener = new OnConsoleStatusListener(); } else { - try { - listener = (StatusListener) OptionHelper.instantiateByClassName( - listenerClass, StatusListener.class, loggerContext); - if(listener instanceof ContextAware) // LOGBACK-767 - ((ContextAware) listener).setContext(loggerContext); - if(listener instanceof LifeCycle) // LOGBACK-767 - ((LifeCycle) listener).start(); - } catch (Exception e) { - // printing on the console is the best we can do - e.printStackTrace(); - } + listener = createListenerPerClassName(loggerContext, listenerClass); } + initListener(loggerContext, listener); + } + + private static void initListener(LoggerContext loggerContext, StatusListener listener) { if (listener != null) { + if(listener instanceof ContextAware) // LOGBACK-767 + ((ContextAware) listener).setContext(loggerContext); + if(listener instanceof LifeCycle) // LOGBACK-767 + ((LifeCycle) listener).start(); loggerContext.getStatusManager().add(listener); } } + + private static StatusListener createListenerPerClassName(LoggerContext loggerContext, String listenerClass) { + try { + return (StatusListener) OptionHelper.instantiateByClassName( + listenerClass, StatusListener.class, loggerContext); + } catch (Exception e) { + // printing on the console is the best we can do + e.printStackTrace(); + return null; + } + } } diff --git a/logback-classic/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/logback-classic/src/main/java/org/slf4j/impl/StaticLoggerBinder.java index c6fd6344d10a4344dca01ce094293e3e27268834..975c7de1dcb1adb22cf8515273a8713d1e99f0a0 100644 --- a/logback-classic/src/main/java/org/slf4j/impl/StaticLoggerBinder.java +++ b/logback-classic/src/main/java/org/slf4j/impl/StaticLoggerBinder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/org/slf4j/impl/StaticMDCBinder.java b/logback-classic/src/main/java/org/slf4j/impl/StaticMDCBinder.java index f83af57c1d3d949f701cf9468e97645f330a0753..f0cd2f8cbc1ace17e26507ce8f83866c287cb06c 100644 --- a/logback-classic/src/main/java/org/slf4j/impl/StaticMDCBinder.java +++ b/logback-classic/src/main/java/org/slf4j/impl/StaticMDCBinder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/main/java/org/slf4j/impl/StaticMarkerBinder.java b/logback-classic/src/main/java/org/slf4j/impl/StaticMarkerBinder.java index d2c4e64f6c0b1b3a9beea1b8bab155b6bb2fe65a..4cd8b8a4ebfc324660363ea73ab831e07a0255c9 100644 --- a/logback-classic/src/main/java/org/slf4j/impl/StaticMarkerBinder.java +++ b/logback-classic/src/main/java/org/slf4j/impl/StaticMarkerBinder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/GafferConfiguratorTest.groovy b/logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/GafferConfiguratorTest.groovy index 6f66c90f7c5b1be76ad426d374f194525f5d5954..78fd0ed62933e3ce0a3de8380c342b8d599551b1 100644 --- a/logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/GafferConfiguratorTest.groovy +++ b/logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/GafferConfiguratorTest.groovy @@ -17,6 +17,7 @@ import ch.qos.logback.classic.ClassicTestConstants import ch.qos.logback.classic.LoggerContext import org.junit.Before import ch.qos.logback.core.testUtil.RandomUtil +import org.junit.Ignore import org.junit.Test import ch.qos.logback.classic.Logger import ch.qos.logback.classic.Level @@ -39,122 +40,133 @@ import static org.junit.Assert.assertTrue */ class GafferConfiguratorTest { - LoggerContext context = new LoggerContext(); - Logger root = context.getLogger(Logger.ROOT_LOGGER_NAME) - Logger logger = context.getLogger(this.getClass()) - int diff = RandomUtil.getPositiveInt(); - GafferConfigurator configurator = new GafferConfigurator(context); - - @Before - void setUp() { - - } - - @Test - void smoke() { - File file = new File(ClassicTestConstants.GAFFER_INPUT_PREFIX + "smoke.groovy") - String dslText = file.text - configurator.run dslText - Logger root = context.getLogger(Logger.ROOT_LOGGER_NAME); - assertEquals(Level.WARN, root.level) - assertNotNull(root.getAppender("C")) - ConsoleAppender ca = root.getAppender("C") - assertNotNull(ca.encoder) - assertNotNull(ca.encoder.layout) - PatternLayout layout = ca.encoder.layout - assertEquals("%m%n", layout.pattern) - } - - @Test - void onTheFly() { - File file = new File(ClassicTestConstants.GAFFER_INPUT_PREFIX + "onTheFly.groovy") - String dslText = file.text - configurator.run dslText - } - - @Test - void contextName() { - String dslText = "context.name = 'a'" - configurator.run dslText - assertEquals("a", context.name) - } - - @Test - void contextProperty() { - String dslText = "context.putProperty('x', 'a')" - configurator.run dslText - assertEquals("a", context.getProperty("x")) - } - - @Test - void conversionRule() { - File file = new File(ClassicTestConstants.GAFFER_INPUT_PREFIX + "conversionRule.groovy") - String dslText = file.text - configurator.run dslText - - StringListAppender sla = (StringListAppender) root.getAppender("LIST"); - assertNotNull(sla); - assertEquals(0, sla.strList.size()); - - assertEquals(Level.DEBUG, root.level); - - String msg = "Simon says"; - logger.debug(msg); - StatusPrinter.print context - assertEquals(1, sla.strList.size()); - assertEquals(SampleConverter.SAMPLE_STR + " - " + msg, sla.strList.get(0)); - } - - @Test - void evaluatorWithMatcher() { - File file = new File(ClassicTestConstants.GAFFER_INPUT_PREFIX + "evaluatorWithMatcher.groovy") - String dslText = file.text - configurator.run dslText - - ConsoleAppender ca = (ConsoleAppender) root.getAppender("STDOUT"); - assertTrue ca.isStarted() - - EvaluatorFilter ef = ca.getCopyOfAttachedFiltersList()[0]; - assertTrue ef.isStarted() - - JaninoEventEvaluator jee = ef.evaluator - assertTrue jee.isStarted() - Matcher m = jee.matcherList[0] - assertTrue m.isStarted() - } - - @Test - void propertyCascading0() { - File file = new File(ClassicTestConstants.GAFFER_INPUT_PREFIX + "propertyCascading0.groovy") - String dslText = file.text - configurator.run dslText - - ConsoleAppender ca = (ConsoleAppender) root.getAppender("STDOUT"); - assertTrue ca.isStarted() - - assertEquals("HELLO %m%n", ca.encoder.layout.pattern) - } - - @Test - void propertyCascading1() { - File file = new File(ClassicTestConstants.GAFFER_INPUT_PREFIX + "propertyCascading1.groovy") - String dslText = file.text - configurator.run dslText - - ConsoleAppender ca = (ConsoleAppender) root.getAppender("STDOUT"); - assertTrue ca.isStarted() - assertEquals("HELLO %m%n", ca.encoder.getLayout().pattern) - } - - @Test - void propertyCascading2() { - context.putProperty("p", "HELLO"); - File file = new File(ClassicTestConstants.GAFFER_INPUT_PREFIX + "propertyCascading2.groovy") - String dslText = file.text - configurator.run dslText - - ConsoleAppender ca = (ConsoleAppender) root.getAppender("STDOUT"); - assertTrue ca.isStarted() - assertEquals("HELLO %m%n", ca.encoder.getLayout().pattern) - } + LoggerContext context = new LoggerContext(); + Logger root = context.getLogger(Logger.ROOT_LOGGER_NAME) + Logger logger = context.getLogger(this.getClass()) + int diff = RandomUtil.getPositiveInt(); + GafferConfigurator configurator = new GafferConfigurator(context); + + @Before + void setUp() { + + } + + @Test + void smoke() { + File file = new File(ClassicTestConstants.GAFFER_INPUT_PREFIX + "smoke.groovy") + String dslText = file.text + configurator.run dslText + Logger root = context.getLogger(Logger.ROOT_LOGGER_NAME); + assertEquals(Level.WARN, root.level) + assertNotNull(root.getAppender("C")) + ConsoleAppender ca = root.getAppender("C") + assertNotNull(ca.encoder) + assertNotNull(ca.encoder.layout) + PatternLayout layout = ca.encoder.layout + assertEquals("%m%n", layout.pattern) + } + + @Test + void onTheFly() { + File file = new File(ClassicTestConstants.GAFFER_INPUT_PREFIX + "onTheFly.groovy") + String dslText = file.text + configurator.run dslText + } + + @Test + void contextName() { + String dslText = "context.name = 'a'" + configurator.run dslText + assertEquals("a", context.name) + } + + @Test + void contextProperty() { + String dslText = "context.putProperty('x', 'a')" + configurator.run dslText + assertEquals("a", context.getProperty("x")) + } + + @Test + void conversionRule() { + File file = new File(ClassicTestConstants.GAFFER_INPUT_PREFIX + "conversionRule.groovy") + String dslText = file.text + configurator.run dslText + + StringListAppender sla = (StringListAppender) root.getAppender("LIST"); + assertNotNull(sla); + assertEquals(0, sla.strList.size()); + + assertEquals(Level.DEBUG, root.level); + + String msg = "Simon says"; + logger.debug(msg); + StatusPrinter.print context + assertEquals(1, sla.strList.size()); + assertEquals(SampleConverter.SAMPLE_STR + " - " + msg, sla.strList.get(0)); + } + + @Test + void evaluatorWithMatcher() { + File file = new File(ClassicTestConstants.GAFFER_INPUT_PREFIX + "evaluatorWithMatcher.groovy") + String dslText = file.text + configurator.run dslText + + ConsoleAppender ca = (ConsoleAppender) root.getAppender("STDOUT"); + assertTrue ca.isStarted() + + EvaluatorFilter ef = ca.getCopyOfAttachedFiltersList()[0]; + assertTrue ef.isStarted() + + JaninoEventEvaluator jee = ef.evaluator + assertTrue jee.isStarted() + Matcher m = jee.matcherList[0] + assertTrue m.isStarted() + } + + @Test + void propertyCascading0() { + File file = new File(ClassicTestConstants.GAFFER_INPUT_PREFIX + "propertyCascading0.groovy") + String dslText = file.text + configurator.run dslText + + ConsoleAppender ca = (ConsoleAppender) root.getAppender("STDOUT"); + assertTrue ca.isStarted() + + assertEquals("HELLO %m%n", ca.encoder.layout.pattern) + } + + @Test + void propertyCascading1() { + File file = new File(ClassicTestConstants.GAFFER_INPUT_PREFIX + "propertyCascading1.groovy") + String dslText = file.text + configurator.run dslText + + ConsoleAppender ca = (ConsoleAppender) root.getAppender("STDOUT"); + assertTrue ca.isStarted() + assertEquals("HELLO %m%n", ca.encoder.getLayout().pattern) + } + + @Test + void propertyCascading2() { + context.putProperty("p", "HELLO"); + File file = new File(ClassicTestConstants.GAFFER_INPUT_PREFIX + "propertyCascading2.groovy") + String dslText = file.text + configurator.run dslText + + ConsoleAppender ca = (ConsoleAppender) root.getAppender("STDOUT"); + assertTrue ca.isStarted() + assertEquals("HELLO %m%n", ca.encoder.getLayout().pattern) + } + + + @Test + @Ignore + void receiver() { + File file = new File(ClassicTestConstants.GAFFER_INPUT_PREFIX + "propertyCascading2.groovy") + String dslText = file.text + configurator.run dslText + } + + } diff --git a/logback-classic/src/test/groovy/ch/qos/logback/classic/sift/GSiftingAppenderTest.groovy b/logback-classic/src/test/groovy/ch/qos/logback/classic/sift/GSiftingAppenderTest.groovy deleted file mode 100644 index df62eea1a257ac758a8411a201e630cbc688aa2a..0000000000000000000000000000000000000000 --- a/logback-classic/src/test/groovy/ch/qos/logback/classic/sift/GSiftingAppenderTest.groovy +++ /dev/null @@ -1,111 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2010, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.classic.sift - -import ch.qos.logback.classic.gaffer.GafferConfigurator - -import ch.qos.logback.classic.Logger -import ch.qos.logback.classic.LoggerContext -import ch.qos.logback.core.testUtil.RandomUtil -import org.junit.Test -import ch.qos.logback.classic.ClassicTestConstants -import org.slf4j.MDC -import static junit.framework.Assert.assertNotNull -import ch.qos.logback.core.sift.AppenderTracker -import ch.qos.logback.core.read.ListAppender -import ch.qos.logback.core.util.StatusPrinter -import static junit.framework.Assert.assertEquals -import ch.qos.logback.core.FileAppender -import ch.qos.logback.core.status.StatusChecker -import ch.qos.logback.core.status.Status -import static junit.framework.Assert.assertNull -import org.junit.After -import static ch.qos.logback.classic.ClassicTestConstants.OUTPUT_DIR_PREFIX; - -/** - * @author Ceki Gücü - */ -class GSiftingAppenderTest { - - LoggerContext context = new LoggerContext(); - Logger root = context.getLogger(Logger.ROOT_LOGGER_NAME) - Logger logger = context.getLogger(this.getClass()) - int diff = RandomUtil.getPositiveInt(); - GafferConfigurator configurator = new GafferConfigurator(context); - StatusChecker checker = new StatusChecker(context) - - @After - public void tearDown() { - MDC.clear(); - } - - AppenderTracker execute(String path) { - File file = new File(ClassicTestConstants.GAFFER_INPUT_PREFIX + path) - String dslText = file.text - configurator.run dslText - - GSiftingAppender sa = (GSiftingAppender) root.getAppender("SIFT"); - assertNotNull(sa) - AppenderTracker tracker = sa.getAppenderTracker(); - } - - @Test - void noDiscriminator() { - AppenderTracker tracker = execute("sift/noDiscriminator.groovy") - logger.debug("x") - ListAppender unknownAppender = tracker.get("unknown", System.currentTimeMillis()) - assertNull(unknownAppender) - checker.containsMatch(Status.ERROR, "Missing discriminator. Aborting") - } - - @Test - void sample0() { - AppenderTracker tracker = execute("sift/sample0.groovy") - logger.debug("x") - ListAppender unknownAppender = tracker.get("unknown", System.currentTimeMillis()) - assertNotNull(unknownAppender) - - MDC.put("userid", "a"); - logger.debug("y"); - ListAppender aAppender = tracker.get("a", System.currentTimeMillis()) - assertNotNull(aAppender) - - assertEquals(1, unknownAppender.list.size); - assertEquals("x", unknownAppender.list[0].message) - assertEquals(1, aAppender.list.size); - assertEquals("y", aAppender.list[0].message) - } - - @Test - void sample1() { - AppenderTracker tracker = execute("sift/sample1.groovy") - logger.debug("x") - - StatusPrinter.print context - FileAppender unknownAppender = tracker.get("unknown", System.currentTimeMillis()) - assertNotNull(unknownAppender) - assertEquals("FILE-unknown", unknownAppender.name) - assertEquals(OUTPUT_DIR_PREFIX+"test-unknown.log", unknownAppender.file) - - MDC.put("userid", "a"); - logger.debug("y"); - FileAppender aAppender = tracker.get("a", System.currentTimeMillis()) - assertNotNull(aAppender) - assertEquals("FILE-a", aAppender.name) - assertEquals(OUTPUT_DIR_PREFIX+"test-a.log", aAppender.file) - assertEquals("a - %msg%n", aAppender.encoder.pattern) - } - - -} diff --git a/logback-classic/src/test/input/joran/jul/levelChangePropagator0.xml b/logback-classic/src/test/input/joran/jul/levelChangePropagator0.xml index 6052995d031d451e99bc92a4306de36a8a721ef5..6ecf75e93389ee243b1f8b08ebb81626c305e1d6 100644 --- a/logback-classic/src/test/input/joran/jul/levelChangePropagator0.xml +++ b/logback-classic/src/test/input/joran/jul/levelChangePropagator0.xml @@ -3,7 +3,7 @@ true - + diff --git a/logback-classic/src/test/input/joran/jul/levelChangePropagator1.xml b/logback-classic/src/test/input/joran/jul/levelChangePropagator1.xml index a7f4d4e0f5c1b38c81ce29025d23f6fbac5f0c9a..231e13f84daf4acdb1dfdef6b2169e7bfa8ae310 100644 --- a/logback-classic/src/test/input/joran/jul/levelChangePropagator1.xml +++ b/logback-classic/src/test/input/joran/jul/levelChangePropagator1.xml @@ -1,7 +1,8 @@ - + + diff --git a/logback-classic/src/test/input/joran/sift/compositeProperty.xml b/logback-classic/src/test/input/joran/sift/compositeProperty.xml new file mode 100644 index 0000000000000000000000000000000000000000..37ed96bd51b83340f51cf941627ac719459fd5cb --- /dev/null +++ b/logback-classic/src/test/input/joran/sift/compositeProperty.xml @@ -0,0 +1,27 @@ + + + + + + + + compositeProperty + default + + + + + + + ${Z}%msg + + + + + + + + + + diff --git a/logback-classic/src/test/input/joran/sift/defaultLayoutRule.xml b/logback-classic/src/test/input/joran/sift/defaultLayoutRule.xml index 7e4213d1c80a3f945dd71a0ca8830f75f356143d..b8753ea78ae57940adb13f33b1256af8e30cd178 100644 --- a/logback-classic/src/test/input/joran/sift/defaultLayoutRule.xml +++ b/logback-classic/src/test/input/joran/sift/defaultLayoutRule.xml @@ -1,16 +1,15 @@ - - userid + userid default - %level %msg + %level %msg diff --git a/logback-classic/src/test/input/joran/sift/hoard0.xml b/logback-classic/src/test/input/joran/sift/hoard0.xml index 930f5502cd73758780c1d88f241cb4d40f4ace07..d1673bf921fd68f33b78eb6c8226beea9e011ae8 100644 --- a/logback-classic/src/test/input/joran/sift/hoard0.xml +++ b/logback-classic/src/test/input/joran/sift/hoard0.xml @@ -3,17 +3,16 @@ - + userid asdad - ${userid}.log - true + ${userid}.log + true - %d [%thread] %level %logger{35} - %msg%n + %d [%thread] %level %logger{35} - %msg%n diff --git a/logback-classic/src/test/input/joran/sift/lbclassic203.xml b/logback-classic/src/test/input/joran/sift/lbclassic203.xml index 5db0eb816e864fcd16d393b5807095b2e1219d27..646d6a2441d20cfe3e1eef09ab77d180fbd9863b 100644 --- a/logback-classic/src/test/input/joran/sift/lbclassic203.xml +++ b/logback-classic/src/test/input/joran/sift/lbclassic203.xml @@ -9,7 +9,7 @@ - userid + userid smoke diff --git a/logback-classic/src/test/input/joran/sift/lingering.xml b/logback-classic/src/test/input/joran/sift/lingering.xml new file mode 100644 index 0000000000000000000000000000000000000000..5c53496e159a3e18b84ab58f031488f915af5552 --- /dev/null +++ b/logback-classic/src/test/input/joran/sift/lingering.xml @@ -0,0 +1,22 @@ + + + + + + + + + linger + linger + + + + + + + + + + + diff --git a/logback-classic/src/test/input/joran/sift/maxAppenderCount.xml b/logback-classic/src/test/input/joran/sift/maxAppenderCount.xml new file mode 100644 index 0000000000000000000000000000000000000000..90c5957d4d834a227e2031b89a5f73b901979131 --- /dev/null +++ b/logback-classic/src/test/input/joran/sift/maxAppenderCount.xml @@ -0,0 +1,22 @@ + + + + + + + + max + default + + 5 + + + + + + + + + + \ No newline at end of file diff --git a/logback-classic/src/test/input/joran/sift/multipleNesting.xml b/logback-classic/src/test/input/joran/sift/multipleNesting.xml index 2dccd197c8ac2b2b82c0e6deb82a759ed8b56e46..40d572a0ab28f55704fbd6d71c43d192d2a67066 100644 --- a/logback-classic/src/test/input/joran/sift/multipleNesting.xml +++ b/logback-classic/src/test/input/joran/sift/multipleNesting.xml @@ -6,14 +6,12 @@ - userid - smoke + userid + multipleDefault - - + + diff --git a/logback-classic/src/test/input/joran/sift/propertyDefinedInSiftElement.xml b/logback-classic/src/test/input/joran/sift/propertyDefinedInSiftElement.xml new file mode 100644 index 0000000000000000000000000000000000000000..6a08c63a11cc4ee9b3b598e1e8de320a22704134 --- /dev/null +++ b/logback-classic/src/test/input/joran/sift/propertyDefinedInSiftElement.xml @@ -0,0 +1,24 @@ + + + + + propertyDefinedWithinSift + default + + + + + + + ${X}%msg + + + + + + + + + + diff --git a/logback-classic/src/test/input/joran/sift/propertyPropagation.xml b/logback-classic/src/test/input/joran/sift/propertyPropagation.xml new file mode 100644 index 0000000000000000000000000000000000000000..ab7ff7dae4ce0d94abce4d4a7442b98d1cec8aa2 --- /dev/null +++ b/logback-classic/src/test/input/joran/sift/propertyPropagation.xml @@ -0,0 +1,25 @@ + + + + + + + + localProperty + default + + + + + ${X}%msg + + + + + + + + + + diff --git a/logback-classic/src/test/input/joran/sift/smoke.xml b/logback-classic/src/test/input/joran/sift/smoke.xml index 91e3f565a600fc9dea70ec94b30c2e1fa601fbf5..846fd14a087ee556bb5fdb089327ffd45a5abe27 100644 --- a/logback-classic/src/test/input/joran/sift/smoke.xml +++ b/logback-classic/src/test/input/joran/sift/smoke.xml @@ -6,8 +6,8 @@ - userid - smoke + userid + smokeDefault + + + + + + + + timeout + smoke + + 30 seconds + + + + + + + + + + \ No newline at end of file diff --git a/logback-classic/src/test/input/joran/sift/unsetDefaultValueProperty.xml b/logback-classic/src/test/input/joran/sift/unsetDefaultValueProperty.xml index 7afa57b9fafde7c26c9cb27e35d72273d66afd8d..95615cbdd7639579f0e98b14d0a5fb5bc1db7400 100644 --- a/logback-classic/src/test/input/joran/sift/unsetDefaultValueProperty.xml +++ b/logback-classic/src/test/input/joran/sift/unsetDefaultValueProperty.xml @@ -6,7 +6,7 @@ - userid + userid - userid - smoke + userid + zeroDefault diff --git a/logback-classic/src/test/input/joran/smtp/customBufferSize.xml b/logback-classic/src/test/input/joran/smtp/customBufferSize.xml index 65bda73361a366e7cb728b859766e35c89f3b4d1..5383b90a41f0027e3803de2b13f01a868df80a5b 100644 --- a/logback-classic/src/test/input/joran/smtp/customBufferSize.xml +++ b/logback-classic/src/test/input/joran/smtp/customBufferSize.xml @@ -5,9 +5,9 @@ ${port} nospam@qos.ch user@host.dom - %logger - %m + testCustomBufferSize %logger - %m - + 1 diff --git a/logback-classic/src/test/input/joran/smtp/customEvaluator.xml b/logback-classic/src/test/input/joran/smtp/customEvaluator.xml index f5405da8328b3ab361fc7a74d9c4774286e0e5ef..b2e39a76dfccc4bddeb9b14183ec503f80984f21 100644 --- a/logback-classic/src/test/input/joran/smtp/customEvaluator.xml +++ b/logback-classic/src/test/input/joran/smtp/customEvaluator.xml @@ -5,7 +5,7 @@ ${port} nospam@qos.ch user@host.dom - %logger - %m + testCustomEvaluator %logger - %m 2 diff --git a/logback-classic/src/test/input/joran/timestamp-context.xml b/logback-classic/src/test/input/joran/timestamp-context.xml new file mode 100644 index 0000000000000000000000000000000000000000..f184f5ac4eaece9aa77466df08f73949ab57de79 --- /dev/null +++ b/logback-classic/src/test/input/joran/timestamp-context.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/logback-classic/src/test/input/joran/timestamp-local.xml b/logback-classic/src/test/input/joran/timestamp-local.xml new file mode 100644 index 0000000000000000000000000000000000000000..dd20ba01dac4f8316418d7b28c7439b0104bfd24 --- /dev/null +++ b/logback-classic/src/test/input/joran/timestamp-local.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/logback-classic/src/test/input/joran/timestamp.xml b/logback-classic/src/test/input/joran/timestamp.xml deleted file mode 100644 index e36da68144f51a50f90349d614b44f7f3814c4a2..0000000000000000000000000000000000000000 --- a/logback-classic/src/test/input/joran/timestamp.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/AllClassicTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/AllClassicTest.java index c06b086bea5df4d0ec503008b5ac29dbdf65359c..5d998fc1d90d7380f5fdb03e302ed09f666af0de 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/AllClassicTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/AllClassicTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/AsyncAppenderTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/AsyncAppenderTest.java index 990dc9a0fefaf220ee25f25fdbe259ff6303399a..20702136405aec93c14963031279c67def23cb1a 100755 --- a/logback-classic/src/test/java/ch/qos/logback/classic/AsyncAppenderTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/AsyncAppenderTest.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.classic; import ch.qos.logback.classic.net.testObjectBuilders.LoggingEventBuilderInContext; diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/ClassicTestConstants.java b/logback-classic/src/test/java/ch/qos/logback/classic/ClassicTestConstants.java index 2bf62828124c3fdf8b1d75833b2b041af11a1a60..597dd67be75777a2abba2531d6b8d52ff518e2c9 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/ClassicTestConstants.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/ClassicTestConstants.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/Foo.java b/logback-classic/src/test/java/ch/qos/logback/classic/Foo.java index bcee0ca82cbe52a0d5cd4cced551ebf5d1360ea7..a171c50e21b0558a09e2f7d57406eb656a4c9cde 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/Foo.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/Foo.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java b/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java index a9ec26b19b9e84858106e25af7f273dd7b3a4601..b42f87de233e7b78e0ef1b4b3ab49a9841b328f0 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/HLoggerContext.java b/logback-classic/src/test/java/ch/qos/logback/classic/HLoggerContext.java index d5f5fb3a345472c445eec5f79489409fdedb1427..5d9d7396aa94ce4927d615a8ca799d1eb313b6a7 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/HLoggerContext.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/HLoggerContext.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextDeadlockTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextDeadlockTest.java index 774d6e915f7f3168976f2c869b0b0f1f7840ec30..cc8ed20aff76d3b0269ad98d4d40f897ea9e4376 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextDeadlockTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextDeadlockTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java index 6b37896884f9182472145121eb4ede4620e1288d..17e6702eab41d1fad94ac51f8902c40cc18c79ad 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/MessageFormattingTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerMessageFormattingTest.java old mode 100644 new mode 100755 similarity index 96% rename from logback-classic/src/test/java/ch/qos/logback/classic/MessageFormattingTest.java rename to logback-classic/src/test/java/ch/qos/logback/classic/LoggerMessageFormattingTest.java index c6974209f683af1cebdbe38b4cfad3f5a192889c..c9b5bd9c8411673cb40f0170b76ba94c9d2bb1d5 --- a/logback-classic/src/test/java/ch/qos/logback/classic/MessageFormattingTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerMessageFormattingTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -21,7 +21,7 @@ import org.junit.Test; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.read.ListAppender; -public class MessageFormattingTest { +public class LoggerMessageFormattingTest { LoggerContext lc; ListAppender listAppender; @@ -81,4 +81,6 @@ public class MessageFormattingTest { assertEquals("12", formattedMessage); } + + } diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/LoggerPerfTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerPerfTest.java index 01db530171874326ed996ddd887015c79ad944ba..7aebc7123e96dcb40f26096ef0bed781bb2d621e 100755 --- a/logback-classic/src/test/java/ch/qos/logback/classic/LoggerPerfTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerPerfTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/LoggerSerializationTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerSerializationTest.java index 99805ba0785c52459437a8e326fae397a5f2de87..3e33063b3b47bf76665c34a338cb071903fdfb6a 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/LoggerSerializationTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerSerializationTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java index 6b9f65c94846cdd1b62af7522961fb437d1c48eb..d7a5dc67e008556a8b5fe17ee21657add196f9e7 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTestHelper.java b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTestHelper.java index 7a68162444e0be9c64dd2b7234b3e293a2db6f5d..aa84d64c380ec581b6f4ee03e73ac9eabd8ac2d7 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTestHelper.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTestHelper.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/MDCTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/MDCTest.java index 7234a4b6b8bf1e5f25edbda3bb482c250a574d76..bcd5bae2f388bf729f5a975bcab3f58276729243 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/MDCTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/MDCTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/MDCTestThread.java b/logback-classic/src/test/java/ch/qos/logback/classic/MDCTestThread.java index f1e9a9605557a6796d53ffcd74553cad341be48c..f59e9745eb30caa0b179b262496657f523f8365e 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/MDCTestThread.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/MDCTestThread.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/PackageTest.java old mode 100644 new mode 100755 index a5ec680add627d83eb6d4da6163e42a4bbf36b28..ebd1806da102d7017eee44161e39672deedb3af7 --- a/logback-classic/src/test/java/ch/qos/logback/classic/PackageTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -21,7 +21,7 @@ import org.junit.runners.Suite.SuiteClasses; @SuiteClasses({LoggerContextTest.class, LoggerPerfTest.class, ScenarioBasedLoggerContextTest.class, PatternLayoutTest.class, LoggerTest.class, LoggerSerializationTest.class, - MessageFormattingTest.class, MDCTest.class, + LoggerMessageFormattingTest.class, MDCTest.class, TurboFilteringInLoggerTest.class, AsyncAppenderTest.class}) public class PackageTest { diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java index 2429a83442fd6bd8551a19c689d7607f11e00afc..3c7b16bda9387997c0b635d9917dc3b3a96a89ee 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,19 +13,6 @@ */ package ch.qos.logback.classic; -import static ch.qos.logback.classic.ClassicTestConstants.ISO_REGEX; -import static ch.qos.logback.classic.ClassicTestConstants.MAIN_REGEX; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import ch.qos.logback.core.util.StatusPrinter; -import org.junit.Before; -import org.junit.Test; - import ch.qos.logback.classic.joran.JoranConfigurator; import ch.qos.logback.classic.pattern.ConverterTest; import ch.qos.logback.classic.spi.ILoggingEvent; @@ -36,6 +23,15 @@ import ch.qos.logback.core.joran.spi.JoranException; import ch.qos.logback.core.pattern.PatternLayoutBase; import ch.qos.logback.core.pattern.parser.AbstractPatternLayoutBaseTest; import ch.qos.logback.core.testUtil.StringListAppender; +import ch.qos.logback.core.util.OptionHelper; +import ch.qos.logback.core.util.StatusPrinter; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.MDC; + +import static ch.qos.logback.classic.ClassicTestConstants.ISO_REGEX; +import static ch.qos.logback.classic.ClassicTestConstants.MAIN_REGEX; +import static org.junit.Assert.*; public class PatternLayoutTest extends AbstractPatternLayoutBaseTest { @@ -45,9 +41,8 @@ public class PatternLayoutTest extends AbstractPatternLayoutBaseTest optionList = new ArrayList(); - public PatternLayoutTest() { + public PatternLayoutTest() { super(); Exception ex = new Exception("Bogus exception"); le = makeLoggingEvent(ex); @@ -147,6 +142,20 @@ public class PatternLayoutTest extends AbstractPatternLayoutBaseTest cbTracker; + CyclicBuffer cb; @Before public void setUp() throws Exception { diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/ExternalMockSocketServer.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/ExternalMockSocketServer.java index 74643def5a3cd6942d1df28bc478838c9ac201b0..659dc7e2df16f035a23cc50f08f60fa971500b99 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/ExternalMockSocketServer.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/ExternalMockSocketServer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTest.java index 4113770bed2f6eaddebcc915f2999f3ab7cbeb5a..1fc169ecf2172b41c2897318c461ca7480af57dd 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTestApp.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTestApp.java index 624871da9ddb0caa97cb99b3886b7ab7ca57ba68..64ced9fdd934a432ef53e6fd5641400b6a8c843e 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTestApp.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTestApp.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTest.java index 6139d743f3e0f041db282208a4d97b250a2798ef..cfdff9d192465fa4f44135bcf6867bc985033c0e 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTestApp.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTestApp.java index 298b1efa369220cb12fabf9a44fde20a2c7a6ee9..f5a5f7d8c7c6256b3a5d1ce3f2f281e00c4ef66b 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTestApp.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTestApp.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/NOPOutputStream.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/NOPOutputStream.java index b0efe9097e6bd5af004118af305d949fa140681e..42b4aea4bd0e6d17dbc92ceb8dba5648b798d689 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/NOPOutputStream.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/NOPOutputStream.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/PackageTest.java index e6b6d805f18a9659795d71b2cf1c88af315a8598..6664d91f6a8b8cd92a804268b628c58bfeef9790 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/PackageTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -19,8 +19,8 @@ import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses( { SyslogAppenderTest.class, DilutedSMTPAppenderTest.class, - SocketAppenderTest.class, JMSQueueAppenderTest.class, JMSTopicAppenderTest.class, + JMSQueueAppenderTest.class, JMSTopicAppenderTest.class, SMTPAppender_GreenTest.class, SMTPAppender_SubethaSMTPTest.class, - SocketRemoteTest.class }) + SocketReceiverTest.class, SSLSocketReceiverTest.class }) public class PackageTest { } \ No newline at end of file diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java index de2b59fcbd9cfe3f3e1e7154fcb29e0bd6a9033b..541f14c922b83cfca1428d15c01bcbc0a30b2861 100755 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,19 +13,6 @@ */ package ch.qos.logback.classic.net; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.concurrent.TimeUnit; - -import javax.mail.MessagingException; -import javax.mail.internet.MimeMessage; -import javax.mail.internet.MimeMultipart; - -import org.dom4j.io.SAXReader; -import org.junit.*; -import org.slf4j.MDC; - import ch.qos.logback.classic.ClassicTestConstants; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; @@ -36,43 +23,64 @@ import ch.qos.logback.classic.joran.JoranConfigurator; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.Layout; import ch.qos.logback.core.joran.spi.JoranException; +import ch.qos.logback.core.status.OnConsoleStatusListener; +import ch.qos.logback.core.testUtil.EnvUtilForTests; import ch.qos.logback.core.testUtil.RandomUtil; - +import ch.qos.logback.core.util.CoreTestConstants; import com.icegreen.greenmail.util.GreenMail; import com.icegreen.greenmail.util.GreenMailUtil; import com.icegreen.greenmail.util.ServerSetup; +import org.dom4j.DocumentException; +import org.dom4j.io.SAXReader; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.MDC; + +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.concurrent.TimeUnit; import static org.junit.Assert.*; public class SMTPAppender_GreenTest { - static boolean SYNCHRONOUS = false; - static boolean ASYNCHRONOUS = true; - static int port = RandomUtil.getRandomServerPort(); - static GreenMail greenMailServer; - - SMTPAppender smtpAppender; - LoggerContext lc = new LoggerContext(); - Logger logger = lc.getLogger(this.getClass()); - - static final String TEST_SUBJECT = "test subject"; static final String HEADER = "HEADER\n"; static final String FOOTER = "FOOTER\n"; static final String DEFAULT_PATTERN = "%-4relative %mdc [%thread] %-5level %class - %msg%n"; + static final boolean SYNCHRONOUS = false; + static final boolean ASYNCHRONOUS = true; + int port = RandomUtil.getRandomServerPort(); + // GreenMail cannot be static. As a shared server induces race conditions + GreenMail greenMailServer; + + SMTPAppender smtpAppender; + LoggerContext loggerContext = new LoggerContext(); + Logger logger = loggerContext.getLogger(this.getClass()); - int oldCount; @Before public void setUp() throws Exception { + + OnConsoleStatusListener.addNewInstanceToContext(loggerContext); + MDC.clear(); ServerSetup serverSetup = new ServerSetup(port, "localhost", ServerSetup.PROTOCOL_SMTP); greenMailServer = new GreenMail(serverSetup); greenMailServer.start(); - - MDC.clear(); - oldCount = messageCount(); + // give the server a head start + if (EnvUtilForTests.isRunningOnSlowJenkins()) { + Thread.currentThread().sleep(2000); + } else { + Thread.currentThread().sleep(50); + } } @After @@ -80,22 +88,21 @@ public class SMTPAppender_GreenTest { greenMailServer.stop(); } - void buildSMTPAppender(boolean synchronicity) throws Exception { + void buildSMTPAppender(String subject, boolean synchronicity) throws Exception { smtpAppender = new SMTPAppender(); - smtpAppender.setContext(lc); + smtpAppender.setContext(loggerContext); smtpAppender.setName("smtp"); smtpAppender.setFrom("user@host.dom"); smtpAppender.setSMTPHost("localhost"); smtpAppender.setSMTPPort(port); - smtpAppender.setSubject(TEST_SUBJECT); + smtpAppender.setSubject(subject); smtpAppender.addTo("nospam@qos.ch"); smtpAppender.setAsynchronousSending(synchronicity); - // smtpAppender.start(); } - private Layout buildPatternLayout(LoggerContext lc, String pattern) { + private Layout buildPatternLayout(String pattern) { PatternLayout layout = new PatternLayout(); - layout.setContext(lc); + layout.setContext(loggerContext); layout.setFileHeader(HEADER); layout.setOutputPatternAsHeader(false); layout.setPattern(pattern); @@ -104,27 +111,27 @@ public class SMTPAppender_GreenTest { return layout; } - private Layout buildHTMLLayout(LoggerContext lc) { + private Layout buildHTMLLayout() { HTMLLayout layout = new HTMLLayout(); - layout.setContext(lc); - // layout.setFileHeader(HEADER); + layout.setContext(loggerContext); layout.setPattern("%level%class%msg"); - // layout.setFileFooter(FOOTER); layout.start(); return layout; } - private int messageCount() throws MessagingException, IOException { - MimeMessage[] mma = greenMailServer.getReceivedMessages(); - assertNotNull(mma); - return mma.length; + private void waitForServerToReceiveEmails(int emailCount) throws InterruptedException { + greenMailServer.waitForIncomingEmail(5000, emailCount); } - private MimeMultipart verify(String subject) throws MessagingException, - IOException { + private MimeMultipart verifyAndExtractMimeMultipart(String subject) throws MessagingException, + IOException, InterruptedException { + int oldCount = 0; + int expectedEmailCount = 1; + // wait for the server to receive the messages + waitForServerToReceiveEmails(expectedEmailCount); MimeMessage[] mma = greenMailServer.getReceivedMessages(); assertNotNull(mma); - assertEquals(oldCount + 1, mma.length); + assertEquals(expectedEmailCount, mma.length); MimeMessage mm = mma[oldCount]; // http://jira.qos.ch/browse/LBCLASSIC-67 assertEquals(subject, mm.getSubject()); @@ -132,37 +139,39 @@ public class SMTPAppender_GreenTest { } void waitUntilEmailIsSent() throws InterruptedException { - lc.getExecutorService().shutdown(); - lc.getExecutorService().awaitTermination(1000, TimeUnit.MILLISECONDS); + loggerContext.getExecutorService().shutdown(); + loggerContext.getExecutorService().awaitTermination(1000, TimeUnit.MILLISECONDS); } @Test - public void syncronousSmoke() throws Exception { - buildSMTPAppender(SYNCHRONOUS); + public void synchronousSmoke() throws Exception { + String subject = "synchronousSmoke"; + buildSMTPAppender(subject, SYNCHRONOUS); - smtpAppender.setLayout(buildPatternLayout(lc, DEFAULT_PATTERN)); + smtpAppender.setLayout(buildPatternLayout(DEFAULT_PATTERN)); smtpAppender.start(); logger.addAppender(smtpAppender); logger.debug("hello"); logger.error("en error", new Exception("an exception")); - MimeMultipart mp = verify(TEST_SUBJECT); + MimeMultipart mp = verifyAndExtractMimeMultipart(subject); String body = GreenMailUtil.getBody(mp.getBodyPart(0)); assertTrue(body.startsWith(HEADER.trim())); assertTrue(body.endsWith(FOOTER.trim())); } @Test - public void asyncronousSmoke() throws Exception { - buildSMTPAppender(ASYNCHRONOUS); - smtpAppender.setLayout(buildPatternLayout(lc, DEFAULT_PATTERN)); + public void asynchronousSmoke() throws Exception { + String subject = "asynchronousSmoke"; + buildSMTPAppender(subject, ASYNCHRONOUS); + smtpAppender.setLayout(buildPatternLayout(DEFAULT_PATTERN)); smtpAppender.start(); logger.addAppender(smtpAppender); logger.debug("hello"); logger.error("en error", new Exception("an exception")); waitUntilEmailIsSent(); - MimeMultipart mp = verify(TEST_SUBJECT); + MimeMultipart mp = verifyAndExtractMimeMultipart(subject); String body = GreenMailUtil.getBody(mp.getBodyPart(0)); assertTrue(body.startsWith(HEADER.trim())); assertTrue(body.endsWith(FOOTER.trim())); @@ -170,34 +179,37 @@ public class SMTPAppender_GreenTest { // See also http://jira.qos.ch/browse/LOGBACK-734 @Test - public void callerDataShouldBeCorrectlySetWithAsyncronousSending() throws Exception { - buildSMTPAppender(ASYNCHRONOUS); - smtpAppender.setLayout(buildPatternLayout(lc,DEFAULT_PATTERN)); + public void callerDataShouldBeCorrectlySetWithAsynchronousSending() throws Exception { + String subject = "LOGBACK-734"; + buildSMTPAppender("LOGBACK-734", ASYNCHRONOUS); + smtpAppender.setLayout(buildPatternLayout(DEFAULT_PATTERN)); smtpAppender.setIncludeCallerData(true); smtpAppender.start(); logger.addAppender(smtpAppender); - logger.debug("hello"); - logger.error("en error", new Exception("an exception")); + logger.debug("LOGBACK-734"); + logger.error("callerData", new Exception("ShouldBeCorrectlySetWithAsynchronousSending")); waitUntilEmailIsSent(); - MimeMultipart mp = verify(TEST_SUBJECT); + MimeMultipart mp = verifyAndExtractMimeMultipart(subject); String body = GreenMailUtil.getBody(mp.getBodyPart(0)); - assertTrue(body.contains("DEBUG "+this.getClass().getName()+" - hello")); + assertTrue("actual [" + body + "]", body.contains("DEBUG " + this.getClass().getName() + " - LOGBACK-734")); } + // lost MDC @Test public void LBCLASSIC_104() throws Exception { - buildSMTPAppender(SYNCHRONOUS); + String subject = "LBCLASSIC_104"; + buildSMTPAppender(subject, SYNCHRONOUS); smtpAppender.setAsynchronousSending(false); - smtpAppender.setLayout(buildPatternLayout(lc, DEFAULT_PATTERN)); + smtpAppender.setLayout(buildPatternLayout(DEFAULT_PATTERN)); smtpAppender.start(); logger.addAppender(smtpAppender); MDC.put("key", "val"); logger.debug("LBCLASSIC_104"); MDC.clear(); - logger.error("en error", new Exception("an exception")); + logger.error("en error", new Exception("test")); - MimeMultipart mp = verify(TEST_SUBJECT); + MimeMultipart mp = verifyAndExtractMimeMultipart(subject); String body = GreenMailUtil.getBody(mp.getBodyPart(0)); assertTrue(body.startsWith(HEADER.trim())); System.out.println(body); @@ -207,22 +219,30 @@ public class SMTPAppender_GreenTest { @Test public void html() throws Exception { - buildSMTPAppender(SYNCHRONOUS); + String subject = "html"; + buildSMTPAppender(subject, SYNCHRONOUS); smtpAppender.setAsynchronousSending(false); - smtpAppender.setLayout(buildHTMLLayout(lc)); + smtpAppender.setLayout(buildHTMLLayout()); smtpAppender.start(); logger.addAppender(smtpAppender); logger.debug("html"); logger.error("en error", new Exception("an exception")); - MimeMultipart mp = verify(TEST_SUBJECT); + MimeMultipart mp = verifyAndExtractMimeMultipart(subject); - // verify strict adherence to xhtml1-strict.dtd + // verifyAndExtractMimeMultipart strict adherence to xhtml1-strict.dtd SAXReader reader = new SAXReader(); reader.setValidation(true); reader.setEntityResolver(new XHTMLEntityResolver()); - reader.read(mp.getBodyPart(0).getInputStream()); - + byte[] messageBytes = getAsByteArray(mp.getBodyPart(0).getInputStream()); + ByteArrayInputStream bais = new ByteArrayInputStream(messageBytes); + try { + reader.read(bais); + } catch (DocumentException de) { + System.out.println("incoming message:"); + System.out.println(new String(messageBytes)); + throw de; + } } private byte[] getAsByteArray(InputStream inputStream) throws IOException { @@ -230,7 +250,7 @@ public class SMTPAppender_GreenTest { byte[] buffer = new byte[1024]; int n = -1; - while((n = inputStream.read(buffer)) != -1) { + while ((n = inputStream.read(buffer)) != -1) { baos.write(buffer, 0, n); } return baos.toByteArray(); @@ -238,9 +258,8 @@ public class SMTPAppender_GreenTest { private void configure(String file) throws JoranException { JoranConfigurator jc = new JoranConfigurator(); - jc.setContext(lc); - System.out.println("port=" + port); - lc.putProperty("port", "" + port); + jc.setContext(loggerContext); + loggerContext.putProperty("port", "" + port); jc.doConfigure(file); } @@ -249,14 +268,14 @@ public class SMTPAppender_GreenTest { configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "smtp/customEvaluator.xml"); - logger.debug("hello"); - String msg2 = "world"; + logger.debug("test"); + String msg2 = "CustomEvaluator"; logger.debug(msg2); logger.debug("invisible"); waitUntilEmailIsSent(); - MimeMultipart mp = verify(this.getClass().getName() + " - " + msg2); + MimeMultipart mp = verifyAndExtractMimeMultipart("testCustomEvaluator " + this.getClass().getName() + " - " + msg2); String body = GreenMailUtil.getBody(mp.getBodyPart(0)); - assertEquals("helloworld", body); + assertEquals("testCustomEvaluator", body); } @Test @@ -269,31 +288,35 @@ public class SMTPAppender_GreenTest { String msg = "hello"; logger.error(msg); waitUntilEmailIsSent(); - MimeMultipart mp = verify(this.getClass().getName() + " - " + msg); + MimeMultipart mp = verifyAndExtractMimeMultipart("testCustomBufferSize " + this.getClass().getName() + " - " + msg); String body = GreenMailUtil.getBody(mp.getBodyPart(0)); assertEquals(msg, body); } + // this test fails intermittently on Jenkins. @Test public void testMultipleTo() throws Exception { - buildSMTPAppender(SYNCHRONOUS); - smtpAppender.setLayout(buildPatternLayout(lc, DEFAULT_PATTERN)); + buildSMTPAppender("testMultipleTo", SYNCHRONOUS); + smtpAppender.setLayout(buildPatternLayout(DEFAULT_PATTERN)); + // buildSMTPAppender() already added one destination address smtpAppender.addTo("Test , other-test@example.com"); smtpAppender.start(); logger.addAppender(smtpAppender); - logger.debug("hello"); - logger.error("en error", new Exception("an exception")); - + logger.debug("testMultipleTo hello"); + logger.error("testMultipleTo en error", new Exception("an exception")); + Thread.yield(); + int expectedEmailCount = 3; + waitForServerToReceiveEmails(expectedEmailCount); MimeMessage[] mma = greenMailServer.getReceivedMessages(); assertNotNull(mma); - assertEquals(oldCount+3, mma.length); + assertEquals(expectedEmailCount, mma.length); } // http://jira.qos.ch/browse/LBCLASSIC-221 @Test public void bufferShouldBeResetBetweenMessages() throws Exception { - buildSMTPAppender(SYNCHRONOUS); - smtpAppender.setLayout(buildPatternLayout(lc, DEFAULT_PATTERN)); + buildSMTPAppender("bufferShouldBeResetBetweenMessages", SYNCHRONOUS); + smtpAppender.setLayout(buildPatternLayout(DEFAULT_PATTERN)); smtpAppender.start(); logger.addAppender(smtpAppender); String msg0 = "hello zero"; @@ -304,17 +327,20 @@ public class SMTPAppender_GreenTest { logger.debug(msg1); logger.error("error one"); - waitUntilEmailIsSent(); + Thread.yield(); + int oldCount = 0; + int expectedEmailCount = oldCount + 2; + waitForServerToReceiveEmails(expectedEmailCount); MimeMessage[] mma = greenMailServer.getReceivedMessages(); assertNotNull(mma); - assertEquals(oldCount+2, mma.length); + assertEquals(expectedEmailCount, mma.length); MimeMessage mm0 = mma[oldCount]; MimeMultipart content0 = (MimeMultipart) mm0.getContent(); String body0 = GreenMailUtil.getBody(content0.getBodyPart(0)); - MimeMessage mm1 = mma[oldCount+1]; + MimeMessage mm1 = mma[oldCount + 1]; MimeMultipart content1 = (MimeMultipart) mm1.getContent(); String body1 = GreenMailUtil.getBody(content1.getBodyPart(0)); // second body should not contain content from first message diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_SubethaSMTPTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_SubethaSMTPTest.java index 1d671c421920edfc92a4058692f6476297a3f06c..cc01494c30763f06ffc52a9c8c6d7c838f694100 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_SubethaSMTPTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_SubethaSMTPTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SSLSocketRemoteTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SSLSocketReceiverTest.java similarity index 66% rename from logback-classic/src/test/java/ch/qos/logback/classic/net/SSLSocketRemoteTest.java rename to logback-classic/src/test/java/ch/qos/logback/classic/net/SSLSocketReceiverTest.java index aae7c407b8a8034269a3f1a180667791df899f98..36d5a2e2893e7d599e2d8c4026cddad16e0c63e1 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SSLSocketRemoteTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/SSLSocketReceiverTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.classic.net; import static org.junit.Assert.assertNotNull; @@ -20,30 +19,30 @@ import java.net.InetAddress; import org.junit.Before; import org.junit.Test; +import org.slf4j.LoggerFactory; -import ch.qos.logback.core.net.mock.MockContext; +import ch.qos.logback.classic.LoggerContext; /** - * Unit tests for {@link SSLSocketRemote}. + * Unit tests for {@link SSLSocketReceiver}. * * @author Carl Harris */ -public class SSLSocketRemoteTest { - - private MockContext context = new MockContext(); +public class SSLSocketReceiverTest { - private SSLSocketRemote remote = - new SSLSocketRemote(); + private SSLSocketReceiver remote = + new SSLSocketReceiver(); @Before public void setUp() throws Exception { - remote.setContext(context); + LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + remote.setContext(lc); } @Test public void testUsingDefaultConfig() throws Exception { // should be able to start successfully with no SSL configuration at all - remote.setHost(InetAddress.getLocalHost().getHostAddress()); + remote.setRemoteHost(InetAddress.getLocalHost().getHostAddress()); remote.setPort(6000); remote.start(); assertNotNull(remote.getSocketFactory()); diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfTest.java index 8064a34cca05016b5a55889ccf615d5ef61a5907..6760da46734290af7996518052c66e751b833341 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java deleted file mode 100644 index 9a45a6e16670484d6b9b716dcc94d5b0b06526f6..0000000000000000000000000000000000000000 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java +++ /dev/null @@ -1,317 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.classic.net; - -import java.util.Date; -import java.util.Map; -import java.util.concurrent.*; - -import ch.qos.logback.core.status.OnConsoleStatusListener; -import ch.qos.logback.core.testUtil.RandomUtil; -import org.junit.*; -import org.slf4j.MDC; -import org.slf4j.Marker; -import org.slf4j.MarkerFactory; - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.classic.spi.LoggerContextVO; -import ch.qos.logback.core.read.ListAppender; - -import static org.junit.Assert.*; - -public class SocketAppenderTest { - - static final String LIST_APPENDER_NAME = "list"; - static final int RECONNECT_DELAY = 1; - static final int SERVER_LATCH_WAIT_TIMEOUT = 1000; - static final int APPENDER_LATCH_WAIT_TIMEOUT = 10; - - static int diff = RandomUtil.getPositiveInt(); - - static int PORT = 1024 + (diff % 30000); - static LoggerContext SERVER_LOGGER_CONTEXT = new LoggerContext(); - static ListAppenderWithLatch LIST_APPENDER = new ListAppenderWithLatch(); - static private SimpleSocketServer SIMPLE_SOCKET_SERVER; - - String mdcKey = "key" + diff; - LoggerContext loggerContext = new LoggerContext(); - SocketAppender socketAppender = new SocketAppender(); - private boolean includeCallerData = false; - - @BeforeClass - public static void beforeClass() throws InterruptedException { - fireServer(); - waitForServerToStart(); - } - - @AfterClass - public static void afterClass() { - closeServer(); - } - - private static void closeServer() {SIMPLE_SOCKET_SERVER.close();} - - @Before - public void setUp() { - } - - @After - public void tearDown() { - LIST_APPENDER.list.clear(); - } - - @Test - public void startFailNoRemoteHost() { - SocketAppender appender = new SocketAppender(); - appender.setContext(loggerContext); - appender.setPort(PORT); - appender.start(); - assertEquals(1, loggerContext.getStatusManager().getCount()); - } - - @Test - public void receiveMessage() throws InterruptedException { - updateListAppenderLatch(1); - configureClient(); - - Logger logger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); - logger.debug("test msg"); - - waitForListAppenderLatch(); - - //simpleSocketServer.close(); - //simpleSocketServer.join(JOIN_OR_WAIT_TIMEOUT); - //assertTrue(simpleSocketServer.isClosed()); - assertEquals(1, LIST_APPENDER.list.size()); - - ILoggingEvent remoteEvent = LIST_APPENDER.list.get(0); - assertNull(remoteEvent.getCallerData()); - assertEquals("test msg", remoteEvent.getMessage()); - assertEquals(Level.DEBUG, remoteEvent.getLevel()); - } - - @Test - public void receiveWithContext() throws InterruptedException { - updateListAppenderLatch(1); - configureClient(); - - Logger logger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); - logger.debug("test msg"); - waitForListAppenderLatch(); - - assertEquals(1, LIST_APPENDER.list.size()); - - ILoggingEvent remoteEvent = LIST_APPENDER.list.get(0); - - String loggerName = remoteEvent.getLoggerName(); - assertNotNull(loggerName); - assertEquals(Logger.ROOT_LOGGER_NAME, loggerName); - - LoggerContextVO loggerContextRemoteView = remoteEvent - .getLoggerContextVO(); - assertNull(remoteEvent.getCallerData()); - assertNotNull(loggerContextRemoteView); - assertEquals("test", loggerContextRemoteView.getName()); - Map props = loggerContextRemoteView.getPropertyMap(); - assertEquals("testValue", props.get("testKey")); - } - - @Test - public void messageWithMDC() throws InterruptedException { - updateListAppenderLatch(1); - configureClient(); - - Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); - - MDC.put(mdcKey, "testValue"); - root.debug("test msg"); - - waitForListAppenderLatch(); - assertEquals(1, LIST_APPENDER.list.size()); - - ILoggingEvent remoteEvent = LIST_APPENDER.list.get(0); - Map MDCPropertyMap = remoteEvent.getMDCPropertyMap(); - assertEquals("testValue", MDCPropertyMap.get(mdcKey)); - assertNull(remoteEvent.getCallerData()); - } - - // test http://jira.qos.ch/browse/LBCLASSIC-145 - @Test - public void withCallerData() throws InterruptedException { - updateListAppenderLatch(1); - includeCallerData = true; -// fireServer(); -// waitForServerToStart(); - configureClient(); - - Logger logger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); - logger.debug("test msg"); - - waitForListAppenderLatch(); - assertEquals(1, LIST_APPENDER.list.size()); - - ILoggingEvent remoteEvent = LIST_APPENDER.list.get(0); - assertNotNull(remoteEvent.getCallerData()); - } - - @Test - public void messageWithMarker() throws InterruptedException { - updateListAppenderLatch(1); - configureClient(); - - Logger logger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); - - Marker marker = MarkerFactory.getMarker("testMarker"); - logger.debug(marker, "test msg"); - waitForListAppenderLatch(); - - assertEquals(1, LIST_APPENDER.list.size()); - - ILoggingEvent remoteEvent = LIST_APPENDER.list.get(0); - assertEquals("testMarker", remoteEvent.getMarker().getName()); - } - - @Test - public void messageWithUpdatedMDC() throws InterruptedException { - updateListAppenderLatch(2); - configureClient(); - - Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); - - MDC.put(mdcKey, "testValue"); - root.debug("test msg"); - - MDC.put(mdcKey, "updatedTestValue"); - root.debug("test msg 2"); - - waitForListAppenderLatch(); - assertEquals(2, LIST_APPENDER.list.size()); - - // We observe the second logging event. It should provide us with - // the updated MDC property. - ILoggingEvent remoteEvent = LIST_APPENDER.list.get(1); - Map MDCPropertyMap = remoteEvent.getMDCPropertyMap(); - assertEquals("updatedTestValue", MDCPropertyMap.get(mdcKey)); - } - - @Test - public void lateServerLaunch() throws InterruptedException { - closeServer(); - - socketAppender.setReconnectionDelay(RECONNECT_DELAY); - configureClient(); - OnConsoleStatusListener.addNewInstanceToContext(loggerContext); - - Logger logger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); - logger.debug("test msg"); - - fireServer(); - waitForServerToStart(); - updateListAppenderLatch(1); - - - int len = 1000/APPENDER_LATCH_WAIT_TIMEOUT; - for(int i = 0; i < len; i++) { - logger.debug("test msg lateServerLaunch"); - if(waitForListAppenderLatch()) { - System.out.println("Success after "+i+" attempts"); - break; - } - } - - assertTrue("expecting non-empty list", LIST_APPENDER.list.size() > 0); - - ILoggingEvent remoteEvent = LIST_APPENDER.list.get(0); - assertEquals("test msg lateServerLaunch", remoteEvent.getMessage()); - assertEquals(Level.DEBUG, remoteEvent.getLevel()); - } - - private static void waitForServerToStart() throws InterruptedException { - CountDownLatch latch = SIMPLE_SOCKET_SERVER.getLatch(); - boolean success = latch.await(SERVER_LATCH_WAIT_TIMEOUT, TimeUnit.MILLISECONDS); - if (!success) { - fail("Failed latch wait for server to start"); - } - } - - private static void fireServer() throws InterruptedException { - SERVER_LOGGER_CONTEXT.reset(); - - Logger root = SERVER_LOGGER_CONTEXT.getLogger("root"); - - // we don't want to ignore messages generated by SocketNode - Logger socketNodeLogger = SERVER_LOGGER_CONTEXT.getLogger(SocketNode.class); - socketNodeLogger.setLevel(Level.WARN); - - LIST_APPENDER.setName(LIST_APPENDER_NAME); - LIST_APPENDER.setContext(SERVER_LOGGER_CONTEXT); - LIST_APPENDER.start(); - - root.addAppender(LIST_APPENDER); - SIMPLE_SOCKET_SERVER = new SimpleSocketServer(SERVER_LOGGER_CONTEXT, PORT); - CountDownLatch latch = new CountDownLatch(1); - SIMPLE_SOCKET_SERVER.setLatch(latch); - SIMPLE_SOCKET_SERVER.start(); - } - - private void updateListAppenderLatch(int count) { - LIST_APPENDER.setLatch(new CountDownLatch(count)); - } - - private boolean waitForListAppenderLatch() throws InterruptedException { - CountDownLatch latch = LIST_APPENDER.getLatch(); - boolean success = latch.await(APPENDER_LATCH_WAIT_TIMEOUT, TimeUnit.MILLISECONDS); - return success; - } - - private void configureClient() { - loggerContext = new LoggerContext(); - loggerContext.setName("test"); - loggerContext.putProperty("testKey", "testValue"); - Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); - socketAppender.setContext(loggerContext); - socketAppender.setName("socket"); - socketAppender.setPort(PORT); - socketAppender.setRemoteHost("localhost"); - socketAppender.setIncludeCallerData(includeCallerData); - root.addAppender(socketAppender); - socketAppender.start(); - } - - public static class ListAppenderWithLatch extends ListAppender { - - CountDownLatch latch; - - public void setLatch(CountDownLatch latch) { - this.latch = latch; - } - - CountDownLatch getLatch() { - return latch; - } - - protected void append(E event) { - super.append(event); - try { - latch.countDown(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - -} diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java index 9a13386126b496bb9ed015536f3e6cf7f1c8fc01..1edc92abad161aa2daad4c606ae985bdd867debb 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -56,7 +56,9 @@ public class SocketMin { try { int port = Integer.parseInt(portStr); logger.info("Creating socket appender (" + host + "," + port + ")."); - s = new SocketAppender(host, port); + s = new SocketAppender(); + s.setRemoteHost(host); + s.setPort(port); s.setName("S"); root.addAppender(s); } catch (java.lang.NumberFormatException e) { diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketRemoteTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketReceiverTest.java similarity index 69% rename from logback-classic/src/test/java/ch/qos/logback/classic/net/SocketRemoteTest.java rename to logback-classic/src/test/java/ch/qos/logback/classic/net/SocketReceiverTest.java index fb54bba5632f7532321ce09289d1897bf4b3d562..b4fcaa1f8710becfc636de709f84e764bbda78e1 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketRemoteTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketReceiverTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.classic.net; import static org.junit.Assert.assertEquals; @@ -27,7 +26,6 @@ import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import javax.net.SocketFactory; @@ -35,7 +33,6 @@ import javax.net.SocketFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.slf4j.LoggerFactory; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; @@ -45,32 +42,30 @@ import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.LoggingEvent; import ch.qos.logback.classic.spi.LoggingEventVO; import ch.qos.logback.core.net.SocketConnector; -import ch.qos.logback.core.net.mock.MockContext; import ch.qos.logback.core.net.server.ServerSocketUtil; +import ch.qos.logback.core.status.Status; /** - * Unit tests for {@link SocketRemote}. + * Unit tests for {@link SocketReceiver}. * * @author Carl Harris */ -public class SocketRemoteTest { +public class SocketReceiverTest { - private static final int DELAY = 200; + private static final int DELAY = 1000; private static final String TEST_HOST_NAME = "NOT.A.VALID.HOST.NAME"; private ServerSocket serverSocket; private Socket socket; - private ExecutorService executor = Executors.newCachedThreadPool(); - private MockContext context = new MockContext(); private MockSocketFactory socketFactory = new MockSocketFactory(); private MockSocketConnector connector; private MockAppender appender; private LoggerContext lc; private Logger logger; - private InstrumentedSocketRemote remote = - new InstrumentedSocketRemote(); + private InstrumentedSocketReceiver receiver = + new InstrumentedSocketReceiver(); @Before public void setUp() throws Exception { @@ -78,9 +73,10 @@ public class SocketRemoteTest { socket = new Socket(serverSocket.getInetAddress(), serverSocket.getLocalPort()); connector = new MockSocketConnector(socket); - remote.setContext(context); - lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + lc = new LoggerContext(); + lc.reset(); + receiver.setContext(lc); appender = new MockAppender(); appender.start(); logger = lc.getLogger(getClass()); @@ -89,10 +85,9 @@ public class SocketRemoteTest { @After public void tearDown() throws Exception { - remote.stop(); - if (!remote.isExecutorCreated()) { - executor.shutdownNow(); - } + receiver.stop(); + ExecutorService executor = lc.getExecutorService(); + executor.shutdownNow(); assertTrue(executor.awaitTermination(DELAY, TimeUnit.MILLISECONDS)); socket.close(); serverSocket.close(); @@ -101,64 +96,73 @@ public class SocketRemoteTest { @Test public void testStartNoRemoteAddress() throws Exception { - remote.start(); - assertTrue(context.getLastStatus().getMessage().contains("host")); + receiver.start(); + assertFalse(receiver.isStarted()); + int count = lc.getStatusManager().getCount(); + Status status = lc.getStatusManager().getCopyOfStatusList().get(count - 1); + assertTrue(status.getMessage().contains("host")); } @Test public void testStartNoPort() throws Exception { - remote.setHost(TEST_HOST_NAME); - remote.start(); - assertTrue(context.getLastStatus().getMessage().contains("port")); + receiver.setRemoteHost(TEST_HOST_NAME); + receiver.start(); + assertFalse(receiver.isStarted()); + int count = lc.getStatusManager().getCount(); + Status status = lc.getStatusManager().getCopyOfStatusList().get(count - 1); + assertTrue(status.getMessage().contains("port")); } @Test public void testStartUnknownHost() throws Exception { - remote.setPort(6000); - remote.setHost(TEST_HOST_NAME); - remote.start(); - assertTrue(context.getLastStatus().getMessage().contains("unknown host")); + receiver.setPort(6000); + receiver.setRemoteHost(TEST_HOST_NAME); + receiver.start(); + assertFalse(receiver.isStarted()); + int count = lc.getStatusManager().getCount(); + Status status = lc.getStatusManager().getCopyOfStatusList().get(count - 1); + assertTrue(status.getMessage().contains("unknown host")); } @Test public void testStartStop() throws Exception { - remote.setHost(InetAddress.getLocalHost().getHostName()); - remote.setPort(6000); - remote.setAcceptConnectionTimeout(DELAY / 2); - remote.start(); - assertTrue(remote.isStarted()); - remote.awaitConnectorCreated(DELAY); - remote.stop(); - assertFalse(remote.isStarted()); + receiver.setRemoteHost(InetAddress.getLocalHost().getHostName()); + receiver.setPort(6000); + receiver.setAcceptConnectionTimeout(DELAY / 2); + receiver.start(); + assertTrue(receiver.isStarted()); + receiver.awaitConnectorCreated(DELAY); + receiver.stop(); + assertFalse(receiver.isStarted()); } @Test public void testServerSlowToAcceptConnection() throws Exception { - remote.setHost(InetAddress.getLocalHost().getHostName()); - remote.setPort(6000); - remote.setAcceptConnectionTimeout(DELAY / 4); - remote.start(); - assertTrue(remote.awaitConnectorCreated(DELAY / 2)); + receiver.setRemoteHost(InetAddress.getLocalHost().getHostName()); + receiver.setPort(6000); + receiver.setAcceptConnectionTimeout(DELAY / 4); + receiver.start(); + assertTrue(receiver.awaitConnectorCreated(DELAY / 2)); // note that we don't call serverSocket.accept() here - // but stop (in tearDown) should still clean up everything + // but processPriorToRemoval (in tearDown) should still clean up everything } @Test public void testServerDropsConnection() throws Exception { - remote.setHost(InetAddress.getLocalHost().getHostName()); - remote.setPort(6000); - remote.start(); - assertTrue(remote.awaitConnectorCreated(DELAY)); + receiver.setRemoteHost(InetAddress.getLocalHost().getHostName()); + receiver.setPort(6000); + receiver.start(); + assertTrue(receiver.awaitConnectorCreated(DELAY)); Socket socket = serverSocket.accept(); socket.close(); } @Test public void testDispatchEventForEnabledLevel() throws Exception { - remote.setHost(InetAddress.getLocalHost().getHostName()); - remote.setPort(6000); - remote.start(); - assertTrue(remote.awaitConnectorCreated(DELAY)); + receiver.setRemoteHost(InetAddress.getLocalHost().getHostName()); + receiver.setPort(6000); + receiver.start(); + assertTrue(receiver.awaitConnectorCreated(DELAY)); Socket socket = serverSocket.accept(); ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream()); @@ -180,10 +184,10 @@ public class SocketRemoteTest { @Test public void testNoDispatchEventForDisabledLevel() throws Exception { - remote.setHost(InetAddress.getLocalHost().getHostName()); - remote.setPort(6000); - remote.start(); - assertTrue(remote.awaitConnectorCreated(DELAY)); + receiver.setRemoteHost(InetAddress.getLocalHost().getHostName()); + receiver.setPort(6000); + receiver.start(); + assertTrue(receiver.awaitConnectorCreated(DELAY)); Socket socket = serverSocket.accept(); ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream()); @@ -200,12 +204,11 @@ public class SocketRemoteTest { } /** - * A {@link SocketRemote} with instrumentation for unit testing. + * A {@link SocketReceiver} with instrumentation for unit testing. */ - private class InstrumentedSocketRemote extends SocketRemote { + private class InstrumentedSocketReceiver extends SocketReceiver { private boolean connectorCreated; - private boolean executorCreated; @Override protected synchronized SocketConnector newConnector( @@ -220,11 +223,6 @@ public class SocketRemoteTest { return socketFactory; } - @Override - protected ExecutorService createExecutorService() { - return executor; - } - public synchronized boolean awaitConnectorCreated(long delay) throws InterruptedException { while (!connectorCreated) { @@ -233,10 +231,6 @@ public class SocketRemoteTest { return connectorCreated; } - public boolean isExecutorCreated() { - return executorCreated; - } - } /** @@ -250,14 +244,7 @@ public class SocketRemoteTest { this.socket = socket; } - public void run() { - } - - public Socket awaitConnection() throws InterruptedException { - return awaitConnection(Long.MAX_VALUE); - } - - public Socket awaitConnection(long delay) throws InterruptedException { + public Socket call() throws InterruptedException { return socket; } diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java index 3b199c12c6bf15ac8d3ab1e114f63d940821e673..cf4da4a3770bbabc677b1a0ac439ec81d07d52b5 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -183,7 +183,7 @@ public class SyslogAppenderTest { @Test public void large() throws InterruptedException { - setMockServerAndConfigure(1); + setMockServerAndConfigure(2); StringBuilder largeBuf = new StringBuilder(); for (int i = 0; i < 2 * 1024 * 1024; i++) { largeBuf.append('a'); @@ -197,15 +197,24 @@ public class SyslogAppenderTest { mockServer.join(8000); assertTrue(mockServer.isFinished()); - - // the first message is wasted - assertEquals(1, mockServer.getMessageList().size()); - String msg = mockServer.getMessageList().get(0); - String expected = "<" + + // both messages received + assertEquals(2, mockServer.getMessageList().size()); + + String expected = "<" + (SyslogConstants.LOG_MAIL + SyslogConstants.DEBUG_SEVERITY) + ">"; - assertTrue(msg.startsWith(expected)); String expectedPrefix = "<\\d{2}>\\w{3} \\d{2} \\d{2}(:\\d{2}){2} [\\w.-]* "; String threadName = Thread.currentThread().getName(); + + // large message is truncated + String largeMsg = mockServer.getMessageList().get(0); + assertTrue(largeMsg.startsWith(expected)); + String largeRegex = expectedPrefix + "\\[" + threadName + "\\] " + loggerName + + " " + "a{64000,66000}"; + checkRegexMatch(largeMsg, largeRegex); + + String msg = mockServer.getMessageList().get(1); + assertTrue(msg.startsWith(expected)); String regex = expectedPrefix + "\\[" + threadName + "\\] " + loggerName + " " + logMsg; checkRegexMatch(msg, regex); diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockAppender.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockAppender.java index d9159698453469af3c156b966fc4821d648ce907..66e46afab6f3d92d505452b501dfc353ca001f44 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockAppender.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockObjectMessage.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockObjectMessage.java index 2bd903dc1996f14098cc2f54df670c0f171ec68e..bdcc36e0467477970919315a8b503ed9b28e871e 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockObjectMessage.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockObjectMessage.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueue.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueue.java index fefdca832ab015817e3b2fb3dedeb08349385fd4..f7648fb11c215dd8017f65612971124f867e8723 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueue.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueue.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueConnection.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueConnection.java index e6458f156bb8d0d73361767d1b3f208666379397..b3850770015b7fb7140e1bbaceff586171d7d9b9 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueConnection.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueConnection.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueConnectionFactory.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueConnectionFactory.java index 589026b6eb323ce296df342f430776d5788b22cf..96aba7d605f21e41e7ab3e6979cf12da5b17a4a6 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueConnectionFactory.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueConnectionFactory.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueSender.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueSender.java index 7ff1019cc4d4fa3803c525e78908982152a805d3..fdee3e054b0a357e9a39bb90f6b39237f2aa1700 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueSender.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueSender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueSession.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueSession.java index 1e97dcf80a144ee8f55fd6ecb58bac9ac3810c00..139b3636b793eac308641906801af5a23fa8466a 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueSession.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueSession.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockSyslogServer.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockSyslogServer.java index a0bd6a64f34ac35b0a4ebe841be2aaf1e2204904..a74f84b0a33005c282c615e91ab678e5c2c49e8e 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockSyslogServer.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockSyslogServer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -44,7 +44,7 @@ public class MockSyslogServer extends Thread { socket = new DatagramSocket(port); for (int i = 0; i < loopLen; i++) { - byte[] buf = new byte[2048]; + byte[] buf = new byte[65536]; DatagramPacket packet = new DatagramPacket(buf, buf.length); //System.out.println("Waiting for message"); socket.receive(packet); diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopic.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopic.java index 4a46555a29ffd9efa556a144d282a89102f423fc..cfffd8f6ed4d4eb8d6c759742c962f38ee2beba3 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopic.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopic.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicConnection.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicConnection.java index 4c0addaa6f1a3d96ccee7efa7bdf536afb066b52..92dc5df4a4be89f481b4e862860d6e55e7dc64ae 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicConnection.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicConnection.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicConnectionFactory.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicConnectionFactory.java index eb01d86425076607ad54dc446992334df0bdbec9..b8e4ca596e1a02e1a87d9b0f9640cd5e7595fb15 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicConnectionFactory.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicConnectionFactory.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicPublisher.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicPublisher.java index 89e2bfd1a89969ac213585aea08baba67aad2c57..106b121050e41037b86c8eaa744af428666d914c 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicPublisher.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicPublisher.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicSession.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicSession.java index cbb0688da91befaf57f4cd23a9797a64c3f12215..83146efc6ef7920c6ace67ca727846d5e236e2ef 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicSession.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicSession.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/InstrumentedSocketServer.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/InstrumentedServerSocketReceiver.java similarity index 85% rename from logback-classic/src/test/java/ch/qos/logback/classic/net/server/InstrumentedSocketServer.java rename to logback-classic/src/test/java/ch/qos/logback/classic/net/server/InstrumentedServerSocketReceiver.java index 895d390133cf88354b9385464ec5da39f6797435..f61d0f7fb8f74636e7d2b529da7c49eaedb26f30 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/InstrumentedSocketServer.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/InstrumentedServerSocketReceiver.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -22,17 +22,17 @@ import javax.net.ServerSocketFactory; import ch.qos.logback.classic.net.server.RemoteAppenderClient; import ch.qos.logback.classic.net.server.RemoteAppenderServerListener; -import ch.qos.logback.classic.net.server.SocketServer; +import ch.qos.logback.classic.net.server.ServerSocketReceiver; import ch.qos.logback.core.net.server.ServerListener; import ch.qos.logback.core.net.server.ServerRunner; /** - * A {@link SocketServer} with instrumentation for unit testing. + * A {@link ServerSocketReceiver} with instrumentation for unit testing. * * @author Carl Harris */ -public class InstrumentedSocketServer extends SocketServer { +public class InstrumentedServerSocketReceiver extends ServerSocketReceiver { private final ServerSocket serverSocket; private final ServerListener listener; @@ -40,11 +40,11 @@ public class InstrumentedSocketServer extends SocketServer { private ServerListener lastListener; - public InstrumentedSocketServer(ServerSocket serverSocket) { + public InstrumentedServerSocketReceiver(ServerSocket serverSocket) { this(serverSocket, new RemoteAppenderServerListener(serverSocket), null); } - public InstrumentedSocketServer(ServerSocket serverSocket, + public InstrumentedServerSocketReceiver(ServerSocket serverSocket, ServerListener listener, ServerRunner runner) { this.serverSocket = serverSocket; diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/MockSSLConfiguration.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/MockSSLConfiguration.java index 8c7a1813adb7e2e8955e5cfd419e4b1d2f8a5df1..537c0ff59212e28fb46141dea30daf443bc561aa 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/MockSSLConfiguration.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/MockSSLConfiguration.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/MockSSLParametersConfiguration.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/MockSSLParametersConfiguration.java index 6e0e13f5e9255413b212cffe583f8bd88115de7b..dc1e08fe580981169aef22fc780e84596fe4341e 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/MockSSLParametersConfiguration.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/MockSSLParametersConfiguration.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/MockThreadPoolFactoryBean.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/MockThreadPoolFactoryBean.java deleted file mode 100644 index 007331220bae6dea60af0641ff886e35ba666425..0000000000000000000000000000000000000000 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/MockThreadPoolFactoryBean.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.classic.net.server; - -import java.util.Collections; -import java.util.List; -import java.util.concurrent.AbstractExecutorService; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.TimeUnit; - -import ch.qos.logback.core.net.server.ThreadPoolFactoryBean; - -/** - * A mock {@link ThreadPoolFactoryBean} with instrumentation for unit testing. - * - * @author Carl Harris - */ -class MockThreadPoolFactoryBean extends ThreadPoolFactoryBean { - - private final MockExecutorService executorService = - new MockExecutorService(); - - private Runnable lastCommand; - - @Override - public ExecutorService createExecutor() { - return executorService; - } - - public Runnable getLastCommand() { - return lastCommand; - } - - private class MockExecutorService extends AbstractExecutorService { - - public void shutdown() { - } - - public List shutdownNow() { - return Collections.emptyList(); - } - - public boolean isShutdown() { - return true; - } - - public boolean isTerminated() { - return true; - } - - public boolean awaitTermination(long timeout, TimeUnit unit) - throws InterruptedException { - return true; - } - - public void execute(Runnable command) { - lastCommand = command; - } - - } - -} diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/RemoteAppenderStreamClientTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/RemoteAppenderStreamClientTest.java index 78718cb3bbf9b830050b470f24fd2861faf07c64..21ba3418ee9a93beb18ba0251a7fba0489770dba 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/RemoteAppenderStreamClientTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/RemoteAppenderStreamClientTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/SSLSocketServerTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/SSLServerSocketReceiverTest.java similarity index 74% rename from logback-classic/src/test/java/ch/qos/logback/classic/net/server/SSLSocketServerTest.java rename to logback-classic/src/test/java/ch/qos/logback/classic/net/server/SSLServerSocketReceiverTest.java index 1fba4a0fa01fac9108e3728b470b629800eed993..2d273638cec4ede0bec8f862ef60e4daaf29efa0 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/SSLSocketServerTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/SSLServerSocketReceiverTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -21,14 +21,14 @@ import javax.net.ServerSocketFactory; import org.junit.Before; import org.junit.Test; -import ch.qos.logback.core.net.server.MockContext; +import ch.qos.logback.core.net.mock.MockContext; /** - * Unit tests for {@link SSLSocketServer}. + * Unit tests for {@link SSLServerSocketReceiver}. * * @author Carl Harris */ -public class SSLSocketServerTest { +public class SSLServerSocketReceiverTest { private MockContext context = new MockContext(); @@ -37,18 +37,18 @@ public class SSLSocketServerTest { private MockSSLParametersConfiguration parameters = new MockSSLParametersConfiguration(); - private SSLSocketServer socketServer = new SSLSocketServer(); + private SSLServerSocketReceiver receiver = new SSLServerSocketReceiver(); @Before public void setUp() throws Exception { - socketServer.setContext(context); - socketServer.setSsl(ssl); + receiver.setContext(context); + receiver.setSsl(ssl); ssl.setParameters(parameters); } @Test public void testGetServerSocketFactory() throws Exception { - ServerSocketFactory socketFactory = socketServer.getServerSocketFactory(); + ServerSocketFactory socketFactory = receiver.getServerSocketFactory(); assertNotNull(socketFactory); assertTrue(ssl.isContextCreated()); assertTrue(parameters.isContextInjected()); diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/SocketServerFunctionalTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/ServerSocketReceiverFunctionalTest.java similarity index 79% rename from logback-classic/src/test/java/ch/qos/logback/classic/net/server/SocketServerFunctionalTest.java rename to logback-classic/src/test/java/ch/qos/logback/classic/net/server/ServerSocketReceiverFunctionalTest.java index 182eeb48d2a20ca747618a3c34d52ab7351bc735..b8135d4b44984c1b5bcdbe3c5cac465ae305ac24 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/SocketServerFunctionalTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/ServerSocketReceiverFunctionalTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -22,13 +22,11 @@ import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.slf4j.LoggerFactory; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; @@ -38,16 +36,15 @@ import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.LoggingEvent; import ch.qos.logback.classic.spi.LoggingEventVO; import ch.qos.logback.core.net.server.ServerSocketUtil; -import ch.qos.logback.core.net.server.ThreadPoolFactoryBean; /** - * A functional test for {@link SocketServer}. + * A functional test for {@link ServerSocketReceiver}. *

* In this test we create a SocketServer, connect to it over the local * network interface, and validate that it receives messages and delivers * them to its appender. */ -public class SocketServerFunctionalTest { +public class ServerSocketReceiverFunctionalTest { private static final int EVENT_COUNT = 10; private static final int SHUTDOWN_DELAY = 10000; @@ -55,12 +52,12 @@ public class SocketServerFunctionalTest { private MockAppender appender; private Logger logger; private ServerSocket serverSocket; - private ExecutorService executor = Executors.newFixedThreadPool(2); - private InstrumentedSocketServer socketServer; + private InstrumentedServerSocketReceiver receiver; + private LoggerContext lc; @Before public void setUp() throws Exception { - LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + lc = new LoggerContext(); appender = new MockAppender(); appender.start(); @@ -70,21 +67,17 @@ public class SocketServerFunctionalTest { serverSocket = ServerSocketUtil.createServerSocket(); - socketServer = new InstrumentedSocketServer(serverSocket); - - socketServer.setThreadPool(new ThreadPoolFactoryBean() { - @Override - public ExecutorService createExecutor() { - return executor; - } - }); - - socketServer.setContext(lc); + receiver = new InstrumentedServerSocketReceiver(serverSocket); + + receiver.setContext(lc); + receiver.start(); } @After public void tearDown() throws Exception { - socketServer.stop(); + receiver.stop(); + ExecutorService executor = lc.getExecutorService(); + executor.shutdownNow(); executor.awaitTermination(SHUTDOWN_DELAY, TimeUnit.MILLISECONDS); assertTrue(executor.isTerminated()); } @@ -93,7 +86,6 @@ public class SocketServerFunctionalTest { public void testLogEventFromClient() throws Exception { ILoggingEvent event = new LoggingEvent(logger.getName(), logger, Level.DEBUG, "test message", null, new Object[0]); - socketServer.start(); Socket socket = new Socket(InetAddress.getLocalHost(), serverSocket.getLocalPort()); diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/SocketServerTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/ServerSocketReceiverTest.java similarity index 64% rename from logback-classic/src/test/java/ch/qos/logback/classic/net/server/SocketServerTest.java rename to logback-classic/src/test/java/ch/qos/logback/classic/net/server/ServerSocketReceiverTest.java index d870cb7273e7f5e61349ca8c08ea1d80d47a91e7..4fc7bc4413da93ca4018abcabf42a967a575eb35 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/SocketServerTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/ServerSocketReceiverTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -26,7 +26,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import ch.qos.logback.core.net.server.MockContext; +import ch.qos.logback.core.net.mock.MockContext; import ch.qos.logback.core.net.server.MockServerListener; import ch.qos.logback.core.net.server.MockServerRunner; import ch.qos.logback.core.net.server.ServerSocketUtil; @@ -34,11 +34,11 @@ import ch.qos.logback.core.status.ErrorStatus; import ch.qos.logback.core.status.Status; /** - * Unit tests for {@link SocketServer}. + * Unit tests for {@link ServerSocketReceiver}. * * @author Carl Harris */ -public class SocketServerTest { +public class ServerSocketReceiverTest { private MockContext context = new MockContext(); @@ -48,18 +48,14 @@ public class SocketServerTest { private MockServerListener listener = new MockServerListener(); - private MockThreadPoolFactoryBean threadPool = - new MockThreadPoolFactoryBean(); - private ServerSocket serverSocket; - private InstrumentedSocketServer socketServer; + private InstrumentedServerSocketReceiver receiver; @Before public void setUp() throws Exception { serverSocket = ServerSocketUtil.createServerSocket(); - socketServer = new InstrumentedSocketServer(serverSocket, listener, runner); - socketServer.setThreadPool(threadPool); - socketServer.setContext(context); + receiver = new InstrumentedServerSocketReceiver(serverSocket, listener, runner); + receiver.setContext(context); } @After @@ -69,42 +65,29 @@ public class SocketServerTest { @Test public void testStartStop() throws Exception { - socketServer.start(); + receiver.start(); assertTrue(runner.isContextInjected()); - assertTrue(runner.isStarted()); - assertSame(listener, socketServer.getLastListener()); + assertTrue(runner.isRunning()); + assertSame(listener, receiver.getLastListener()); - socketServer.stop(); - assertFalse(runner.isStarted()); - } - - @Test - public void testStartThrowsException() throws Exception { - IOException ex = new IOException("test exception"); - runner.setStartException(ex); - socketServer.start(); - assertFalse(socketServer.isStarted()); - Status status = context.getLastStatus(); - assertNotNull(status); - assertTrue(status instanceof ErrorStatus); - assertTrue(status.getMessage().contains(ex.getMessage())); - assertSame(ex, status.getThrowable()); + receiver.stop(); + assertFalse(runner.isRunning()); } @Test public void testStartWhenAlreadyStarted() throws Exception { - socketServer.start(); - socketServer.start(); + receiver.start(); + receiver.start(); assertEquals(1, runner.getStartCount()); } @Test public void testStopThrowsException() throws Exception { - socketServer.start(); - assertTrue(socketServer.isStarted()); + receiver.start(); + assertTrue(receiver.isStarted()); IOException ex = new IOException("test exception"); runner.setStopException(ex); - socketServer.stop(); + receiver.stop(); Status status = context.getLastStatus(); assertNotNull(status); @@ -115,7 +98,7 @@ public class SocketServerTest { @Test public void testStopWhenNotStarted() throws Exception { - socketServer.stop(); + receiver.stop(); assertEquals(0, runner.getStartCount()); } diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/Builder.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/Builder.java index 022a216d1b7b1a68ba7d8722f38935fdb68573f0..2bc6317d0e939e343013e9b7bc166f4a0a71fd3d 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/Builder.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/Builder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventBuilderInContext.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventBuilderInContext.java index 2e5879abd08b62e0f04b103ea7108ddafdab180b..61f3fb16277852f37075ee9c1e91d7142cb576b6 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventBuilderInContext.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventBuilderInContext.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.classic.net.testObjectBuilders; import ch.qos.logback.classic.Level; diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventWithParametersBuilder.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventWithParametersBuilder.java index 728d7934d0280a6ab2e634bcf8ca6d55251df2b0..bfe4417d92808fb9c8e4ed78836d67c81c3d85ce 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventWithParametersBuilder.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventWithParametersBuilder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/MinimalSerBuilder.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/MinimalSerBuilder.java index 5ab66d13b7b750254bc2b34bd089b51731280ee8..7226c7593b8ba7bdaf8a183986be4114c9ee4928 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/MinimalSerBuilder.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/MinimalSerBuilder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/TrivialLoggingEventBuilder.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/TrivialLoggingEventBuilder.java index 53edf36e2e60257e9fe468e7b5bdba078535ec68..11f661bc7660cee166c1dfd138b9063eda2ec848 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/TrivialLoggingEventBuilder.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/TrivialLoggingEventBuilder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/TrivialLoggingEventVOBuilder.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/TrivialLoggingEventVOBuilder.java index d04c2d1d49baf82140aa2829c8e7cb9985f66230..9bdf3c0337efd44a1a9426601440c3891d7464c2 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/TrivialLoggingEventVOBuilder.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/TrivialLoggingEventVOBuilder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java index 7a144f96de3b9893c1bae7daee5e475ec3d01f3c..56a7d05348e0ff42023d81d91a76b33b358b62c1 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverterTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverterTest.java index 3baa23ae20fc06559f539224b6fbcc2631f1d46e..a383243eaf9eb52113d270b57527c06585a8bf19 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverterTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverterTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/MDCConverterTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/MDCConverterTest.java old mode 100644 new mode 100755 index 5881e4fd5fdf65a902714a942a0aeab7ffd74b7a..df9b10fa845b822dcb8f02d01512825ca87cb312 --- a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/MDCConverterTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/MDCConverterTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -14,7 +14,9 @@ package ch.qos.logback.classic.pattern; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import ch.qos.logback.core.testUtil.RandomUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -31,12 +33,14 @@ public class MDCConverterTest { LoggerContext lc; MDCConverter converter; + int diff = RandomUtil.getPositiveInt(); @Before public void setUp() throws Exception { lc = new LoggerContext(); converter = new MDCConverter(); converter.start(); + MDC.clear(); } @After @@ -44,29 +48,28 @@ public class MDCConverterTest { lc = null; converter.stop(); converter = null; + MDC.clear(); } @Test - public void testConverWithOneEntry() { - MDC.clear(); - MDC.put("testKey", "testValue"); + public void testConvertWithOneEntry() { + String k = "MDCConverterTest_k"+diff; + String v = "MDCConverterTest_v"+diff; + + MDC.put(k, v); ILoggingEvent le = createLoggingEvent(); String result = converter.convert(le); - assertEquals("testKey=testValue", result); + assertEquals(k+"="+v, result); } @Test - public void testConverWithMultipleEntries() { - MDC.clear(); + public void testConvertWithMultipleEntries() { MDC.put("testKey", "testValue"); MDC.put("testKey2", "testValue2"); ILoggingEvent le = createLoggingEvent(); String result = converter.convert(le); - if (SystemInfo.getJavaVendor().contains("IBM")) { - assertEquals("testKey2=testValue2, testKey=testValue", result); - } else { - assertEquals("testKey=testValue, testKey2=testValue2", result); - } + boolean isConform = result.matches("testKey2?=testValue2?, testKey2?=testValue2?"); + assertTrue(result + " is not conform", isConform); } private ILoggingEvent createLoggingEvent() { diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/MarkerConverterTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/MarkerConverterTest.java index 92397df4d71ae6e051a7dbc57f35fefda06bad67..c76404763ca25eeeb290f9ec00dc0afc92b13081 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/MarkerConverterTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/MarkerConverterTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/PackageTest.java index 64228e9329128e0d902d16e7c2ac3fac6d8a34da..21f445ac7748c63899017696a2211d01eb907b22 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/PackageTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/RootCauseFirstThrowableProxyConverterTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/RootCauseFirstThrowableProxyConverterTest.java index ccd0873629482584678ebd04108b797f913af489..cd982bb572237c870022bdda61f6c4f8b52f3b96 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/RootCauseFirstThrowableProxyConverterTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/RootCauseFirstThrowableProxyConverterTest.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.classic.pattern; import ch.qos.logback.classic.Level; diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviatorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviatorTest.java index 7a64e9b690896bdb657f867d4defeb37d4315259..db5aac83ae1ab0233760be04bf9e45ec15cd14e7 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviatorTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviatorTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java index 4b63b981e59c261afef2cf9f570f44fb4ed1e4cf..34784d3e2a24536a9939a4b7c0719a8d9ac2fa2e 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,10 +13,12 @@ */ package ch.qos.logback.classic.pattern; -import static org.junit.Assert.assertEquals; - +import java.io.BufferedReader; import java.io.PrintWriter; +import java.io.StringReader; import java.io.StringWriter; +import java.util.Arrays; +import java.util.List; import org.junit.After; import org.junit.Before; @@ -29,6 +31,8 @@ import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.LoggingEvent; import ch.qos.logback.classic.util.TeztHelper; +import static org.junit.Assert.*; + public class ThrowableProxyConverterTest { LoggerContext lc = new LoggerContext(); @@ -64,6 +68,42 @@ public class ThrowableProxyConverterTest { verify(t); } + @Test + public void withArgumentOfOne() throws Exception { + final Throwable t = TeztHelper.makeNestedException(0); + t.printStackTrace(pw); + final ILoggingEvent le = createLoggingEvent(t); + + final List optionList = Arrays.asList("1"); + tpc.setOptionList(optionList); + tpc.start(); + + final String result = tpc.convert(le); + + final BufferedReader reader = new BufferedReader(new StringReader(result)); + assertTrue(reader.readLine().contains(t.getMessage())); + assertNotNull(reader.readLine()); + assertNull("Unexpected line in stack trace", reader.readLine()); + } + + @Test + public void withShortArgument() throws Exception { + final Throwable t = TeztHelper.makeNestedException(0); + t.printStackTrace(pw); + final ILoggingEvent le = createLoggingEvent(t); + + final List options = Arrays.asList("short"); + tpc.setOptionList(options); + tpc.start(); + + final String result = tpc.convert(le); + + final BufferedReader reader = new BufferedReader(new StringReader(result)); + assertTrue(reader.readLine().contains(t.getMessage())); + assertNotNull(reader.readLine()); + assertNull("Unexpected line in stack trace", reader.readLine()); + } + void verify(Throwable t) { t.printStackTrace(pw); @@ -73,6 +113,4 @@ public class ThrowableProxyConverterTest { result = result.replace("common frames omitted", "more"); assertEquals(sw.toString(), result); } - - } diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/rolling/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/rolling/PackageTest.java index 8c1e86f95633f4231b6614cd31128cc5bc1022c4..8fc82a5432e958736bceef6abd5d24ee3aec64b1 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/rolling/PackageTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/rolling/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/rolling/TimeBasedRollingWithConfigFileTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/rolling/TimeBasedRollingWithConfigFileTest.java index 349e1906e65831ac0b555a794d90eb0492bae6d2..614dc0450a20ecc9c5610dc7aa35b8342b4f2719 100755 --- a/logback-classic/src/test/java/ch/qos/logback/classic/rolling/TimeBasedRollingWithConfigFileTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/rolling/TimeBasedRollingWithConfigFileTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/rolling/UniqueFileTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/rolling/UniqueFileTest.java index d3170e3aca2fcbfaf97b4fe399dab631afc5da52..b2a96e31fb4f3cf833be2bce5cc0291d35fd2dc5 100755 --- a/logback-classic/src/test/java/ch/qos/logback/classic/rolling/UniqueFileTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/rolling/UniqueFileTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java index a96c20937f49fe195e84e8f02b68f6ba9b3b345e..9c2b39fc0d1d841fba5463c439e1c1d328e9567a 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextJNDISelectorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextJNDISelectorTest.java index fc298bcc31988c26d62f847b7627487fe61896cc..d2538af23417cb87fe613a171ceacc94e0f4d063 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextJNDISelectorTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextJNDISelectorTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/selector/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/selector/PackageTest.java index 88d8eb83b5777f4250f498b244c9fc2c1783a5fb..72b7b047653de8f8bc3d7721ec281b79bd21685f 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/selector/PackageTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/selector/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/sift/MDCBasedDiscriminatorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/sift/MDCBasedDiscriminatorTest.java old mode 100644 new mode 100755 index 08ef733adbb2e790f35c6ae4e8efd575b25ec2e0..d1b08d87484bb3164367d18fd65f12e572a58b5b --- a/logback-classic/src/test/java/ch/qos/logback/classic/sift/MDCBasedDiscriminatorTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/sift/MDCBasedDiscriminatorTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -42,8 +42,8 @@ public class MDCBasedDiscriminatorTest { Logger logger = context.getLogger(this.getClass()); int diff = RandomUtil.getPositiveInt(); - String key = "k" + diff; - String value = "val" + diff; + String key = "MDCBasedDiscriminatorTest_key" + diff; + String value = "MDCBasedDiscriminatorTest_val" + diff; LoggingEvent event; @Before diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/sift/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/sift/PackageTest.java index 5d90607995643f27d4b0ddf352d0eaad45aa6b59..d66fe4ca9bace69282d931e3e3737769eaed91ce 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/sift/PackageTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/sift/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/sift/SiftingAppenderTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/sift/SiftingAppenderTest.java index 50f5454ce95bb8c84ec84ca59c7375de402cfa4e..d998dc22e1f79a929fce84d2de4095fc142dc5d8 100755 --- a/logback-classic/src/test/java/ch/qos/logback/classic/sift/SiftingAppenderTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/sift/SiftingAppenderTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,31 +13,29 @@ */ package ch.qos.logback.classic.sift; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.junit.Test; -import org.slf4j.MDC; - -import ch.qos.logback.classic.ClassicTestConstants; -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.*; import ch.qos.logback.classic.joran.JoranConfigurator; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.LoggingEvent; +import ch.qos.logback.core.Appender; import ch.qos.logback.core.helpers.NOPAppender; import ch.qos.logback.core.joran.spi.JoranException; import ch.qos.logback.core.read.ListAppender; import ch.qos.logback.core.sift.AppenderTracker; +import ch.qos.logback.core.spi.AbstractComponentTracker; +import ch.qos.logback.core.spi.ComponentTracker; import ch.qos.logback.core.status.ErrorStatus; import ch.qos.logback.core.status.StatusChecker; +import ch.qos.logback.core.testUtil.RandomUtil; import ch.qos.logback.core.testUtil.StringListAppender; import ch.qos.logback.core.util.StatusPrinter; +import org.junit.Test; +import org.slf4j.MDC; + +import java.util.List; + +import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class SiftingAppenderTest { @@ -46,8 +44,10 @@ public class SiftingAppenderTest { LoggerContext loggerContext = new LoggerContext(); Logger logger = loggerContext.getLogger(this.getClass().getName()); Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); - StatusChecker sc = new StatusChecker(loggerContext); - + StatusChecker statusChecker = new StatusChecker(loggerContext); + int diff = RandomUtil.getPositiveInt(); + int now = 0; + protected void configure(String file) throws JoranException { JoranConfigurator jc = new JoranConfigurator(); jc.setContext(loggerContext); @@ -66,16 +66,19 @@ public class SiftingAppenderTest { public void smoke() throws JoranException { configure(SIFT_FOLDER_PREFIX + "smoke.xml"); logger.debug("smoke"); - long timestamp = 0; - SiftingAppender ha = (SiftingAppender) root.getAppender("SIFT"); - ListAppender listAppender = (ListAppender) ha - .getAppenderTracker().get("smoke", timestamp); - assertNotNull(listAppender); + Appender appender = getAppenderTracker().find("smokeDefault"); + assertNotNull(appender); + ListAppender listAppender = (ListAppender) appender; List eventList = listAppender.list; assertEquals(1, listAppender.list.size()); assertEquals("smoke", eventList.get(0).getMessage()); } + private AppenderTracker getAppenderTracker() { + SiftingAppender ha = (SiftingAppender) root.getAppender("SIFT"); + return ha.getAppenderTracker(); + } + @Test public void zeroNesting() throws JoranException { configure(SIFT_FOLDER_PREFIX + "zeroNesting.xml"); @@ -84,18 +87,14 @@ public class SiftingAppenderTest { logger.debug("hello"); logger.debug("hello"); logger.debug("hello"); - - long timestamp = 0; - SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT"); - NOPAppender nopa = (NOPAppender) sa - .getAppenderTracker().get("smoke", timestamp); + + Appender appender = getAppenderTracker().find("zeroDefault"); + assertNotNull(appender); + NOPAppender nopa = (NOPAppender) appender; StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext); - assertNotNull(nopa); - sc.assertContainsMatch(ErrorStatus.ERROR, "No nested appenders found"); - sc.assertContainsMatch(ErrorStatus.ERROR, - "Failed to build an appender for discriminating value \\[smoke\\]"); + statusChecker.assertContainsMatch(ErrorStatus.ERROR, "No nested appenders found"); } @Test @@ -105,26 +104,21 @@ public class SiftingAppenderTest { logger.debug("hello"); logger.debug("hello"); - long timestamp = 0; - - SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT"); - ListAppender listAppender = (ListAppender) sa - .getAppenderTracker().get("smoke", timestamp); + Appender listAppender = getAppenderTracker().find("multipleDefault"); StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext); assertNotNull(listAppender); - sc.assertContainsMatch(ErrorStatus.ERROR, - "Only and only one appender can be nested"); + statusChecker.assertContainsMatch(ErrorStatus.ERROR, + "Only and only one appender can be nested"); } @Test public void defaultLayoutRule() throws JoranException { configure(SIFT_FOLDER_PREFIX + "defaultLayoutRule.xml"); logger.debug("hello"); - long timestamp = 0; SiftingAppender ha = (SiftingAppender) root.getAppender("SIFT"); StringListAppender listAppender = (StringListAppender) ha - .getAppenderTracker().get("default", timestamp); + .getAppenderTracker().find("default"); assertNotNull(listAppender); List strList = listAppender.strList; @@ -139,9 +133,9 @@ public class SiftingAppenderTest { MDC.put(mdcKey, "a"); logger.debug("smoke"); long timestamp = System.currentTimeMillis(); - SiftingAppender ha = (SiftingAppender) root.getAppender("SIFT"); - ListAppender listAppender = (ListAppender) ha - .getAppenderTracker().get("a", timestamp); + SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT"); + ListAppender listAppender = (ListAppender) + sa.getAppenderTracker().find("a"); assertNotNull(listAppender); List eventList = listAppender.list; assertEquals(1, listAppender.list.size()); @@ -149,12 +143,130 @@ public class SiftingAppenderTest { MDC.remove(mdcKey); LoggingEvent le = new LoggingEvent("x", logger, Level.INFO, "hello", null, - null); - le.setTimeStamp(timestamp + AppenderTracker.THRESHOLD * 2); - ha.doAppend(le); + null); + le.setTimeStamp(timestamp + ComponentTracker.DEFAULT_TIMEOUT + 1); + sa.doAppend(le); assertFalse(listAppender.isStarted()); - assertEquals(1, ha.getAppenderTracker().keyList().size()); - assertEquals("cycleDefault", ha.getAppenderTracker().keyList().get(0)); + assertEquals(1, sa.getAppenderTracker().allKeys().size()); + assertTrue(sa.getAppenderTracker().allKeys().contains("cycleDefault")); + } + + @Test + public void sessionFinalizationShouldCauseLingering() throws JoranException { + String mdcKey = "linger"; + String mdcVal = "session" + diff; + configure(SIFT_FOLDER_PREFIX + "lingering.xml"); + MDC.put(mdcKey, mdcVal); + logger.debug("linger 1"); + logger.debug(ClassicConstants.FINALIZE_SESSION_MARKER, "linger 2"); + long now = System.currentTimeMillis(); + SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT"); + AppenderTracker tracker = sa.getAppenderTracker(); + + assertEquals(1, tracker.allKeys().size()); + Appender appender = tracker.find(mdcVal); + assertTrue(appender.isStarted()); + + tracker.removeStaleComponents(now + AppenderTracker.LINGERING_TIMEOUT + 1); + // previously lingering appenders should be closed upon timeout + assertFalse(appender.isStarted()); + // and they should be gone + assertEquals(0, tracker.allKeys().size()); + } + + @Test + public void localPropertiesShouldBeVisible() throws JoranException { + String mdcKey = "localProperty"; + String mdcVal = "" + diff; + String msg = "localPropertiesShouldBeVisible"; + String prefix = "Y"; + configure(SIFT_FOLDER_PREFIX + "propertyPropagation.xml"); + MDC.put(mdcKey, mdcVal); + logger.debug(msg); + SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT"); + StringListAppender listAppender = (StringListAppender) sa + .getAppenderTracker().find(mdcVal); + assertNotNull(listAppender); + List strList = listAppender.strList; + assertEquals(1, listAppender.strList.size()); + assertEquals(prefix + msg, strList.get(0)); + } + + @Test + public void propertyDefinedWithinSiftElementShouldBeVisible() throws JoranException { + String mdcKey = "propertyDefinedWithinSift"; + String mdcVal = "" + diff; + String msg = "propertyDefinedWithinSiftElementShouldBeVisible"; + String prefix = "Y"; + configure(SIFT_FOLDER_PREFIX + "propertyDefinedInSiftElement.xml"); + MDC.put(mdcKey, mdcVal); + logger.debug(msg); + SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT"); + StringListAppender listAppender = (StringListAppender) sa + .getAppenderTracker().find(mdcVal); + assertNotNull(listAppender); + List strList = listAppender.strList; + assertEquals(1, listAppender.strList.size()); + assertEquals(prefix + msg, strList.get(0)); + } + + @Test + public void compositePropertyShouldCombineWithinAndWithoutSiftElement() throws JoranException { + String mdcKey = "compositeProperty"; + String mdcVal = "" + diff; + String msg = "compositePropertyShouldCombineWithinAndWithoutSiftElement"; + String prefix = "composite"; + configure(SIFT_FOLDER_PREFIX + "compositeProperty.xml"); + MDC.put(mdcKey, mdcVal); + logger.debug(msg); + SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT"); + StringListAppender listAppender = (StringListAppender) sa + .getAppenderTracker().find(mdcVal); + assertNotNull(listAppender); + List strList = listAppender.strList; + assertEquals(1, listAppender.strList.size()); + assertEquals(prefix + msg, strList.get(0)); + } + + @Test + public void maxAppendersCountPropertyShouldBeHonored() throws JoranException { + configure(SIFT_FOLDER_PREFIX + "maxAppenderCount.xml"); + int max = 5; + SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT"); + String mdcKey = "max"; + for(int i = 0; i <= max; i++) { + MDC.put(mdcKey, "" + (diff + i)); + LoggingEvent event = new LoggingEvent("", logger, Level.DEBUG, "max"+i, null, null); + event.setTimeStamp(now); + sa.doAppend(event); + now += AbstractComponentTracker.WAIT_BETWEEN_SUCCESSIVE_REMOVAL_ITERATIONS; + } + AppenderTracker tracker = sa.getAppenderTracker(); + assertEquals(max, tracker.allKeys().size()); + assertNull(tracker.find("" + (diff + 0))); + for(int i = 1; i <= max; i++) { + assertNotNull(tracker.find("" + (diff + i))); + } + } + + @Test + public void timeoutPropertyShouldBeHonored() throws JoranException, InterruptedException { + configure(SIFT_FOLDER_PREFIX + "timeout.xml"); + long timeout = 30*1000; + SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT"); + + LoggingEvent event = new LoggingEvent("", logger, Level.DEBUG, "timeout", null, null); + event.setTimeStamp(now); + sa.doAppend(event); + + AppenderTracker tracker = sa.getAppenderTracker(); + + assertEquals(1, tracker.getComponentCount()); + + now += timeout+1; + tracker.removeStaleComponents(now); + assertEquals(0, tracker.getComponentCount()); + statusChecker.assertIsErrorFree(); } } diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/BasicContextListener.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/BasicContextListener.java index 3c50f7d14dd6186ccdcbbe93a1ae1799aaeeaf17..5a30b8f1641ea8a3c580eaa4acc505ef3c168352 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/BasicContextListener.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/BasicContextListener.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/BogusClassLoader.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/BogusClassLoader.java index 208fd11cdedbc7bdbf9f150291751ec01a5b205d..eabfc087c05f96b59c6b5e0dffee0253d2661242 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/BogusClassLoader.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/BogusClassLoader.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/CPDCSpecial.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/CPDCSpecial.java index 66e7edcfac9f50b3a44d0acdb7c679c51c79f115..8842ddd1d02d6f09ae333a3aa45f02efb7d7b29f 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/CPDCSpecial.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/CPDCSpecial.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/CallerDataTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/CallerDataTest.java index 47850d8767747f39a1937887f19593841eb02c7d..e99f34142fff363c3a08d65558bee2b7baf09207 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/CallerDataTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/CallerDataTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/ContextListenerTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/ContextListenerTest.java index b8a8751a695ee8d6f0ddeed33a466a0258ae95c7..3912a58e295962953002ade7409d29ebd959c436 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/ContextListenerTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/ContextListenerTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/DummyThrowableProxy.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/DummyThrowableProxy.java index b6e48bd176fd6eba87d1863e72001bcd5aef2a8d..0d9c554cdf2823e3f01b6c7cd6cd6d2fba7bbf74 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/DummyThrowableProxy.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/DummyThrowableProxy.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/LocalFirstClassLoader.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/LocalFirstClassLoader.java index 4fcaf8d2d93c964d9a44b846e7f8582f2a587e8f..7c2be9a9786a7d8482483d5e255fdf46aa0a40b2 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/LocalFirstClassLoader.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/LocalFirstClassLoader.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggerComparatorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggerComparatorTest.java index ea5d35595130c0a080b1ebc7f5e8cd413b5e7103..a752d472e9e9d61c238bd443b5230e6fad19d918 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggerComparatorTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggerComparatorTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationPerfTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationPerfTest.java index ecc6a1d357ec78d1abd82cca2eea51686b9cff09..02a3cf13ce1bf071c89e27c94f535d1a69d8bcff 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationPerfTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationPerfTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java index 2d73426db2a59181534cbde134a7a21a62ea795b..24e88606770487caed65ed0f8e07283fe701ddfe 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventTest.java new file mode 100755 index 0000000000000000000000000000000000000000..c68902212639b36b57912380ffaa5f331ca05208 --- /dev/null +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventTest.java @@ -0,0 +1,65 @@ +package ch.qos.logback.classic.spi; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.LoggerContext; +import org.junit.Before; +import org.junit.Test; + +import static junit.framework.Assert.assertNull; +import static org.junit.Assert.assertEquals; + +public class LoggingEventTest { + + LoggerContext loggerContext = new LoggerContext(); + Logger logger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); + + @Before + public void setUp() { + } + + + @Test + public void testFormattingOneArg() { + String message = "x={}"; + Throwable throwable = null; + Object[] argArray = new Object[] {12}; + + LoggingEvent event = new LoggingEvent("", logger, Level.INFO, message, throwable, argArray); + assertNull(event.formattedMessage); + assertEquals("x=12", event.getFormattedMessage()); + } + + + @Test + public void testFormattingTwoArg() { + String message = "{}-{}"; + Throwable throwable = null; + Object[] argArray = new Object[] {12, 13}; + LoggingEvent event = new LoggingEvent("", logger, Level.INFO, message, throwable, argArray); + + assertNull(event.formattedMessage); + assertEquals("12-13", event.getFormattedMessage()); + } + + + @Test + public void testNoFormattingWithArgs() { + String message = "testNoFormatting"; + Throwable throwable = null; + Object[] argArray = new Object[] {12, 13}; + LoggingEvent event = new LoggingEvent("", logger, Level.INFO, message, throwable, argArray); + assertNull(event.formattedMessage); + assertEquals(message, event.getFormattedMessage()); + } + + @Test + public void testNoFormattingWithoutArgs() { + String message = "testNoFormatting"; + Throwable throwable = null; + Object[] argArray = null; + LoggingEvent event = new LoggingEvent("", logger, Level.INFO, message, throwable, argArray); + assertNull(event.formattedMessage); + assertEquals(message, event.getFormattedMessage()); + } +} diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/LuckyCharms.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/LuckyCharms.java index 0048286e29757c14e4e08b0d8f9029a01c78f374..941a40588207c21c4359edd0182fe60dcb375fcb 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/LuckyCharms.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/LuckyCharms.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/PackageTest.java index 15a55ebdf6e25dc886babb494e0a6c15bc8c81d5..b9214201dc2d07d1c98c7490df05e45f98ffa8bd 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/PackageTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -19,7 +19,7 @@ import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses( { ContextListenerTest.class, CallerDataTest.class, - LoggerComparatorTest.class, LoggingEventSerializationTest.class, + LoggerComparatorTest.class, LoggingEventTest.class, LoggingEventSerializationTest.class, LoggingEventSerializationPerfTest.class, ThrowableProxyTest.class, PackagingDataCalculatorTest.class }) public class PackageTest { diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/PackagingDataCalculatorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/PackagingDataCalculatorTest.java index 385dcfde3ea023f15f832fb70b2fae952291daff..c499d3309e8a4f5107d7db42063384e87e02fabb 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/PackagingDataCalculatorTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/PackagingDataCalculatorTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/PubLoggingEventVO.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/PubLoggingEventVO.java index 3018f62166c2804f30b4b35da3babd801344f7c8..d8d90cbda308d7cdbe648a6687ab01e97a59dfb9 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/PubLoggingEventVO.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/PubLoggingEventVO.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableProxyTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableProxyTest.java index d5ff8248cdbb9e5540be25579c97adf76e8303c3..2d0aba0ee87eb804fd9b4fda747b61454cdb5e17 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableProxyTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableProxyTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/special/CPDCSpecialImpl.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/special/CPDCSpecialImpl.java index a8d6bc593de8293170403363a43e6e467c7f81b5..41e3c64a70c159fa012290c4eff79504779f339a 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/special/CPDCSpecialImpl.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/special/CPDCSpecialImpl.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/testUtil/SampleConverter.java b/logback-classic/src/test/java/ch/qos/logback/classic/testUtil/SampleConverter.java index 2ea49586f05dab7449185fd478caf675214bd67c..7d93da14c7e191b8c15224d34a7b67e84fd699c0 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/testUtil/SampleConverter.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/testUtil/SampleConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/DebugUsersTurboFilter.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/DebugUsersTurboFilter.java index e74980e598fba506cd82f36580f5dfee945f82e9..b6285038a96530a329e8c28a67e5c5fd4abccc35 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/DebugUsersTurboFilter.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/DebugUsersTurboFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/DuplicateMessageFilterTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/DuplicateMessageFilterTest.java index 04eacbc93d6df452499fb096dd4231cfad159f62..7f9a8447233e0b37f34627df6278caa729048e4e 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/DuplicateMessageFilterTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/DuplicateMessageFilterTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/LRUMessageCacheTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/LRUMessageCacheTest.java index 3ec9f39770a9d0ef7f500fcd06cde3ff6c25c548..f49bb74377cc75487cb606b8cd5ec8390b82674d 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/LRUMessageCacheTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/LRUMessageCacheTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/MarkerFilterTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/MarkerFilterTest.java index 7d23a8b01b2721ead9d779db2cddcbee33e3f725..20767af66cacdcdcd870bbf190c0fa1677c004cc 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/MarkerFilterTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/MarkerFilterTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/NOPTurboFilter.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/NOPTurboFilter.java index f55f16eab17894ade7203873ef0396cb320c0963..6c8694feebdc09b6536378fae11f7f1a7923a14b 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/NOPTurboFilter.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/NOPTurboFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/PackageTest.java index 2e94ec5915bd2d9e6b28d8b81aaecdc110ca951e..b57aa90bf1d984d32f4df854ed8e40df3d72440a 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/PackageTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigurePerf.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigurePerf.java index c6ce8753af356536b172b2d4e73f12a4c9507ef7..591ddcb472267b1fa4b831f267de59e475feb49a 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigurePerf.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigurePerf.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/Event.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/Event.java index a6e41a650fc5222e4d71aa26859e15473e70e00d..f45978524380b876cc3bb99fab90cc51fd664cbd 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/Event.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/Event.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/LRUCache.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/LRUCache.java index 12b55705ab9af4a7462156697b3db5bfdfde2517..5dc53d1d9f891cfe007ef8b8f49512f254b8d5cc 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/LRUCache.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/LRUCache.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/LRUCacheTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/LRUCacheTest.java index 13c01203168cbb18902106421f2db1affb8b3f0a..f367301fd48e77e9e9622701db7b5af35da58440 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/LRUCacheTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/LRUCacheTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/Simulator.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/Simulator.java index f30588457d3ab16c005411b4dad71f490bf7b073..72bb87942128940846420ff17afdd813fcb9528b 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/Simulator.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/Simulator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/T_Entry.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/T_Entry.java index 4189712c2371b31b6983b0031b3acc560de5661d..dd9bcf3ff8a6e14ec35a8c5ae444f47ec396bda4 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/T_Entry.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/T_Entry.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/T_LRUCache.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/T_LRUCache.java index bc9101d96d02a35889d031c42a2d411556323592..23fdfd69be1993b8305c484359d1f176ad9c1305 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/T_LRUCache.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/T_LRUCache.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/X_LRUCache.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/X_LRUCache.java index 167cca3b632980c736181665a740caa2040ea419..146ab94eb9560227ba2f113c0efc7598796083fa 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/X_LRUCache.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/lru/X_LRUCache.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerAutoConfigTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerAutoConfigTest.java index 8251c8a1fcffd4d3af50e9a873f8fb01b4672fcd..9a83de32cec8c4be21d24c25db7aa07c1533dfe2 100755 --- a/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerAutoConfigTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerAutoConfigTest.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.classic.util; import ch.qos.logback.classic.Logger; diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerTest.java index 98006db5607a18a92e2eb706615964c22f5f200c..ffc5c93accc1b72db997b5ae8865535be82d39cc 100755 --- a/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationIntegrationTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationIntegrationTest.java index 07419271f1078734c62d7f0cc3000c1c7c9ea10f..6354e0fe9fb9c1fe893f12af572043eadf39fe90 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationIntegrationTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationIntegrationTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/util/LevelToSyslogSeverityTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/util/LevelToSyslogSeverityTest.java index 51cfef79aeefb933131503ea36466c3ce045cd3c..9ec55bdd8de66e6ea0a5fa9faf9a803198fba668 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/util/LevelToSyslogSeverityTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/util/LevelToSyslogSeverityTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/util/LogbackMDCAdapterTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/util/LogbackMDCAdapterTest.java index 6918e70d935a7ce9e24db21010c50edfe70df9d3..d05d997a39520211a19dd58ed50f308996d3df5a 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/util/LogbackMDCAdapterTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/util/LogbackMDCAdapterTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/util/LoggerNameUtilTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/util/LoggerNameUtilTest.java index 0efd5e2ff6f590587c355a86b910be9e27485618..1f3614c18f59e3a165c082462ecddb847cebde6f 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/util/LoggerNameUtilTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/util/LoggerNameUtilTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -74,5 +74,29 @@ public class LoggerNameUtilTest { assertEquals(witnessList, partList); } + @Test + public void supportNestedClassesWithNestedDot() { + //LOGBACK-384 + List witnessList = new ArrayList(); + witnessList.add("com"); + witnessList.add("foo"); + witnessList.add("Bar"); + witnessList.add("Nested"); + witnessList.add("dot"); + + List partList = LoggerNameUtil.computeNameParts("com.foo.Bar$Nested.dot"); + assertEquals(witnessList, partList); + } + + @Test + public void supportNestedClassesAtBeginning() { + List witnessList = new ArrayList(); + witnessList.add("foo"); + witnessList.add("Nested"); + witnessList.add("bar"); + + List partList = LoggerNameUtil.computeNameParts("foo$Nested.bar"); + assertEquals(witnessList, partList); + } } diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/util/MockInitialContext.java b/logback-classic/src/test/java/ch/qos/logback/classic/util/MockInitialContext.java index 4cfab67f57bc4f81f35af4e9da5888c704d80764..ea3c5a97f119d268f7d2538b7621c9d07e5501f2 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/util/MockInitialContext.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/util/MockInitialContext.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/util/MockInitialContextFactory.java b/logback-classic/src/test/java/ch/qos/logback/classic/util/MockInitialContextFactory.java index 3ba06f972508e295562115b116e2bf2f75a2b606..06f59d550238e8b7445a376230d7992a22960c16 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/util/MockInitialContextFactory.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/util/MockInitialContextFactory.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/util/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/util/PackageTest.java index 87129bb8c8cbc4f2a4ae35099ffa8506295b3b3c..70ad014cb550495a4d376c5a6b49ff23e6d8e405 100755 --- a/logback-classic/src/test/java/ch/qos/logback/classic/util/PackageTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/util/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/util/TeztHelper.java b/logback-classic/src/test/java/ch/qos/logback/classic/util/TeztHelper.java index badde04c350c4d8692fe0455a9e046343cb0769d..2bee5886e7fc25ea29073b34b6c2d1db9d83d23d 100644 --- a/logback-classic/src/test/java/ch/qos/logback/classic/util/TeztHelper.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/util/TeztHelper.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/integrator/Activator.java b/logback-classic/src/test/java/integrator/Activator.java index 3dfe195a0d30d9ce66f3704cc4f90708de3e5a83..0a7493b9c8539726d4feb92720c4c98eb616f8aa 100644 --- a/logback-classic/src/test/java/integrator/Activator.java +++ b/logback-classic/src/test/java/integrator/Activator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/org/dummy/DummyLBAppender.java b/logback-classic/src/test/java/org/dummy/DummyLBAppender.java index 19957ebd1b01a808f8872618ae067436c5aa555c..5c7fc00f6026b78f61ba6ed8635f690eddafef1b 100644 --- a/logback-classic/src/test/java/org/dummy/DummyLBAppender.java +++ b/logback-classic/src/test/java/org/dummy/DummyLBAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/org/dummy/Log4jInvocation.java b/logback-classic/src/test/java/org/dummy/Log4jInvocation.java index 81c38d1220e4863018854dc483f565f883c8bcbc..f512ce76421e0161328b2c3e63235202016ad24d 100644 --- a/logback-classic/src/test/java/org/dummy/Log4jInvocation.java +++ b/logback-classic/src/test/java/org/dummy/Log4jInvocation.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/org/slf4j/LoggerFactoryFriend.java b/logback-classic/src/test/java/org/slf4j/LoggerFactoryFriend.java index 905f4dacc426291992e3f8a525318d265015be30..ec520e2969b9cb03b7e3f7b56322ccb3e4907288 100644 --- a/logback-classic/src/test/java/org/slf4j/LoggerFactoryFriend.java +++ b/logback-classic/src/test/java/org/slf4j/LoggerFactoryFriend.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/org/slf4j/impl/InitializationOutputTest.java b/logback-classic/src/test/java/org/slf4j/impl/InitializationOutputTest.java index 99039fdece60a7e779829870767d4edc5fc19880..b747d8d1a211d8c76334ab9e3a8734da9aea70ed 100644 --- a/logback-classic/src/test/java/org/slf4j/impl/InitializationOutputTest.java +++ b/logback-classic/src/test/java/org/slf4j/impl/InitializationOutputTest.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package org.slf4j.impl; import ch.qos.logback.classic.ClassicTestConstants; diff --git a/logback-classic/src/test/java/org/slf4j/impl/PackageTest.java b/logback-classic/src/test/java/org/slf4j/impl/PackageTest.java index 3f563bdbb12dc5b5bd29c9b55358bec40658955a..488091c2263b7f3b4e7b006efc6b2f1416a315cb 100644 --- a/logback-classic/src/test/java/org/slf4j/impl/PackageTest.java +++ b/logback-classic/src/test/java/org/slf4j/impl/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/org/slf4j/impl/RecursiveInitializationTest.java b/logback-classic/src/test/java/org/slf4j/impl/RecursiveInitializationTest.java index 4c4006e4e27ef00041e85e9df15984758f4f5fdc..18c5171c21d6bd65a0489cc173537c6238afa8e7 100644 --- a/logback-classic/src/test/java/org/slf4j/impl/RecursiveInitializationTest.java +++ b/logback-classic/src/test/java/org/slf4j/impl/RecursiveInitializationTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/org/slf4j/impl/RecursiveLBAppender.java b/logback-classic/src/test/java/org/slf4j/impl/RecursiveLBAppender.java index 56195517a2f1fde5039c785f4e7aa409d6e345fd..89d3e994c63b97fd3be306d787e9f68c46f16052 100644 --- a/logback-classic/src/test/java/org/slf4j/impl/RecursiveLBAppender.java +++ b/logback-classic/src/test/java/org/slf4j/impl/RecursiveLBAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/org/slf4j/impl/StaticLoggerBinderFriend.java b/logback-classic/src/test/java/org/slf4j/impl/StaticLoggerBinderFriend.java index d6a65cacab15c83e2351ab62a808cb4720683940..7b879185439169456182fe1c799aec6bf4983f6f 100644 --- a/logback-classic/src/test/java/org/slf4j/impl/StaticLoggerBinderFriend.java +++ b/logback-classic/src/test/java/org/slf4j/impl/StaticLoggerBinderFriend.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/org/slf4j/test_osgi/BundleTest.java b/logback-classic/src/test/java/org/slf4j/test_osgi/BundleTest.java index 8b20e3adef4d3e968c6973bbd4495cc49a389bac..20c94f532910da19b8f372b3fae5bcde1a2eda0c 100644 --- a/logback-classic/src/test/java/org/slf4j/test_osgi/BundleTest.java +++ b/logback-classic/src/test/java/org/slf4j/test_osgi/BundleTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/org/slf4j/test_osgi/CheckingBundleListener.java b/logback-classic/src/test/java/org/slf4j/test_osgi/CheckingBundleListener.java index c2f358e156f62377d3465b310072f939b99b46b0..2f0b7a302d783e7867643c92c2429061bd80c797 100644 --- a/logback-classic/src/test/java/org/slf4j/test_osgi/CheckingBundleListener.java +++ b/logback-classic/src/test/java/org/slf4j/test_osgi/CheckingBundleListener.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/org/slf4j/test_osgi/FelixHost.java b/logback-classic/src/test/java/org/slf4j/test_osgi/FelixHost.java index 8811f2924418bbdc697eff4b1fa5875c9aa3099f..65026643649e1c277bc4b999f1c2cb09f534c83a 100644 --- a/logback-classic/src/test/java/org/slf4j/test_osgi/FelixHost.java +++ b/logback-classic/src/test/java/org/slf4j/test_osgi/FelixHost.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-classic/src/test/java/org/slf4j/test_osgi/FrameworkErrorListener.java b/logback-classic/src/test/java/org/slf4j/test_osgi/FrameworkErrorListener.java index c39266db153c28340c663c6e06ebd8b75b8f4644..02fa91d275eff9e34b499d01dabd8274203875af 100644 --- a/logback-classic/src/test/java/org/slf4j/test_osgi/FrameworkErrorListener.java +++ b/logback-classic/src/test/java/org/slf4j/test_osgi/FrameworkErrorListener.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/pom.xml b/logback-core/pom.xml index 24b3ca757236de72332d688be39583394e5690b6..7cdc66e91b67fc8c54dedea60326753e7ca9f59c 100755 --- a/logback-core/pom.xml +++ b/logback-core/pom.xml @@ -7,7 +7,7 @@ ch.qos.logback logback-parent - 1.0.12-SNAPSHOT + 2.0.0-SNAPSHOT logback-core @@ -87,29 +87,21 @@ - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - org.apache.maven.plugins maven-surefire-plugin - ${surefire.version} + ${maven-surefire-plugin.version} once plain - classes + false **/All*Test.java **/PackageTest.java + **/ConsoleAppenderTest.java - **/TimeBasedRollingTest.java + @@ -117,6 +109,7 @@ org.apache.maven.plugins maven-jar-plugin + ${maven-jar-plugin.version} ${project.build.outputDirectory}/META-INF/MANIFEST.MF diff --git a/logback-core/src/main/java/ch/qos/logback/core/Appender.java b/logback-core/src/main/java/ch/qos/logback/core/Appender.java index ff76f42007beb964939c78a7e57f573afe976fc3..8684df8340eed4dc0d557f1e4fb91bffa9225ab8 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/Appender.java +++ b/logback-core/src/main/java/ch/qos/logback/core/Appender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/AppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/AppenderBase.java index 08a325c6a3cf43f05693ef84076cbfc9165af59f..9795c61eeda6d2f073b73ee192c71f3470104daf 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/AppenderBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/AppenderBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/AsyncAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/AsyncAppenderBase.java index 6345df1a094bcffd952f4e4d3d1210200a2bbcad..8718737f2a68d4b64eb0a9791d1746cc34018d97 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/AsyncAppenderBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/AsyncAppenderBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -106,7 +106,7 @@ public class AsyncAppenderBase extends UnsynchronizedAppenderBase implemen if (!isStarted()) return; - // mark this appender as stopped so that Worker can also stop if it is invoking aii.appendLoopOnAppenders + // mark this appender as stopped so that Worker can also processPriorToRemoval if it is invoking aii.appendLoopOnAppenders // and sub-appenders consume the interruption super.stop(); diff --git a/logback-core/src/main/java/ch/qos/logback/core/BasicStatusManager.java b/logback-core/src/main/java/ch/qos/logback/core/BasicStatusManager.java index ff5567d0c43cea1a4c93b36172ffa0a27da3ae9c..6f1fc05d55b44b48bb0474de19af4e6466563e39 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/BasicStatusManager.java +++ b/logback-core/src/main/java/ch/qos/logback/core/BasicStatusManager.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/ConsoleAppender.java b/logback-core/src/main/java/ch/qos/logback/core/ConsoleAppender.java index 3b2be6b54940df79582639a9fbb09c493472bafe..cd238c61aed0e50451d9df6ac47c3f7a86303207 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/ConsoleAppender.java +++ b/logback-core/src/main/java/ch/qos/logback/core/ConsoleAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/Context.java b/logback-core/src/main/java/ch/qos/logback/core/Context.java index aaceaa0fe0b3b72979617e85af137a09ccb20a98..f164647291f7391d1caf5a2d4336b888f644f6e0 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/Context.java +++ b/logback-core/src/main/java/ch/qos/logback/core/Context.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -16,6 +16,7 @@ package ch.qos.logback.core; import java.util.Map; import java.util.concurrent.ExecutorService; +import ch.qos.logback.core.spi.LifeCycle; import ch.qos.logback.core.spi.PropertyContainer; import ch.qos.logback.core.status.StatusManager; @@ -113,4 +114,15 @@ public interface Context extends PropertyContainer { * @since 1.0.0 */ ExecutorService getExecutorService(); + + /** + * Register a component that participates in the context's life cycle. + *

+ * All components registered via this method will be stopped and removed + * from the context when the context is reset. + * + * @param component the subject component + */ + void register(LifeCycle component); + } diff --git a/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java b/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java old mode 100644 new mode 100755 index 39255a6de28ce67f7beb1ef7cd2f45ac34379b32..7ef658106bdbf1590a0db14bcd23e6e0c28a07cf --- a/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,17 +13,18 @@ */ package ch.qos.logback.core; +import static ch.qos.logback.core.CoreConstants.CONTEXT_NAME_KEY; + import java.util.HashMap; import java.util.Map; -import java.util.concurrent.*; +import java.util.concurrent.ExecutorService; +import ch.qos.logback.core.spi.LifeCycle; import ch.qos.logback.core.spi.LogbackLock; import ch.qos.logback.core.status.StatusManager; -import ch.qos.logback.core.util.EnvUtil; - -import static ch.qos.logback.core.CoreConstants.CONTEXT_NAME_KEY; +import ch.qos.logback.core.util.ExecutorServiceUtil; -public class ContextBase implements Context { +public class ContextBase implements Context, LifeCycle { private long birthTime = System.currentTimeMillis(); @@ -37,15 +38,10 @@ public class ContextBase implements Context { LogbackLock configurationLock = new LogbackLock(); - // CORE_POOL_SIZE must be 1 for JDK 1.5. For JD 1.6 or higher it's set to 0 - // so that there are no idle threads - private static final int CORE_POOL_SIZE = EnvUtil.isJDK5() ? 1 : 0; - - // 0 (JDK 1,6+) or 1 (JDK 1.5) idle threads, 2 maximum threads, no idle waiting - ExecutorService executorService = new ThreadPoolExecutor(CORE_POOL_SIZE, 2, - 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue()); - + private volatile ExecutorService executorService; + private LifeCycleManager lifeCycleManager; + private boolean started; + public StatusManager getStatusManager() { return sm; } @@ -102,10 +98,29 @@ public class ContextBase implements Context { return name; } + public void start() { + // We'd like to create the executor service here, but we can't; + // ContextBase has not always implemented LifeCycle and there are *many* + // uses (mostly in tests) that would need to be modified. + started = true; + } + + public void stop() { + // We don't check "started" here, because the executor service uses + // lazy initialization, rather than being created in the start method + stopExecutorService(); + started = false; + } + + public boolean isStarted() { + return started; + } + /** * Clear the internal objectMap and all properties. */ public void reset() { + getLifeCycleManager().reset(); propertyMap.clear(); objectMap.clear(); } @@ -138,11 +153,49 @@ public class ContextBase implements Context { } public ExecutorService getExecutorService() { - return executorService; + if (executorService == null) { + synchronized (this) { + if (executorService == null) { + executorService = ExecutorServiceUtil.newExecutorService(); + } + } + } + return executorService; + } + + private synchronized void stopExecutorService() { + if (executorService != null) { + ExecutorServiceUtil.shutdown(executorService); + executorService = null; + } + } + + public void register(LifeCycle component) { + getLifeCycleManager().register(component); } + /** + * Gets the life cycle manager for this context. + *

+ * The default implementation lazily initializes an instance of + * {@link LifeCycleManager}. Subclasses may override to provide a custom + * manager implementation, but must take care to return the same manager + * object for each call to this method. + *

+ * This is exposed primarily to support instrumentation for unit testing. + * + * @return manager object + */ + synchronized LifeCycleManager getLifeCycleManager() { + if (lifeCycleManager == null) { + lifeCycleManager = new LifeCycleManager(); + } + return lifeCycleManager; + } + @Override public String toString() { return name; } + } diff --git a/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java b/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java index 38ddc8547827cd76cb94ae2963a655d797bc0b09..0b426b0666ae7b5dd5286f2c7b0e5008703af864 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java +++ b/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,8 +13,24 @@ */ package ch.qos.logback.core; +import ch.qos.logback.core.util.EnvUtil; + public class CoreConstants { + /** + * Number of idle threads to retain in a context's executor service. + */ + // CORE_POOL_SIZE must be 1 for JDK 1.5. For JDK 1.6 or higher it's set to 0 + // so that there are no idle threads + public static final int CORE_POOL_SIZE = EnvUtil.isJDK5() ? 1 : 0; + + /** + * Maximum number of threads to allow in a context's executor service. + */ + // if you need a different MAX_POOL_SIZE, please file create a jira issue + // asking to make MAX_POOL_SIZE a parameter. + public static final int MAX_POOL_SIZE = 32; + // Note that the line.separator property can be looked up even by // applets. public static final String LINE_SEPARATOR = System.getProperty("line.separator"); @@ -84,6 +100,7 @@ public class CoreConstants { public static final char SINGLE_QUOTE_CHAR = '\''; public static final char COLON_CHAR = ':'; public static final char DASH_CHAR = '-'; + public static final String DEFAULT_VALUE_SEPARATOR = ":-"; /** @@ -142,6 +159,11 @@ public class CoreConstants { public static final int MILLIS_IN_ONE_DAY = MILLIS_IN_ONE_HOUR*24; public static final int MILLIS_IN_ONE_WEEK = MILLIS_IN_ONE_DAY*7; + /** + * The number of seconds to wait for compression jobs to finish. + */ + public static final int SECONDS_TO_WAIT_FOR_COMPRESSION_JOBS = 30; + public static final String CONTEXT_SCOPE_VALUE = "context"; public static final String RESET_MSG_PREFIX = "Will reset and reconfigure context "; diff --git a/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java b/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java index b8c425d3e9e72d3a8137f733a8b0d435b2ec1052..409aa6c6b5f456289b45b4dc6f29a44f6610a485 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java +++ b/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/Layout.java b/logback-core/src/main/java/ch/qos/logback/core/Layout.java index 64d785adf3155b3877f12469bc2bbf6764e9f997..9e9a5685a8fe76e42941777f209418bc79dbfa3b 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/Layout.java +++ b/logback-core/src/main/java/ch/qos/logback/core/Layout.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/LayoutBase.java b/logback-core/src/main/java/ch/qos/logback/core/LayoutBase.java index 21daf3fbf541c8763d5617bf6c814729bbde503f..99f24bad43d856d7f45b2e5454b3d37457c33777 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/LayoutBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/LayoutBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/LifeCycleManager.java b/logback-core/src/main/java/ch/qos/logback/core/LifeCycleManager.java new file mode 100644 index 0000000000000000000000000000000000000000..5ba1c60e163c7c5fbcfe73e5d5a07fad4ec90954 --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/LifeCycleManager.java @@ -0,0 +1,56 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ + +package ch.qos.logback.core; + +import java.util.HashSet; +import java.util.Set; + +import ch.qos.logback.core.spi.LifeCycle; + +/** + * An object that manages a collection of components that implement the + * {@link LifeCycle} interface. Each component that is added to the manager + * will be stopped and removed from the manager when the manager is reset. + * + * @author Carl Harris + */ +public class LifeCycleManager { + + private final Set components = new HashSet(); + + /** + * Registers a component with this manager. + *

+ * @param component the component whose life cycle is to be managed + */ + public void register(LifeCycle component) { + components.add(component); + } + + /** + * Resets this manager. + *

+ * All registered components are stopped and removed from the manager. + */ + public void reset() { + for (LifeCycle component : components) { + if (component.isStarted()) { + component.stop(); + } + } + components.clear(); + } + +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/LogbackException.java b/logback-core/src/main/java/ch/qos/logback/core/LogbackException.java index 79bc3ce5b51f7f37f905902f6e65afa46760f49c..47d08b445a944f777d9d738a3ea2cdb9c1c7a41e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/LogbackException.java +++ b/logback-core/src/main/java/ch/qos/logback/core/LogbackException.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/OutputStreamAppender.java b/logback-core/src/main/java/ch/qos/logback/core/OutputStreamAppender.java index 60fd6ce4bcd94e615f55cf16f1ead3e570566462..6bed3f3c720c71da938b549912dc6576e643abfe 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/OutputStreamAppender.java +++ b/logback-core/src/main/java/ch/qos/logback/core/OutputStreamAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/PropertyDefinerBase.java b/logback-core/src/main/java/ch/qos/logback/core/PropertyDefinerBase.java index c8d022e09a42d5df8d4e99d99b4400a7a4e5d7b7..03555c79558c7ad6bccd44b7515ed205cd21607c 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/PropertyDefinerBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/PropertyDefinerBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -17,10 +17,14 @@ import ch.qos.logback.core.spi.ContextAwareBase; import ch.qos.logback.core.spi.PropertyDefiner; /** - * Set a skeleton implementation for property definers - * just for have ContextAwareBase. + * A skeleton implementation for property definers so that they derive from {@link ContextAwareBase}. * * @author Aleksey Didik */ public abstract class PropertyDefinerBase extends ContextAwareBase implements PropertyDefiner { + + static protected String booleanAsStr(boolean bool) { + return bool ? Boolean.TRUE.toString() : Boolean.FALSE.toString(); + } + } diff --git a/logback-core/src/main/java/ch/qos/logback/core/UnsynchronizedAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/UnsynchronizedAppenderBase.java index 2bfaa94793000fe2220d8afb026361532b9dd4b5..2f924e6a5c109f626d6fc2653f938c5f0cd5572a 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/UnsynchronizedAppenderBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/UnsynchronizedAppenderBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/boolex/EvaluationException.java b/logback-core/src/main/java/ch/qos/logback/core/boolex/EvaluationException.java index 5e44e0322fcb826f701f0eb597692f53bb099ff9..c1719296a1a448d50ce911625f3a90f7134dac22 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/boolex/EvaluationException.java +++ b/logback-core/src/main/java/ch/qos/logback/core/boolex/EvaluationException.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/boolex/EventEvaluator.java b/logback-core/src/main/java/ch/qos/logback/core/boolex/EventEvaluator.java index 143be52fdf61f6d9c2255312499c0d38196908fa..30abf491df1fbf3aba249271dc76c76ca1320481 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/boolex/EventEvaluator.java +++ b/logback-core/src/main/java/ch/qos/logback/core/boolex/EventEvaluator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/boolex/EventEvaluatorBase.java b/logback-core/src/main/java/ch/qos/logback/core/boolex/EventEvaluatorBase.java index be382cef80b7a07c2d9a77e16940b23734686850..b380e63205f22260b7c0714616100c40eeb55e3f 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/boolex/EventEvaluatorBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/boolex/EventEvaluatorBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/boolex/JaninoEventEvaluatorBase.java b/logback-core/src/main/java/ch/qos/logback/core/boolex/JaninoEventEvaluatorBase.java index 235728149c6527c5314eccdef0fb98125d5dfffc..2fa92fdb377621dff4cf101bfaf2ca54cee18b48 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/boolex/JaninoEventEvaluatorBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/boolex/JaninoEventEvaluatorBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/boolex/Matcher.java b/logback-core/src/main/java/ch/qos/logback/core/boolex/Matcher.java index 036637e6a59073828e38b42b9863cd8d1d172cf8..9e8f9afa3f75f72fccfbfdfb249828ec59c6e9e0 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/boolex/Matcher.java +++ b/logback-core/src/main/java/ch/qos/logback/core/boolex/Matcher.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/BindDataSourceToJNDIAction.java b/logback-core/src/main/java/ch/qos/logback/core/db/BindDataSourceToJNDIAction.java index 945b6b7080d01aecffbc8b14d48adac317d1765a..ccac089d3cbeda3e40933e90bcdca289dfd20bf7 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/BindDataSourceToJNDIAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/BindDataSourceToJNDIAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/ConnectionSource.java b/logback-core/src/main/java/ch/qos/logback/core/db/ConnectionSource.java index 5c03e5ff8d6137dfeca55343c6a086bd387ef612..9b066c25196cc383759f6089fa756834c1729abb 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/ConnectionSource.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/ConnectionSource.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/ConnectionSourceBase.java b/logback-core/src/main/java/ch/qos/logback/core/db/ConnectionSourceBase.java index 00d5fb534ebe3bc6e06cba36ec549d1e38bd3e86..dd8f964e0e8ceefc584f4e993eb939cebf311f29 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/ConnectionSourceBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/ConnectionSourceBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/DBAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/db/DBAppenderBase.java index 794e1d7234f1a33ac3e4186acac5bbc87597840d..c423bc9b56f0962f09eebe47b437ef06de3c1dd8 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/DBAppenderBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/DBAppenderBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/DBHelper.java b/logback-core/src/main/java/ch/qos/logback/core/db/DBHelper.java index dcd37fa4e4f5eb78341c1a8b6a7efcb12182eac5..867a28aba6a0b3afada3d5638a94425c409fda6a 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/DBHelper.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/DBHelper.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/DataSourceConnectionSource.java b/logback-core/src/main/java/ch/qos/logback/core/db/DataSourceConnectionSource.java index 75918ba13f081e2979f92bdbda2c9bf7aea2298e..3195241f2fb21b63d62aa5d1b5089ce374725cfd 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/DataSourceConnectionSource.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/DataSourceConnectionSource.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -41,16 +41,7 @@ public class DataSourceConnectionSource extends ConnectionSourceBase { if (dataSource == null) { addWarn("WARNING: No data source specified"); } else { - Connection connection = null; - try { - connection = getConnection(); - } catch (SQLException se) { - addWarn("Could not get a connection to discover the dialect to use.", - se); - } - if (connection != null) { - discoverConnectionProperties(); - } + discoverConnectionProperties(); if (!supportsGetGeneratedKeys() && getSQLDialectCode() == SQLDialectCode.UNKNOWN_DIALECT) { addWarn("Connection does not support GetGeneratedKey method and could not discover the dialect."); diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/DriverManagerConnectionSource.java b/logback-core/src/main/java/ch/qos/logback/core/db/DriverManagerConnectionSource.java index 7ff42feb9d4adffd5434639f2581d35175202ea2..d7729bf86daf1de254716ad413255707f159be4f 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/DriverManagerConnectionSource.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/DriverManagerConnectionSource.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/JNDIConnectionSource.java b/logback-core/src/main/java/ch/qos/logback/core/db/JNDIConnectionSource.java index f0ef9fd00e40fa63bf33af275681f6f9a1103afc..c2e58c1f6a803c20f5a937cd78ff9a5688282e58 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/JNDIConnectionSource.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/JNDIConnectionSource.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/DBUtil.java b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/DBUtil.java index 670f92c6014ca093bc3cfa525f47b7a8934b1ec0..cd264dc192901a29de32afc74a3ee48793ad9588 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/DBUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/DBUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/H2Dialect.java b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/H2Dialect.java index 9955f1d280f7ceb161ae0ebd3182ebb52ca8de06..fdde6e740f1bca752be1166986e8e15ad14af307 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/H2Dialect.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/H2Dialect.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/HSQLDBDialect.java b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/HSQLDBDialect.java index 53f8abe80deaf163f3810371b8cdfa5de107d547..4b4dd440ef750f0323a0796ada4f2898dec5300e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/HSQLDBDialect.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/HSQLDBDialect.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/MsSQLDialect.java b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/MsSQLDialect.java index 191167cfadad6a29ce377839f012319d841a928a..211c5197dcd00e3be7ed88e54251d61247778d79 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/MsSQLDialect.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/MsSQLDialect.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/MySQLDialect.java b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/MySQLDialect.java index ede5f37a37b07ae433a84b1969ca5f880bf96c78..04b182e346044bdc7549be1c99bf6aa2c5a2dc21 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/MySQLDialect.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/MySQLDialect.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/OracleDialect.java b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/OracleDialect.java index c8036513fd730a0f6f12b58f2db7ac725ac48ee3..d9e517fc405ef02788441a33ebe16d23e5e0e5b8 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/OracleDialect.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/OracleDialect.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/PostgreSQLDialect.java b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/PostgreSQLDialect.java index 5be17edf6982fa8d5c7eb66ede44cadc513e446f..4bdb124a5898dafe8a6145eca8dad23c21830af9 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/PostgreSQLDialect.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/PostgreSQLDialect.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/SQLDialect.java b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/SQLDialect.java index 3244a34cb4f9235c24cc14cb7cc5eaf6254330ab..2e69ed5dfd95b5948ef9e6813aeb01567564961f 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/SQLDialect.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/SQLDialect.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/SQLDialectCode.java b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/SQLDialectCode.java index 9a09f32789e2ab831c4ba369abf6fc921f64ad93..a423764d46189ef4585f4504c6d9543fdeb02977 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/SQLDialectCode.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/SQLDialectCode.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/SQLiteDialect.java b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/SQLiteDialect.java index fa43960a2e5a82b8c85823a497119145d3e27632..467b024fc9dc245dbcf1f87dfbe798670538381b 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/SQLiteDialect.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/SQLiteDialect.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.core.db.dialect; /** diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/SybaseSqlAnywhereDialect.java b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/SybaseSqlAnywhereDialect.java index 7ec7f77768415d465f1cd3f9886cf91e23ff5013..bce03152ebc4f712156d8130b3228adb750d4489 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/db/dialect/SybaseSqlAnywhereDialect.java +++ b/logback-core/src/main/java/ch/qos/logback/core/db/dialect/SybaseSqlAnywhereDialect.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/ByteArrayUtil.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/ByteArrayUtil.java index 5bcb6f55e745d95dbfc8379cc219ae9fd6e164be..0cc44f64a38a58b1dbe4f041bb4b32576d806938 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/encoder/ByteArrayUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/ByteArrayUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java index 0ac7d31f5e8a017ff1f95feeb21f8f9706b1f97d..d561043726bc89949239948148aacde5eb079091 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java +++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/Encoder.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/Encoder.java index ce5e22b76527b844c744f988768b03eba5270996..7eed74f8c77a98a184938c77f9f309989508871d 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/encoder/Encoder.java +++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/Encoder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/EncoderBase.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/EncoderBase.java index 0e7187084394f2ea4a2d472288df466ce9a7c5e4..ce4ac05ea3b0db54c2cdd3d8f2023ca4c6ab59cc 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/encoder/EncoderBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/EncoderBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/EventObjectInputStream.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/EventObjectInputStream.java index 558e2355d016726d8103faf9db9e7fb029fa771d..df03480e2b69459cd803c2e1a219fa22d4343a3d 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/encoder/EventObjectInputStream.java +++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/EventObjectInputStream.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/LayoutWrappingEncoder.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/LayoutWrappingEncoder.java index e7ac7aa142e16665b66b17aa8df4b48576ed2d7f..d2daccbbe44ce437f22de9ce74c2387963f86f34 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/encoder/LayoutWrappingEncoder.java +++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/LayoutWrappingEncoder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/NonClosableInputStream.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/NonClosableInputStream.java index 08525f08357b7a5ddd0bd175a6e256f9f0bf9cfd..3bcffd7db4bfbb668a3329475f622ff265309a07 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/encoder/NonClosableInputStream.java +++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/NonClosableInputStream.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/ObjectStreamEncoder.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/ObjectStreamEncoder.java index ee5932d05956bc6899ab13a56f3eb8777a9d5f09..a5e19642d2e1198f8cc2cd9df273f97c4450e707 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/encoder/ObjectStreamEncoder.java +++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/ObjectStreamEncoder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/filter/AbstractMatcherFilter.java b/logback-core/src/main/java/ch/qos/logback/core/filter/AbstractMatcherFilter.java index 63f0f5727845567bb26dc16aaaaeddf817f6fa04..79db1519b0d57625685e7e84eceb3be75c6ea574 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/filter/AbstractMatcherFilter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/filter/AbstractMatcherFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/filter/EvaluatorFilter.java b/logback-core/src/main/java/ch/qos/logback/core/filter/EvaluatorFilter.java index 827d928d11e9b9ab4a054340f32fe22105b2f423..e3275779f7aeeda9f26d12a37e8a37e87bfe74e3 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/filter/EvaluatorFilter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/filter/EvaluatorFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/filter/Filter.java b/logback-core/src/main/java/ch/qos/logback/core/filter/Filter.java index 063106b2a7ae2f1e7670a588113f59af3b8628fd..f4bde77fb83fb1437979485c3fbceb909cd3edd4 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/filter/Filter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/filter/Filter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/helpers/CyclicBuffer.java b/logback-core/src/main/java/ch/qos/logback/core/helpers/CyclicBuffer.java index 6e92600ffbd7caf2e2e7afa3e23c7a64313001eb..1eee0e585c3c1ae4fcfb0b4a0f8c1fbba2c1d1de 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/helpers/CyclicBuffer.java +++ b/logback-core/src/main/java/ch/qos/logback/core/helpers/CyclicBuffer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/helpers/NOPAppender.java b/logback-core/src/main/java/ch/qos/logback/core/helpers/NOPAppender.java index ebda3d10b07b8908b3a096d74ebb2aad77e6d73f..3b9b08d60ae28d2ea1a067574e2fe650d1dd5df0 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/helpers/NOPAppender.java +++ b/logback-core/src/main/java/ch/qos/logback/core/helpers/NOPAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/helpers/ThrowableToStringArray.java b/logback-core/src/main/java/ch/qos/logback/core/helpers/ThrowableToStringArray.java index 4bbcde527f128fa7903e6e8ebb48b754dd236bcb..6e549eb3284190dd30df4b45aa92ce0014fb07b9 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/helpers/ThrowableToStringArray.java +++ b/logback-core/src/main/java/ch/qos/logback/core/helpers/ThrowableToStringArray.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/helpers/Transform.java b/logback-core/src/main/java/ch/qos/logback/core/helpers/Transform.java index 57c0da5c0248311f1db66295f6db124d5222487a..59d6def29a9f9ea7c2926976080160b67b78809b 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/helpers/Transform.java +++ b/logback-core/src/main/java/ch/qos/logback/core/helpers/Transform.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/html/CssBuilder.java b/logback-core/src/main/java/ch/qos/logback/core/html/CssBuilder.java index 6dd7a1d23ae98c9736fac27f1dd8f66f7dbce89e..5fbcd12d6e2b5dde1b9842ae6707da0643ac710e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/html/CssBuilder.java +++ b/logback-core/src/main/java/ch/qos/logback/core/html/CssBuilder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/html/HTMLLayoutBase.java b/logback-core/src/main/java/ch/qos/logback/core/html/HTMLLayoutBase.java index 099c32c69dfebc5fc331c14756c42b79d26ac337..60dd2402c0e74439b6dcce6f9a22dd484c9a911e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/html/HTMLLayoutBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/html/HTMLLayoutBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/html/IThrowableRenderer.java b/logback-core/src/main/java/ch/qos/logback/core/html/IThrowableRenderer.java index 874041e9740dbfef698f1899e45ceca7553da071..1110038eb92649fcf4f65d5725433f215fb4b130 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/html/IThrowableRenderer.java +++ b/logback-core/src/main/java/ch/qos/logback/core/html/IThrowableRenderer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/html/NOPThrowableRenderer.java b/logback-core/src/main/java/ch/qos/logback/core/html/NOPThrowableRenderer.java index 8a53d73e37c88a5d1fd41338b5681d1cf21dbbc8..a3d5dfe8d5f179152aa43c2ae6a9cf0632ad98d8 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/html/NOPThrowableRenderer.java +++ b/logback-core/src/main/java/ch/qos/logback/core/html/NOPThrowableRenderer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java b/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java index 5edc47c1f33053868382ef90c600e32b69501430..54a38c54552bedce32e503ff649a06b299dc515b 100755 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -107,14 +107,14 @@ public abstract class GenericConfigurator extends ContextAwareBase { } - protected Pattern initialPattern() { - return new Pattern(); + protected ElementPath initialElementPath() { + return new ElementPath(); } protected void buildInterpreter() { RuleStore rs = new SimpleRuleStore(context); addInstanceRules(rs); - this.interpreter = new Interpreter(context, rs, initialPattern()); + this.interpreter = new Interpreter(context, rs, initialElementPath()); InterpretationContext interpretationContext = interpreter.getInterpretationContext(); interpretationContext.setContext(context); addImplicitRules(interpreter); @@ -130,8 +130,7 @@ public abstract class GenericConfigurator extends ContextAwareBase { if (!ConfigurationWatchListUtil.wasConfigurationWatchListReset(context)) { informContextOfURLUsedForConfiguration(getContext(), null); } - SaxEventRecorder recorder = new SaxEventRecorder(); - recorder.setContext(context); + SaxEventRecorder recorder = new SaxEventRecorder(context); recorder.recordEvents(inputSource); doConfigure(recorder.saxEventList); // no exceptions a this level diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/JoranConfiguratorBase.java b/logback-core/src/main/java/ch/qos/logback/core/joran/JoranConfiguratorBase.java index cb9768267e444e84187b4a7e3e5a4cfdb96705e0..50db8b5307dd91cc7343c6235c89ed0048ddc543 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/JoranConfiguratorBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/JoranConfiguratorBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -30,9 +30,9 @@ import ch.qos.logback.core.joran.action.ParamAction; import ch.qos.logback.core.joran.action.PropertyAction; import ch.qos.logback.core.joran.action.StatusListenerAction; import ch.qos.logback.core.joran.action.TimestampAction; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.joran.spi.InterpretationContext; import ch.qos.logback.core.joran.spi.Interpreter; -import ch.qos.logback.core.joran.spi.Pattern; import ch.qos.logback.core.joran.spi.RuleStore; // Based on 310985 revision 310985 as attested by http://tinyurl.com/8njps @@ -57,32 +57,33 @@ abstract public class JoranConfiguratorBase extends GenericConfigurator { @Override protected void addInstanceRules(RuleStore rs) { - rs.addRule(new Pattern("configuration/variable"), new PropertyAction()); - rs.addRule(new Pattern("configuration/property"), new PropertyAction()); + // is "configuration/variable" referenced in the docs? + rs.addRule(new ElementSelector("configuration/variable"), new PropertyAction()); + rs.addRule(new ElementSelector("configuration/property"), new PropertyAction()); - rs.addRule(new Pattern("configuration/substitutionProperty"), + rs.addRule(new ElementSelector("configuration/substitutionProperty"), new PropertyAction()); - rs.addRule(new Pattern("configuration/timestamp"), new TimestampAction()); + rs.addRule(new ElementSelector("configuration/timestamp"), new TimestampAction()); - rs.addRule(new Pattern("configuration/define"), new DefinePropertyAction()); + rs.addRule(new ElementSelector("configuration/define"), new DefinePropertyAction()); // the contextProperty pattern is deprecated. It is undocumented // and will be dropped in future versions of logback - rs.addRule(new Pattern("configuration/contextProperty"), + rs.addRule(new ElementSelector("configuration/contextProperty"), new ContextPropertyAction()); - rs.addRule(new Pattern("configuration/conversionRule"), + rs.addRule(new ElementSelector("configuration/conversionRule"), new ConversionRuleAction()); - rs.addRule(new Pattern("configuration/statusListener"), + rs.addRule(new ElementSelector("configuration/statusListener"), new StatusListenerAction()); - rs.addRule(new Pattern("configuration/appender"), new AppenderAction()); - rs.addRule(new Pattern("configuration/appender/appender-ref"), + rs.addRule(new ElementSelector("configuration/appender"), new AppenderAction()); + rs.addRule(new ElementSelector("configuration/appender/appender-ref"), new AppenderRefAction()); - rs.addRule(new Pattern("configuration/newRule"), new NewRuleAction()); - rs.addRule(new Pattern("*/param"), new ParamAction()); + rs.addRule(new ElementSelector("configuration/newRule"), new NewRuleAction()); + rs.addRule(new ElementSelector("*/param"), new ParamAction()); } @Override @@ -106,7 +107,7 @@ abstract public class JoranConfiguratorBase extends GenericConfigurator { omap.put(ActionConst.FILTER_CHAIN_BAG, new HashMap()); } - public InterpretationContext getExecutionContext() { + public InterpretationContext getInterpretationContext() { return interpreter.getInterpretationContext(); } } diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/AbstractEventEvaluatorAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/AbstractEventEvaluatorAction.java index 64bbe7ddfd335317d6d7754eef91ffb5aefdc92b..210a39a425f8c2d3f35bd0dd4468e43b380407a3 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/AbstractEventEvaluatorAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/AbstractEventEvaluatorAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java index 5089a4719d88ebda2380893db104c902db73dde4..494187daee8c61dd211e9cbda1d217f47803cdd5 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -50,7 +50,7 @@ public abstract class Action extends ContextAwareBase { /** * Called when the parser encounters an element matching a - * {@link ch.qos.logback.core.joran.spi.Pattern Pattern}. + * {@link ch.qos.logback.core.joran.spi.ElementSelector Pattern}. */ public abstract void begin(InterpretationContext ic, String name, Attributes attributes) throws ActionException; diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/ActionConst.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/ActionConst.java index 66b4fc1afb3ef78c210283eb2493f307cd8a784e..c0b7fe507bd1b8f8ede167451c81636e8df4b1c8 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/ActionConst.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/ActionConst.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/ActionUtil.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/ActionUtil.java index 370a182620d699bda05f495fb39f2bac5dfcb8f8..0cb13b026d57d6a36320780b046f0d722f93a624 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/ActionUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/ActionUtil.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.joran.action; import java.util.Properties; @@ -12,6 +25,11 @@ public class ActionUtil { LOCAL, CONTEXT, SYSTEM }; + /** + * Convert a string into a scope. Scole.LOCAL is returned by default. + * @param scopeStr + * @return a scope corresponding to the input string; Scope.LOCAL by default. + */ static public Scope stringToScope(String scopeStr) { if(Scope.SYSTEM.toString().equalsIgnoreCase(scopeStr)) return Scope.SYSTEM; diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderAction.java index f0ee3b289670b8db5597d5cbe7da185c12361822..7ccab3059e8b715691bd9864b836b7eb2eecc7da 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderRefAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderRefAction.java index 1ed63f1d9fb0c2014011d73f6e4f13796f6f29f6..95ade659df36196e0c0be5b3b4ee1df261196bfc 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderRefAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderRefAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/ContextPropertyAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/ContextPropertyAction.java index 5970d63773419adb3c7df074d92677b94b39239b..ce793c08c29a5cbbe1d198662e5e2ed1d93ca863 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/ContextPropertyAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/ContextPropertyAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/ConversionRuleAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/ConversionRuleAction.java index 95d71c6d8587c0d58377310bf93bf02977ae4880..a01bf23ac992b2ec99441433e65041e1c5cbf4a7 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/ConversionRuleAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/ConversionRuleAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/DefinePropertyAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/DefinePropertyAction.java index cb03fcc4b3e618a3aadf6abd1365ed995f8be099..aced27c0ba8a597f89c49a9d6ffa56be013fad6b 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/DefinePropertyAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/DefinePropertyAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForBasicProperty.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForBasicProperty.java index 9e9882b158c3471c6a23797bd2024f0b6e61ecf4..8275f1421664e0f165366bbe3db4087349fbd64c 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForBasicProperty.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForBasicProperty.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForComplexProperty.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForComplexProperty.java index 424e0164ee6e6a38cdefdfe22c68a1306a223b2e..5db16baf1b5df3ee94a49e69fe62250cb172310d 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForComplexProperty.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForComplexProperty.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/ImplicitAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/ImplicitAction.java index 0f4744eed65309341b9ad20c03acd6e913101af4..3d5a6155cfd17b1f685b2aa453bf8984fb65bd83 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/ImplicitAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/ImplicitAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -14,10 +14,10 @@ package ch.qos.logback.core.joran.action; +import ch.qos.logback.core.joran.spi.ElementPath; import org.xml.sax.Attributes; import ch.qos.logback.core.joran.spi.InterpretationContext; -import ch.qos.logback.core.joran.spi.Pattern; /** @@ -34,14 +34,14 @@ public abstract class ImplicitAction extends Action { /** * Check whether this implicit action is appropriate in the current context. * - * @param currentPattern This pattern contains the tag name of the current + * @param currentElementPath This pattern contains the tag name of the current * element being parsed at the top of the stack. * @param attributes The attributes of the current element to process. * @param ec * @return Whether the implicit action is applicable in the current context */ public abstract boolean isApplicable( - Pattern currentPattern, Attributes attributes, InterpretationContext ec); + ElementPath currentElementPath, Attributes attributes, InterpretationContext ec); } diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IncludeAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IncludeAction.java index 275d981d46af8e380d0cf996734e0f382b145e34..8bc0c4238d7ef254f4debdaefe9d72442f2aa99a 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IncludeAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IncludeAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -39,16 +39,19 @@ public class IncludeAction extends Action { private static final String FILE_ATTR = "file"; private static final String URL_ATTR = "url"; private static final String RESOURCE_ATTR = "resource"; + private static final String OPTIONAL_ATTR = "optional"; private String attributeInUse; + private boolean optional; @Override public void begin(InterpretationContext ec, String name, Attributes attributes) throws ActionException { - SaxEventRecorder recorder = new SaxEventRecorder(); + SaxEventRecorder recorder = new SaxEventRecorder(context); this.attributeInUse = null; + this.optional = OptionHelper.toBoolean(attributes.getValue(OPTIONAL_ATTR), false); if (!checkAttributes(attributes)) { return; @@ -140,8 +143,10 @@ public class IncludeAction extends Action { try { return url.openStream(); } catch (IOException e) { - String errMsg = "Failed to open [" + url.toString() + "]"; - addError(errMsg, e); + if (!optional) { + String errMsg = "Failed to open [" + url.toString() + "]"; + addError(errMsg, e); + } return null; } } diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/NOPAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/NOPAction.java index d034a85e989c62849231a2e6aac66c2bfbf77fae..0c0c705f2c678c57779060cb1f03a00c867f099c 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/NOPAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/NOPAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedBasicPropertyIA.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedBasicPropertyIA.java index f1ff1eb73e0659288ddf5a9d1554dc6d47b6781c..62df428ba5ddd9ccdaba2edde35d4ce774b26826 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedBasicPropertyIA.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedBasicPropertyIA.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -15,10 +15,10 @@ package ch.qos.logback.core.joran.action; import java.util.Stack; +import ch.qos.logback.core.joran.spi.ElementPath; import org.xml.sax.Attributes; import ch.qos.logback.core.joran.spi.InterpretationContext; -import ch.qos.logback.core.joran.spi.Pattern; import ch.qos.logback.core.joran.util.PropertySetter; import ch.qos.logback.core.util.AggregationType; @@ -40,11 +40,11 @@ public class NestedBasicPropertyIA extends ImplicitAction { // be followed by the corresponding pop. Stack actionDataStack = new Stack(); - public boolean isApplicable(Pattern pattern, Attributes attributes, + public boolean isApplicable(ElementPath elementPath, Attributes attributes, InterpretationContext ec) { // System.out.println("in NestedSimplePropertyIA.isApplicable [" + pattern + // "]"); - String nestedElementTagName = pattern.peekLast(); + String nestedElementTagName = elementPath.peekLast(); // no point in attempting if there is no parent object if (ec.isEmpty()) { @@ -85,7 +85,6 @@ public class NestedBasicPropertyIA extends ImplicitAction { public void body(InterpretationContext ec, String body) { String finalBody = ec.subst(body); - // System.out.println("body "+body+", finalBody="+finalBody); // get the action data object pushed in isApplicable() method call IADataForBasicProperty actionData = (IADataForBasicProperty) actionDataStack.peek(); switch (actionData.aggregationType) { diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComplexPropertyIA.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComplexPropertyIA.java index d6a9c3ab5ffc38c8df10bb5455a8ef3600a2740f..5bd32060c4e6430c46629fe2ce60df44dbe98c97 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComplexPropertyIA.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComplexPropertyIA.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -15,11 +15,11 @@ package ch.qos.logback.core.joran.action; import java.util.Stack; +import ch.qos.logback.core.joran.spi.ElementPath; import org.xml.sax.Attributes; import ch.qos.logback.core.joran.spi.InterpretationContext; import ch.qos.logback.core.joran.spi.NoAutoStartUtil; -import ch.qos.logback.core.joran.spi.Pattern; import ch.qos.logback.core.joran.util.PropertySetter; import ch.qos.logback.core.spi.ContextAware; import ch.qos.logback.core.spi.LifeCycle; @@ -44,10 +44,10 @@ public class NestedComplexPropertyIA extends ImplicitAction { // be followed by a corresponding pop. Stack actionDataStack = new Stack(); - public boolean isApplicable(Pattern pattern, Attributes attributes, + public boolean isApplicable(ElementPath elementPath, Attributes attributes, InterpretationContext ic) { - String nestedElementTagName = pattern.peekLast(); + String nestedElementTagName = elementPath.peekLast(); // calling ic.peekObject with an empty stack will throw an exception if (ic.isEmpty()) { diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/NewRuleAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/NewRuleAction.java index e8c85158f76b6d592fec2d2e800966179cc8331a..11c0509d946f9b7d63b5410093975042156634d4 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/NewRuleAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/NewRuleAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -16,7 +16,7 @@ package ch.qos.logback.core.joran.action; import org.xml.sax.Attributes; import ch.qos.logback.core.joran.spi.InterpretationContext; -import ch.qos.logback.core.joran.spi.Pattern; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.util.OptionHelper; @@ -50,7 +50,7 @@ public class NewRuleAction extends Action { try { addInfo("About to add new Joran parsing rule [" + pattern + "," + actionClass + "]."); - ec.getJoranInterpreter().getRuleStore().addRule(new Pattern(pattern), + ec.getJoranInterpreter().getRuleStore().addRule(new ElementSelector(pattern), actionClass); } catch (Exception oops) { inError = true; diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java index 701d6097981a771fd9eab418b5c5bee4cafda742..e9167bd77289108b4f6becf3298acbbb4736e526 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/PropertyAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/PropertyAction.java index 087647708f3e1164226331787a9e6d6d99412ddd..8a8411034f7f260ba07cf1b98842052b509f8fa1 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/PropertyAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/PropertyAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/StatusListenerAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/StatusListenerAction.java index af8552273f68d4e1b2f59e77f32eab34959c9e17..516a5e202c9fd045e1cc94aa38f1753517a2a3b4 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/StatusListenerAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/StatusListenerAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/TimestampAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/TimestampAction.java index 371b0d8c74c988bd17100353584d051464afe155..262b8ad0c80b90b853eaad5b9cc0ee6b96edbe4e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/TimestampAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/TimestampAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -16,6 +16,7 @@ package ch.qos.logback.core.joran.action; import ch.qos.logback.core.util.CachingDateFormatter; import org.xml.sax.Attributes; +import ch.qos.logback.core.joran.action.ActionUtil.Scope; import ch.qos.logback.core.joran.spi.ActionException; import ch.qos.logback.core.joran.spi.InterpretationContext; import ch.qos.logback.core.util.OptionHelper; @@ -64,12 +65,15 @@ public class TimestampAction extends Action { if (inError) return; + String scopeStr = attributes.getValue(SCOPE_ATTRIBUTE); + Scope scope = ActionUtil.stringToScope(scopeStr); + CachingDateFormatter sdf = new CachingDateFormatter(datePatternStr); String val = sdf.format(timeReference); addInfo("Adding property to the context with key=\"" + keyStr - + "\" and value=\"" + val + "\" to the context"); - context.putProperty(keyStr, val); + + "\" and value=\"" + val + "\" to the " + scope + " scope"); + ActionUtil.setProperty(ec, keyStr, val, scope); } @Override diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/Condition.java b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/Condition.java index 5f6a11320670190b576bc3f7558a30ae8cf73746..595ca7247369a122c3d406249ece6040c0215f87 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/Condition.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/Condition.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/ElseAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/ElseAction.java index 43e04b0c22ef08f6be6b505093862b72d4cdada8..d2eda56986adc355fecb7a642fe8a37054fc93e9 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/ElseAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/ElseAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/IfAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/IfAction.java index 4910ba1a2687ada0740787f0529775c2c4aee935..2c93fa717776ecc4ac03fe15e0ba71a6a9a92935 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/IfAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/IfAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/PropertyEvalScriptBuilder.java b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/PropertyEvalScriptBuilder.java index 263b101ad84b91a0b5548d05a0a4be132adc4b4d..66259a80ae14ec6d154030019378fdaf0c4dc6a4 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/PropertyEvalScriptBuilder.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/PropertyEvalScriptBuilder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/PropertyWrapperForScripts.java b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/PropertyWrapperForScripts.java index fd832a903d044598f46d90550747d6beb8317970..8eb495cebaceb01d2d73cc5e63f900c23074e630 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/PropertyWrapperForScripts.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/PropertyWrapperForScripts.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/ThenAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/ThenAction.java index d8a44c16d132d40f7aca4370d7f35477dd91dd21..2cc5268d89fa24268a12134040f418718386bbd5 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/ThenAction.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/ThenAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/ThenOrElseActionBase.java b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/ThenOrElseActionBase.java index 4598161ca553421ab5271f0d889d1681813e8f19..a8ae8aafe942e207f0c8ce72e5352e8e2e032ae3 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/ThenOrElseActionBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/ThenOrElseActionBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/event/BodyEvent.java b/logback-core/src/main/java/ch/qos/logback/core/joran/event/BodyEvent.java index 7eec4b42d34e2e9dd82d5f0d7f14aa2c1bd16e24..9a5d0f3025399b6e4fdcb6c658b8eb1112fcdd91 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/event/BodyEvent.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/event/BodyEvent.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/event/EndEvent.java b/logback-core/src/main/java/ch/qos/logback/core/joran/event/EndEvent.java index 41ce17d6a00d6f57c258249527ed681944d7cd01..dec649ec32e51e5d472c732582cb056133a16a87 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/event/EndEvent.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/event/EndEvent.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/event/InPlayListener.java b/logback-core/src/main/java/ch/qos/logback/core/joran/event/InPlayListener.java index 47b0fedc91a133decb2325060d521c651024a9ed..978096adf7b5b588e127b0ed53e4db4e7b36d2d6 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/event/InPlayListener.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/event/InPlayListener.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEvent.java b/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEvent.java index a5ca412b314f60c31f5d80d8453bc12a9cef78d6..92399435bb82fa53921c4a2970013326f70efeff 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEvent.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEvent.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEventRecorder.java b/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEventRecorder.java index 45bb694607dd5c60e9ff2455726dbc47361e3411..27cfa7c18e2afce9181111e28162b28bb4aad78a 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEventRecorder.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/event/SaxEventRecorder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -22,6 +22,9 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import static ch.qos.logback.core.CoreConstants.XML_PARSING; + +import ch.qos.logback.core.joran.spi.ElementPath; +import ch.qos.logback.core.joran.spi.ElementSelector; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.Locator; @@ -31,7 +34,6 @@ import org.xml.sax.helpers.DefaultHandler; import ch.qos.logback.core.Context; import ch.qos.logback.core.joran.spi.JoranException; -import ch.qos.logback.core.joran.spi.Pattern; import ch.qos.logback.core.spi.ContextAware; import ch.qos.logback.core.spi.ContextAwareImpl; import ch.qos.logback.core.status.Status; @@ -40,13 +42,13 @@ public class SaxEventRecorder extends DefaultHandler implements ContextAware { final ContextAwareImpl cai; - public SaxEventRecorder() { - cai = new ContextAwareImpl(this); + public SaxEventRecorder(Context context) { + cai = new ContextAwareImpl(context, this); } public List saxEventList = new ArrayList(); Locator locator; - Pattern globalPattern = new Pattern(); + ElementPath globalElementPath = new ElementPath(); final public void recordEvents(InputStream inputStream) throws JoranException { recordEvents(new InputSource(inputStream)); @@ -102,8 +104,8 @@ public class SaxEventRecorder extends DefaultHandler implements ContextAware { Attributes atts) { String tagName = getTagName(localName, qName); - globalPattern.push(tagName); - Pattern current = (Pattern) globalPattern.clone(); + globalElementPath.push(tagName); + ElementPath current = globalElementPath.duplicate(); saxEventList.add(new StartEvent(current, namespaceURI, localName, qName, atts, getLocator())); } @@ -138,7 +140,7 @@ public class SaxEventRecorder extends DefaultHandler implements ContextAware { public void endElement(String namespaceURI, String localName, String qName) { saxEventList .add(new EndEvent(namespaceURI, localName, qName, getLocator())); - globalPattern.pop(); + globalElementPath.pop(); } String getTagName(String localName, String qName) { diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/event/StartEvent.java b/logback-core/src/main/java/ch/qos/logback/core/joran/event/StartEvent.java index d76c50fdd4e5717245b712c30cf25fd328eef381..4ce7c108e8c6879e7527cd9e0cc58f7b7fd0d12a 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/event/StartEvent.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/event/StartEvent.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,23 +13,22 @@ */ package ch.qos.logback.core.joran.event; +import ch.qos.logback.core.joran.spi.ElementPath; import org.xml.sax.Attributes; import org.xml.sax.Locator; import org.xml.sax.helpers.AttributesImpl; -import ch.qos.logback.core.joran.spi.Pattern; - public class StartEvent extends SaxEvent { final public Attributes attributes; - final public Pattern pattern; + final public ElementPath elementPath; - StartEvent(Pattern pattern, String namespaceURI, String localName, String qName, + StartEvent(ElementPath elementPath, String namespaceURI, String localName, String qName, Attributes attributes, Locator locator) { super(namespaceURI, localName, qName, locator); // locator impl is used to take a snapshot! this.attributes = new AttributesImpl(attributes); - this.pattern = pattern; + this.elementPath = elementPath; } public Attributes getAttributes() { diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/event/stax/BodyEvent.java b/logback-core/src/main/java/ch/qos/logback/core/joran/event/stax/BodyEvent.java new file mode 100755 index 0000000000000000000000000000000000000000..0ca762986aa2a761fee47a30b1b6b5653c5df788 --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/event/stax/BodyEvent.java @@ -0,0 +1,28 @@ +package ch.qos.logback.core.joran.event.stax; + +import javax.xml.stream.Location; + +public class BodyEvent extends StaxEvent { + + + private String text; + + BodyEvent(String text, Location location) { + super(null, location); + this.text = text; + } + + public String getText() { + return text; + } + + void append(String txt) { + text += txt; + } + + @Override + public String toString() { + return "BodyEvent(" + getText() + ")" + location.getLineNumber() + "," + + location.getColumnNumber(); + } +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/event/stax/EndEvent.java b/logback-core/src/main/java/ch/qos/logback/core/joran/event/stax/EndEvent.java new file mode 100755 index 0000000000000000000000000000000000000000..a11fd73ae024eed148d76429c652ae54c8fb525e --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/event/stax/EndEvent.java @@ -0,0 +1,24 @@ +package ch.qos.logback.core.joran.event.stax; + +import javax.xml.stream.Location; + +/** + * Created with IntelliJ IDEA. + * User: ceki + * Date: 7/2/13 + * Time: 4:07 PM + * To change this template use File | Settings | File Templates. + */ +public class EndEvent extends StaxEvent { + + public EndEvent(String name, Location location) { + super(name, location); + } + + @Override + public String toString() { + return "EndEvent("+getName()+") ["+location.getLineNumber()+","+location.getColumnNumber()+"]"; + } + + +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/event/stax/StartEvent.java b/logback-core/src/main/java/ch/qos/logback/core/joran/event/stax/StartEvent.java new file mode 100755 index 0000000000000000000000000000000000000000..7b60d2fc5f171dc90faac785afffd664484e858c --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/event/stax/StartEvent.java @@ -0,0 +1,54 @@ +package ch.qos.logback.core.joran.event.stax; + +import ch.qos.logback.core.joran.spi.ElementPath; + +import javax.xml.stream.Location; +import javax.xml.stream.events.Attribute; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class StartEvent extends StaxEvent { + + List attributes; + public ElementPath elementPath; + + StartEvent(ElementPath elementPath, String name, Iterator attributeIterator, Location location) { + super(name, location); + populateAttributes(attributeIterator); + this.elementPath = elementPath; + } + + private void populateAttributes(Iterator attributeIterator) { + while (attributeIterator.hasNext()) { + if (attributes == null) { + attributes = new ArrayList(2); + } + attributes.add(attributeIterator.next()); + } + } + + public ElementPath getElementPath() { + return elementPath; + } + + public List getAttributeList() { + return attributes; + } + + Attribute getAttributeByName(String name) { + if(attributes == null) + return null; + + for(Attribute attr: attributes) { + if(name.equals(attr.getName().getLocalPart())) + return attr; + } + return null; + } + + @Override + public String toString() { + return "StartEvent(" + getName() + ") [" + location.getLineNumber() + "," + location.getColumnNumber() + "]"; + } +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/event/stax/StaxEvent.java b/logback-core/src/main/java/ch/qos/logback/core/joran/event/stax/StaxEvent.java new file mode 100755 index 0000000000000000000000000000000000000000..da341fa5889fb4336253b4b8a5170d2c6427648e --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/event/stax/StaxEvent.java @@ -0,0 +1,25 @@ +package ch.qos.logback.core.joran.event.stax; + + +import javax.xml.stream.Location; + +public class StaxEvent { + + final String name; + final Location location; + + StaxEvent(String name, Location location) { + this.name = name; + this.location = location; + + } + + public String getName() { + return name; + } + + public Location getLocation() { + return location; + } + +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/event/stax/StaxEventRecorder.java b/logback-core/src/main/java/ch/qos/logback/core/joran/event/stax/StaxEventRecorder.java new file mode 100755 index 0000000000000000000000000000000000000000..cdfc385eea3d94c00feb3a59778c0568e1c0e22a --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/event/stax/StaxEventRecorder.java @@ -0,0 +1,103 @@ +package ch.qos.logback.core.joran.event.stax; + +import ch.qos.logback.core.Context; +import ch.qos.logback.core.joran.spi.ElementPath; +import ch.qos.logback.core.joran.spi.JoranException; +import ch.qos.logback.core.spi.ContextAwareBase; + +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.events.Characters; +import javax.xml.stream.events.EndElement; +import javax.xml.stream.events.StartElement; +import javax.xml.stream.events.XMLEvent; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +public class StaxEventRecorder extends ContextAwareBase { + + List eventList = new ArrayList(); + ElementPath globalElementPath = new ElementPath(); + + public StaxEventRecorder(Context context) { + setContext(context); + } + + public void recordEvents(InputStream inputStream) throws JoranException { + try { + XMLEventReader xmlEventReader = XMLInputFactory.newInstance().createXMLEventReader(inputStream); + read(xmlEventReader); + } catch (XMLStreamException e) { + throw new JoranException("Problem parsing XML document. See previously reported errors.", e); + } + } + + public List getEventList() { + return eventList; + } + + private void read(XMLEventReader xmlEventReader) throws XMLStreamException { + while (xmlEventReader.hasNext()) { + XMLEvent xmlEvent = xmlEventReader.nextEvent(); + switch (xmlEvent.getEventType()) { + case XMLEvent.START_ELEMENT: + addStartElement(xmlEvent); + break; + case XMLEvent.CHARACTERS: + addCharacters(xmlEvent); + break; + case XMLEvent.END_ELEMENT: + addEndEvent(xmlEvent); + break; + default: + break; + } + } + } + + private void addStartElement(XMLEvent xmlEvent) { + StartElement se = xmlEvent.asStartElement(); + String tagName = se.getName().getLocalPart(); + globalElementPath.push(tagName); + ElementPath current = globalElementPath.duplicate(); + StartEvent startEvent = new StartEvent(current, tagName, se.getAttributes(), se.getLocation()); + eventList.add(startEvent); + } + + private void addCharacters(XMLEvent xmlEvent) { + Characters characters = xmlEvent.asCharacters(); + StaxEvent lastEvent = getLastEvent(); + + if (lastEvent instanceof BodyEvent) { + BodyEvent be = (BodyEvent) lastEvent; + be.append(characters.getData()); + } else { + // ignore space only text if the previous event is not a BodyEvent + if(!characters.isWhiteSpace()) { + BodyEvent bodyEvent = new BodyEvent(characters.getData(), xmlEvent.getLocation()); + eventList.add(bodyEvent); + } + } + } + + private void addEndEvent(XMLEvent xmlEvent) { + EndElement ee = xmlEvent.asEndElement(); + String tagName = ee.getName().getLocalPart(); + EndEvent endEvent = new EndEvent(tagName, ee.getLocation()); + eventList.add(endEvent); + globalElementPath.pop(); + } + + StaxEvent getLastEvent() { + if (eventList.isEmpty()) { + return null; + } + int size = eventList.size(); + if(size == 0) + return null; + return eventList.get(size - 1); + } + +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/node/ComponentNode.java b/logback-core/src/main/java/ch/qos/logback/core/joran/node/ComponentNode.java new file mode 100644 index 0000000000000000000000000000000000000000..3e6f6ceee6a2e0aadfcd3183519d92b5fe8741ba --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/node/ComponentNode.java @@ -0,0 +1,8 @@ +package ch.qos.logback.core.joran.node; + + +public class ComponentNode { + + String classStr; + +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ActionException.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ActionException.java index b6d68f06c4299eae2ad6db529880dc3929fec83d..d210178da324515fe11573b697f6b7a950a6aaa6 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ActionException.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ActionException.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConfigurationWatchList.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConfigurationWatchList.java index 6e70d2211546312de5ed8924cd12d14b6e2fe3b9..0accacdeaa408f45af0d808c685b475d6b60097b 100755 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConfigurationWatchList.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConfigurationWatchList.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConsoleTarget.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConsoleTarget.java index 1f07597ad6a65bdbda1a39fa64f1b1ab90986463..9a71e014a25af526b71f9e7289b45fe8abd3ad45 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConsoleTarget.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConsoleTarget.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/DefaultClass.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/DefaultClass.java index c2059f5426199c2305fecf28f5b23a78b30600d8..725abe3ea605208a69ed852a4a8aeb6365fc2a20 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/DefaultClass.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/DefaultClass.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/DefaultNestedComponentRegistry.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/DefaultNestedComponentRegistry.java index 307eab56d53cece720b8c70dd710878eb6f0a48d..a636a239ba75b96a53a1e0775a8bcfe05f5e7e02 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/DefaultNestedComponentRegistry.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/DefaultNestedComponentRegistry.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ElementPath.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ElementPath.java new file mode 100644 index 0000000000000000000000000000000000000000..7e78b28d0a8d8c8911e1f4802f8acc5459eb2d91 --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ElementPath.java @@ -0,0 +1,122 @@ +package ch.qos.logback.core.joran.spi; + +import java.util.ArrayList; +import java.util.List; + +/** + * A element path characterizes a traversal path in an XML document. + * + * @author Ceki Gulcu + * @since 1.1.0 + */ +public class ElementPath { + // contains String instances + ArrayList partList = new ArrayList(); + + public ElementPath() { + } + + public ElementPath(List list) { + partList.addAll(list); + } + + /** + * Build an elementPath from a string. + *

+ * Note that "/x" is considered equivalent to "x" and to "x/" + */ + public ElementPath(String pathStr) { + if (pathStr == null) { + return; + } + + String[] partArray = pathStr.split("/"); + if(partArray == null) return; + + for(String part: partArray) { + if(part.length() >0) { + partList.add(part); + } + } + } + + public ElementPath duplicate() { + ElementPath p = new ElementPath(); + p.partList.addAll(this.partList); + return p; + } + + // Joran error skipping relies on the equals method + @Override + public boolean equals(Object o) { + if ((o == null) || !(o instanceof ElementPath)) { + return false; + } + + ElementPath r = (ElementPath) o; + + if (r.size() != size()) { + return false; + } + + int len = size(); + + for (int i = 0; i < len; i++) { + if (!equalityCheck(get(i), r.get(i))) { + return false; + } + } + + // if everything matches, then the two patterns are equal + return true; + } + + private boolean equalityCheck(String x, String y) { + return x.equalsIgnoreCase(y); + } + + public List getCopyOfPartList() { + return new ArrayList(partList); + } + + public void push(String s) { + partList.add(s); + } + + public String get(int i) { + return (String) partList.get(i); + } + + public void pop() { + if (!partList.isEmpty()) { + partList.remove(partList.size() - 1); + } + } + + public String peekLast() { + if (!partList.isEmpty()) { + int size = partList.size(); + return (String) partList.get(size - 1); + } else { + return null; + } + } + + public int size() { + return partList.size(); + } + + + protected String toStableString() { + StringBuilder result = new StringBuilder(); + for (String current : partList) { + result.append("[").append(current).append("]"); + } + return result.toString(); + } + + @Override + public String toString() { + return toStableString(); + } +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Pattern.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ElementSelector.java similarity index 53% rename from logback-core/src/main/java/ch/qos/logback/core/joran/spi/Pattern.java rename to logback-core/src/main/java/ch/qos/logback/core/joran/spi/ElementSelector.java index cb950483fd73974eef24690dc6cead841f8904fd..0be04e2fd9c6348e460e99dad09d1939552c72b6 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Pattern.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ElementSelector.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -17,101 +17,47 @@ import java.util.ArrayList; import java.util.List; /** - * A pattern is used to designate XML elements in a document. - * - *

For more information see - * http://logback.qos.ch/manual/onJoran.html#pattern - * + * ElementSelector extends {@link ElementPath} with matching operations such as {@link #fullPathMatch(ElementPath)}, + * {@link #getPrefixMatchLength(ElementPath)} and {@link #getTailMatchLength(ElementPath)}. + * + *

Parts of the path may contain '*' for wildcard matching. + * * @author Ceki Gülcü + * @since 1.1.0 */ -public class Pattern { - - // contains String instances - ArrayList partList = new ArrayList(); +public class ElementSelector extends ElementPath { - - public Pattern() { + public ElementSelector() { + super(); } - public Pattern(List list) { - partList.addAll(list); + public ElementSelector(List list) { + super(list); } /** - * Build a pattern from a string. - * + * Build an elementPath from a string. + * * Note that "/x" is considered equivalent to "x" and to "x/" - * + * */ - public Pattern(String p) { - this(); - - if (p == null) { - return; - } - - int lastIndex = 0; - - // System.out.println("p is "+ p); - while (true) { - int k = p.indexOf('/', lastIndex); - - // System.out.println("k is "+ k); - if (k == -1) { - String lastPart = p.substring(lastIndex); - if (lastPart != null && lastPart.length() > 0) { - partList.add(p.substring(lastIndex)); - } - break; - } else { - String c = p.substring(lastIndex, k); - - if (c.length() > 0) { - partList.add(c); - } - - lastIndex = k + 1; - } - } - - // System.out.println(components); + public ElementSelector(String p) { + super(p); } - public List getCopyOfPartList() { - return new ArrayList(partList); - } - - public Object clone() { - Pattern p = new Pattern(); - p.partList.addAll(this.partList); - return p; - } - - public void push(String s) { - partList.add(s); - } - - public int size() { - return partList.size(); - } - - public String get(int i) { - return (String) partList.get(i); - } - - public void pop() { - if (!partList.isEmpty()) { - partList.remove(partList.size() - 1); + public boolean fullPathMatch(ElementPath path) { + if (path.size() != size()) { + return false; } - } - public String peekLast() { - if (!partList.isEmpty()) { - int size = partList.size(); - return (String) partList.get(size - 1); - } else { - return null; + int len = size(); + for (int i = 0; i < len; i++) { + if (!equalityCheck(get(i), path.get(i))) { + return false; + } } + // if everything matches, then the two patterns are equal + return true; } /** @@ -119,7 +65,7 @@ public class Pattern { * with the pattern p passed as parameter. By "tail" components we mean the * components at the end of the pattern. */ - public int getTailMatchLength(Pattern p) { + public int getTailMatchLength(ElementPath p) { if (p == null) { return 0; } @@ -137,8 +83,8 @@ public class Pattern { // loop from the end to the front for (int i = 1; i <= minLen; i++) { - String l = (String) this.partList.get(lSize - i); - String r = (String) p.partList.get(rSize - i); + String l = this.partList.get(lSize - i); + String r = p.partList.get(rSize - i); if (equalityCheck(l, r)) { match++; @@ -149,21 +95,20 @@ public class Pattern { return match; } - public boolean isContained(Pattern p) { + public boolean isContainedIn(ElementPath p) { if(p == null) { return false; } - String lStr = this.toString(); - return lStr.contains(p.toString()); + return p.toStableString().contains(toStableString()); } - - + + /** * Returns the number of "prefix" components that this pattern has in common * with the pattern p passed as parameter. By "prefix" components we mean the * components at the beginning of the pattern. */ - public int getPrefixMatchLength(Pattern p) { + public int getPrefixMatchLength(ElementPath p) { if (p == null) { return 0; } @@ -180,8 +125,8 @@ public class Pattern { int match = 0; for (int i = 0; i < minLen; i++) { - String l = (String) this.partList.get(i); - String r = (String) p.partList.get(i); + String l = this.partList.get(i); + String r = p.partList.get(i); if (equalityCheck(l, r)) { match++; @@ -199,11 +144,11 @@ public class Pattern { @Override public boolean equals(Object o) { - if ((o == null) || !(o instanceof Pattern)) { + if ((o == null) || !(o instanceof ElementSelector)) { return false; } - Pattern r = (Pattern) o; + ElementSelector r = (ElementSelector) o; if (r.size() != size()) { return false; @@ -231,16 +176,8 @@ public class Pattern { // http://jira.qos.ch/browse/LBCORE-76 hc ^= get(i).toLowerCase().hashCode(); } - return hc; } - @Override - public String toString() { - StringBuilder result = new StringBuilder(); - for (String current : partList) { - result.append("[").append(current).append("]"); - } - return result.toString(); - } + } diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java index aa52afbe310a25065063fc622d30675affed487b..bf6df3c994e4f34b8085d99e91793859a0308646 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/HostClassAndPropertyDouble.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/HostClassAndPropertyDouble.java index 56832feeacda5ccd58e15de110b0e8726fc51a43..8eddce0942992814e50b833559989c9a4fa487d7 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/HostClassAndPropertyDouble.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/HostClassAndPropertyDouble.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/InterpretationContext.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/InterpretationContext.java index 20a3cca707a9a64b51dc41d694b4d029ba81c581..2c0292b5ffd37ce73013906a1a5cd3d1851605e8 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/InterpretationContext.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/InterpretationContext.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -15,7 +15,6 @@ package ch.qos.logback.core.joran.spi; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; @@ -62,6 +61,10 @@ public class InterpretationContext extends ContextAwareBase implements return defaultNestedComponentRegistry; } + public Map getCopyOfPropertyMap() { + return new HashMap(propertiesMap); + } + void setPropertiesMap(Map propertiesMap) { this.propertiesMap = propertiesMap; } @@ -129,10 +132,10 @@ public class InterpretationContext extends ContextAwareBase implements if (props == null) { return; } - Iterator i = props.keySet().iterator(); - while (i.hasNext()) { - String key = (String) i.next(); - addSubstitutionProperty(key, props.getProperty(key)); + for(Object keyObject: props.keySet()) { + String key = (String) keyObject; + String val = props.getProperty(key); + addSubstitutionProperty(key, val); } } diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java index 53a430c247e4c672a3728b700cc1873b5d43d392..50645559db849f9da9ac94be4f764b18c7591ae0 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -71,7 +71,7 @@ public class Interpreter { final private InterpretationContext interpretationContext; final private ArrayList implicitActions; final private CAI_WithLocatorSupport cai; - private Pattern pattern; + private ElementPath elementPath; Locator locator; EventPlayer eventPlayer; @@ -89,15 +89,14 @@ public class Interpreter { * If the skip nested is set, then we skip all its nested elements until it is * set back to null at when the element's end is reached. */ - Pattern skip = null; + ElementPath skip = null; - public Interpreter(Context context, RuleStore rs, Pattern initialPattern) { - this.cai = new CAI_WithLocatorSupport(this); - this.cai.setContext(context); + public Interpreter(Context context, RuleStore rs, ElementPath initialElementPath) { + this.cai = new CAI_WithLocatorSupport(context, this); ruleStore = rs; interpretationContext = new InterpretationContext(context, this); implicitActions = new ArrayList(3); - this.pattern = initialPattern; + this.elementPath = initialElementPath; actionListStack = new Stack>(); eventPlayer = new EventPlayer(this); } @@ -134,7 +133,7 @@ public class Interpreter { String qName, Attributes atts) { String tagName = getTagName(localName, qName); - pattern.push(tagName); + elementPath.push(tagName); if (skip != null) { // every startElement pushes an action list @@ -142,7 +141,7 @@ public class Interpreter { return; } - List applicableActionList = getApplicableActionList(pattern, atts); + List applicableActionList = getApplicableActionList(elementPath, atts); if (applicableActionList != null) { actionListStack.add(applicableActionList); callBeginAction(applicableActionList, tagName, atts); @@ -150,7 +149,7 @@ public class Interpreter { // every startElement pushes an action list pushEmptyActionList(); String errMsg = "no applicable action for [" + tagName - + "], current pattern is [" + pattern + "]"; + + "], current ElementPath is [" + elementPath + "]"; cai.addError(errMsg); } } @@ -190,7 +189,7 @@ public class Interpreter { List applicableActionList = (List) actionListStack.pop(); if (skip != null) { - if (skip.equals(pattern)) { + if (skip.equals(elementPath)) { skip = null; } } else if (applicableActionList != EMPTY_LIST) { @@ -198,7 +197,7 @@ public class Interpreter { } // given that we always push, we must also pop the pattern - pattern.pop(); + elementPath.pop(); } public Locator getLocator() { @@ -228,14 +227,14 @@ public class Interpreter { * action is found, it is returned. Thus, the returned list will have at most * one element. */ - List lookupImplicitAction(Pattern pattern, Attributes attributes, + List lookupImplicitAction(ElementPath elementPath, Attributes attributes, InterpretationContext ec) { int len = implicitActions.size(); for (int i = 0; i < len; i++) { ImplicitAction ia = (ImplicitAction) implicitActions.get(i); - if (ia.isApplicable(pattern, attributes, ec)) { + if (ia.isApplicable(elementPath, attributes, ec)) { List actionList = new ArrayList(1); actionList.add(ia); @@ -249,12 +248,12 @@ public class Interpreter { /** * Return the list of applicable patterns for this */ - List getApplicableActionList(Pattern pattern, Attributes attributes) { - List applicableActionList = ruleStore.matchActions(pattern); + List getApplicableActionList(ElementPath elementPath, Attributes attributes) { + List applicableActionList = ruleStore.matchActions(elementPath); // logger.debug("set of applicable patterns: " + applicableActionList); if (applicableActionList == null) { - applicableActionList = lookupImplicitAction(pattern, attributes, + applicableActionList = lookupImplicitAction(elementPath, attributes, interpretationContext); } @@ -275,10 +274,10 @@ public class Interpreter { try { action.begin(interpretationContext, tagName, atts); } catch (ActionException e) { - skip = (Pattern) pattern.clone(); + skip = elementPath.duplicate(); cai.addError("ActionException in Action for tag [" + tagName + "]", e); } catch (RuntimeException e) { - skip = (Pattern) pattern.clone(); + skip = elementPath.duplicate(); cai.addError("RuntimeException in Action for tag [" + tagName + "]", e); } } @@ -291,7 +290,7 @@ public class Interpreter { Iterator i = applicableActionList.iterator(); while (i.hasNext()) { - Action action = (Action) i.next(); + Action action = i.next(); try { action.body(interpretationContext, body); } catch (ActionException ae) { @@ -311,7 +310,7 @@ public class Interpreter { Iterator i = applicableActionList.iterator(); while (i.hasNext()) { - Action action = (Action) i.next(); + Action action = i.next(); // now let us invoke the end method of the action. We catch and report // any eventual exceptions try { @@ -341,8 +340,8 @@ public class Interpreter { */ class CAI_WithLocatorSupport extends ContextAwareImpl { - CAI_WithLocatorSupport(Interpreter interpreter) { - super(interpreter); + CAI_WithLocatorSupport(Context context, Interpreter interpreter) { + super(context, interpreter); } @Override diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/JoranException.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/JoranException.java index eb0a6af7edc32b49b0ba2647cb540457f0177c15..b75a94e3b2896beb49b50137b192103dade25e2f 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/JoranException.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/JoranException.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/NoAutoStart.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/NoAutoStart.java index 06e4b39e0cd9a75b34439d35108f86187d2e4563..c4662b60452ec7b7ea1831426a7180558381a71e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/NoAutoStart.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/NoAutoStart.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/NoAutoStartUtil.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/NoAutoStartUtil.java index aef34579c5b11aa6608c4cd92b337d3811a5da82..89100c9f5cc6793083e8c2cd8b3c995047b4dc6f 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/NoAutoStartUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/NoAutoStartUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/RuleStore.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/RuleStore.java index d94ac0031e10fb179820d1bfe47e81eb0252474b..32f9626988752753dad5b87d29b3cf753513c654 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/RuleStore.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/RuleStore.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -19,21 +19,41 @@ import ch.qos.logback.core.joran.action.Action; /** * - * As its name indicates, a RuleStore contains 2-tuples consists of a Pattern + * As its name indicates, a RuleStore contains 2-tuples consists of a ElementSelector * and an Action. * *

As a joran configurator goes through the elements in a document, it asks * the rule store whether there are rules matching the current pattern by - * invoking the {@link #matchActions(Pattern)} method. + * invoking the {@link #matchActions(ElementPath)} method. * * @author Ceki Gülcü * */ public interface RuleStore { - void addRule(Pattern pattern, String actionClassStr) + + /** + * Add a new rule, given by a pattern and a action class (String). + * + * @param elementSelector + * @param actionClassStr + * @throws ClassNotFoundException + */ + void addRule(ElementSelector elementSelector, String actionClassStr) throws ClassNotFoundException; - void addRule(Pattern pattern, Action action); + /** + * Add a new rule, given by a pattern and an action instance. + * + * @param elementSelector + * @param action + */ + void addRule(ElementSelector elementSelector, Action action); - List matchActions(Pattern currentPatern); + /** + * Return a list of actions matching a pattern. + * + * @param elementPath the path to match for + * @return list of matching actions + */ + List matchActions(ElementPath elementPath); } diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SimpleRuleStore.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SimpleRuleStore.java old mode 100644 new mode 100755 index ea6c16b798a30402206b55c08abb1d8edcf38eaa..3efede2bf13ce79595bd42da990fa7c42f2575e8 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SimpleRuleStore.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/SimpleRuleStore.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -31,10 +31,10 @@ import ch.qos.logback.core.util.OptionHelper; */ public class SimpleRuleStore extends ContextAwareBase implements RuleStore { - static String ANY = "*"; + static String KLEENE_STAR = "*"; // key: Pattern instance, value: ArrayList containing actions - HashMap> rules = new HashMap>(); + HashMap> rules = new HashMap>(); // public SimpleRuleStore() { // } @@ -47,20 +47,20 @@ public class SimpleRuleStore extends ContextAwareBase implements RuleStore { * Add a new rule, i.e. a pattern, action pair to the rule store.

Note * that the added action's LoggerRepository will be set in the process. */ - public void addRule(Pattern pattern, Action action) { + public void addRule(ElementSelector elementSelector, Action action) { action.setContext(context); - List a4p = rules.get(pattern); + List a4p = rules.get(elementSelector); if (a4p == null) { a4p = new ArrayList(); - rules.put(pattern, a4p); + rules.put(elementSelector, a4p); } a4p.add(action); } - public void addRule(Pattern pattern, String actionClassName) { + public void addRule(ElementSelector elementSelector, String actionClassName) { Action action = null; try { @@ -70,110 +70,126 @@ public class SimpleRuleStore extends ContextAwareBase implements RuleStore { addError("Could not instantiate class [" + actionClassName + "]", e); } if (action != null) { - addRule(pattern, action); + addRule(elementSelector, action); } } // exact match has highest priority - // if no exact match, check for tail match, i.e matches of type */x/y - // tail match for */x/y has higher priority than match for */x - // if no tail match, check for prefix match, i.e. matches for x/* + // if no exact match, check for suffix (tail) match, i.e matches + // of type */x/y. Suffix match for */x/y has higher priority than match for + // */x + // if no suffix match, check for prefix match, i.e. matches for x/* // match for x/y/* has higher priority than matches for x/* - public List matchActions(Pattern currentPattern) { + public List matchActions(ElementPath elementPath) { List actionList; - if ((actionList = rules.get(currentPattern)) != null) { + if ((actionList = fullPathMatch(elementPath)) != null) { return actionList; - } else if ((actionList = tailMatch(currentPattern)) != null) { + } else if ((actionList = suffixMatch(elementPath)) != null) { return actionList; - } else if ((actionList = prefixMatch(currentPattern)) != null) { + } else if ((actionList = prefixMatch(elementPath)) != null) { return actionList; - } else if ((actionList = middleMatch(currentPattern)) != null) { + } else if ((actionList = middleMatch(elementPath)) != null) { return actionList; } else { return null; } } - List tailMatch(Pattern currentPattern) { - int max = 0; - Pattern longestMatchingPattern = null; + List fullPathMatch(ElementPath elementPath) { + for (ElementSelector selector : rules.keySet()) { + if(selector.fullPathMatch(elementPath)) + return rules.get(selector); + } + return null; + } - for (Pattern p : rules.keySet()) { + // Suffix matches are matches of type */x/y + List suffixMatch(ElementPath elementPath) { + int max = 0; + ElementSelector longestMatchingElementSelector = null; - if ((p.size() > 1) && p.get(0).equals(ANY)) { - int r = currentPattern.getTailMatchLength(p); + for (ElementSelector selector : rules.keySet()) { + if (isSuffixPattern(selector)) { + int r = selector.getTailMatchLength(elementPath); if (r > max) { max = r; - longestMatchingPattern = p; + longestMatchingElementSelector = selector; } } } - if (longestMatchingPattern != null) { - return rules.get(longestMatchingPattern); + if (longestMatchingElementSelector != null) { + return rules.get(longestMatchingElementSelector); } else { return null; } } - List prefixMatch(Pattern currentPattern) { + private boolean isSuffixPattern(ElementSelector p) { + return (p.size() > 1) && p.get(0).equals(KLEENE_STAR); + } + + List prefixMatch(ElementPath elementPath) { int max = 0; - Pattern longestMatchingPattern = null; + ElementSelector longestMatchingElementSelector = null; - for (Pattern p : rules.keySet()) { - String last = p.peekLast(); - if (ANY.equals(last)) { - int r = currentPattern.getPrefixMatchLength(p); + for (ElementSelector selector : rules.keySet()) { + String last = selector.peekLast(); + if (isKleeneStar(last)) { + int r = selector.getPrefixMatchLength(elementPath); // to qualify the match length must equal p's size omitting the '*' - if ((r == p.size() - 1) && (r > max)) { - // System.out.println("New longest prefixMatch "+p); + if ((r == selector.size() - 1) && (r > max)) { max = r; - longestMatchingPattern = p; + longestMatchingElementSelector = selector; } } } - if (longestMatchingPattern != null) { - return rules.get(longestMatchingPattern); + if (longestMatchingElementSelector != null) { + return rules.get(longestMatchingElementSelector); } else { return null; } } - List middleMatch(Pattern currentPattern) { + private boolean isKleeneStar(String last) { + return KLEENE_STAR.equals(last); + } + + List middleMatch(ElementPath path) { int max = 0; - Pattern longestMatchingPattern = null; + ElementSelector longestMatchingElementSelector = null; - for (Pattern p : rules.keySet()) { - String last = p.peekLast(); + for (ElementSelector selector : rules.keySet()) { + String last = selector.peekLast(); String first = null; - if(p.size() > 1) { - first = p.get(0); + if(selector.size() > 1) { + first = selector.get(0); } - if (ANY.equals(last) && ANY.equals(first)) { - List partList = p.getCopyOfPartList(); - if(partList.size() > 2) { - partList.remove(0); - partList.remove(partList.size()-1); + if (isKleeneStar(last) && isKleeneStar(first)) { + List copyOfPartList = selector.getCopyOfPartList(); + if(copyOfPartList.size() > 2) { + copyOfPartList.remove(0); + copyOfPartList.remove(copyOfPartList.size()-1); } int r = 0; - Pattern clone = new Pattern(partList); - if(currentPattern.isContained(clone)) { + ElementSelector clone = new ElementSelector(copyOfPartList); + if(clone.isContainedIn(path)) { r = clone.size(); } if (r > max) { max = r; - longestMatchingPattern = p; + longestMatchingElementSelector = selector; } } } - if (longestMatchingPattern != null) { - return rules.get(longestMatchingPattern); + if (longestMatchingElementSelector != null) { + return rules.get(longestMatchingElementSelector); } else { return null; } diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/XMLUtil.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/XMLUtil.java index fbe7c9fe93c086c607756f3c9b2f59fbacbc7f72..0d0c1abb4ed65e1f237628a8d0cf0b1b951817fe 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/XMLUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/XMLUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/util/ConfigurationWatchListUtil.java b/logback-core/src/main/java/ch/qos/logback/core/joran/util/ConfigurationWatchListUtil.java index 0a09a801ae24526c7f8f559f82c44e9fc29d0b2a..bad3eb512b307200695f019151bfa78a004c18b5 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/util/ConfigurationWatchListUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/util/ConfigurationWatchListUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/util/PropertySetter.java b/logback-core/src/main/java/ch/qos/logback/core/joran/util/PropertySetter.java index 22c6abc914e0a22399c2a45dae53afd6785d33c4..0be2d97a5e34b0e863dc4389df219d5e874faf87 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/util/PropertySetter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/util/PropertySetter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/util/StringToObjectConverter.java b/logback-core/src/main/java/ch/qos/logback/core/joran/util/StringToObjectConverter.java index fca3ebaf88403fce5db504e77ed2a71f9f216f6e..34e4643dfa155c5b57cb6770daa209efee1e6664 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/util/StringToObjectConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/util/StringToObjectConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/layout/EchoLayout.java b/logback-core/src/main/java/ch/qos/logback/core/layout/EchoLayout.java index 64220812384ddbba9b559fdb7336002171b984ed..94bb0b897e5029fbedca52bfcd8dab2f8fb0bf5e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/layout/EchoLayout.java +++ b/logback-core/src/main/java/ch/qos/logback/core/layout/EchoLayout.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SSLSocketAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/AbstractSSLSocketAppender.java similarity index 65% rename from logback-core/src/main/java/ch/qos/logback/core/net/SSLSocketAppenderBase.java rename to logback-core/src/main/java/ch/qos/logback/core/net/AbstractSSLSocketAppender.java index 0ac377c380f4577d3298d4898e6453648a8c6a74..e56696c0050a0d20db829e10c51997e7962b420e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/SSLSocketAppenderBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/AbstractSSLSocketAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -17,20 +17,44 @@ import javax.net.SocketFactory; import javax.net.ssl.SSLContext; import ch.qos.logback.core.net.ssl.ConfigurableSSLSocketFactory; +import ch.qos.logback.core.net.ssl.SSLComponent; import ch.qos.logback.core.net.ssl.SSLConfiguration; import ch.qos.logback.core.net.ssl.SSLParametersConfiguration; /** - * - * This is the base class for module specific SSLSocketAppender implementations. - * + * An abstract base for module specific {@code SSLSocketAppender} + * implementations located in other logback modules. + * * @author Carl Harris */ -public abstract class SSLSocketAppenderBase extends SocketAppenderBase { +public abstract class AbstractSSLSocketAppender extends AbstractSocketAppender + implements SSLComponent { private SSLConfiguration ssl; private SocketFactory socketFactory; + /** + * Constructs a new appender. + */ + protected AbstractSSLSocketAppender() { + } + + /** + * Constructs a new appender that will connect to the given remote host + * and port. + *

+ * This constructor was introduced primarily to allow the encapsulation + * of the base {@link AbstractSocketAppender} to be improved in a manner that + * is least disruptive to existing subclasses. This + * constructor will be removed in future release. + * @param remoteHost target remote host + * @param port target port on remote host + */ + @Deprecated + protected AbstractSSLSocketAppender(String remoteHost, int port) { + super(remoteHost, port); + } + /** * Gets an {@link SocketFactory} that produces SSL sockets using an * {@link SSLContext} that is derived from the appender's configuration. diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/AbstractSocketAppender.java b/logback-core/src/main/java/ch/qos/logback/core/net/AbstractSocketAppender.java new file mode 100644 index 0000000000000000000000000000000000000000..9d412e396075832cc55148325e5b379f082a3bbc --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/net/AbstractSocketAppender.java @@ -0,0 +1,431 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +// Contributors: Dan MacDonald +package ch.qos.logback.core.net; + +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.net.ConnectException; +import java.net.InetAddress; +import java.net.Socket; +import java.net.UnknownHostException; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.SynchronousQueue; + + +import javax.net.SocketFactory; + +import ch.qos.logback.core.AppenderBase; +import ch.qos.logback.core.CoreConstants; +import ch.qos.logback.core.spi.PreSerializationTransformer; +import ch.qos.logback.core.util.CloseUtil; + +/** + * An abstract base for module specific {@code SocketAppender} + * implementations in other logback modules. + * + * @author Ceki Gülcü + * @author Sébastien Pennec + * @author Carl Harris + */ + +public abstract class AbstractSocketAppender extends AppenderBase + implements Runnable, SocketConnector.ExceptionHandler { + + /** + * The default port number of remote logging server (4560). + */ + public static final int DEFAULT_PORT = 4560; + + /** + * The default reconnection delay (30000 milliseconds or 30 seconds). + */ + public static final int DEFAULT_RECONNECTION_DELAY = 30000; + + /** + * Default size of the queue used to hold logging events that are destined + * for the remote peer. + */ + public static final int DEFAULT_QUEUE_SIZE = 0; + + /** + * Default timeout when waiting for the remote server to accept our + * connection. + */ + private static final int DEFAULT_ACCEPT_CONNECTION_DELAY = 5000; + + private String remoteHost; + private int port = DEFAULT_PORT; + private InetAddress address; + private int reconnectionDelay = DEFAULT_RECONNECTION_DELAY; + private int queueSize = DEFAULT_QUEUE_SIZE; + private int acceptConnectionTimeout = DEFAULT_ACCEPT_CONNECTION_DELAY; + + private BlockingQueue queue; + private String peerId; + private Future task; + private Future connectorTask; + + private volatile Socket socket; + + /** + * Constructs a new appender. + */ + protected AbstractSocketAppender() { + } + + /** + * Constructs a new appender that will connect to the given remote host + * and port. + *

+ * This constructor was introduced primarily to allow the encapsulation + * of the this class to be improved in a manner that is least disruptive + * to existing subclasses. This constructor will be + * removed in future release. + * + * @param remoteHost target remote host + * @param port target port on remote host + */ + @Deprecated + protected AbstractSocketAppender(String remoteHost, int port) { + this.remoteHost = remoteHost; + this.port = port; + } + + /** + * {@inheritDoc} + */ + public void start() { + if (isStarted()) return; + int errorCount = 0; + if (port <= 0) { + errorCount++; + addError("No port was configured for appender" + + name + + " For more information, please visit http://logback.qos.ch/codes.html#socket_no_port"); + } + + if (remoteHost == null) { + errorCount++; + addError("No remote host was configured for appender" + + name + + " For more information, please visit http://logback.qos.ch/codes.html#socket_no_host"); + } + + if (queueSize < 0) { + errorCount++; + addError("Queue size must be non-negative"); + } + + if (errorCount == 0) { + try { + address = InetAddress.getByName(remoteHost); + } catch (UnknownHostException ex) { + addError("unknown host: " + remoteHost); + errorCount++; + } + } + + if (errorCount == 0) { + queue = newBlockingQueue(queueSize); + peerId = "remote peer " + remoteHost + ":" + port + ": "; + task = getContext().getExecutorService().submit(this); + super.start(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void stop() { + if (!isStarted()) return; + CloseUtil.closeQuietly(socket); + task.cancel(true); + if(connectorTask != null) + connectorTask.cancel(true); + super.stop(); + } + + /** + * {@inheritDoc} + */ + @Override + protected void append(E event) { + if (event == null || !isStarted()) return; + queue.offer(event); + } + + /** + * {@inheritDoc} + */ + public final void run() { + try { + while (!Thread.currentThread().isInterrupted()) { + SocketConnector connector = createConnector(address, port, 0, + reconnectionDelay); + + connectorTask = activateConnector(connector); + if(connectorTask == null) + break; + + socket = waitForConnectorToReturnASocket(); + if(socket == null) + break; + dispatchEvents(); + } + } catch (InterruptedException ex) { + assert true; // ok... we'll exit now + } + addInfo("shutting down"); + } + + private SocketConnector createConnector(InetAddress address, int port, + int initialDelay, int retryDelay) { + SocketConnector connector = newConnector(address, port, initialDelay, + retryDelay); + connector.setExceptionHandler(this); + connector.setSocketFactory(getSocketFactory()); + return connector; + } + + private Future activateConnector(SocketConnector connector) { + try { + return getContext().getExecutorService().submit(connector); + } catch (RejectedExecutionException ex) { + return null; + } + } + + private Socket waitForConnectorToReturnASocket() throws InterruptedException { + try { + Socket s = connectorTask.get(); + connectorTask = null; + return s; + } catch (ExecutionException e) { + return null; + } + } + + private void dispatchEvents() throws InterruptedException { + try { + socket.setSoTimeout(acceptConnectionTimeout); + ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream()); + socket.setSoTimeout(0); + addInfo(peerId + "connection established"); + int counter = 0; + while (true) { + E event = queue.take(); + postProcessEvent(event); + Serializable serEvent = getPST().transform(event); + oos.writeObject(serEvent); + oos.flush(); + if (++counter >= CoreConstants.OOS_RESET_FREQUENCY) { + // Failing to reset the object output stream every now and + // then creates a serious memory leak. + oos.reset(); + counter = 0; + } + } + } catch (IOException ex) { + addInfo(peerId + "connection failed: " + ex); + } finally { + CloseUtil.closeQuietly(socket); + socket = null; + addInfo(peerId + "connection closed"); + } + } + + /** + * {@inheritDoc} + */ + public void connectionFailed(SocketConnector connector, Exception ex) { + if (ex instanceof InterruptedException) { + addInfo("connector interrupted"); + } else if (ex instanceof ConnectException) { + addInfo(peerId + "connection refused"); + } else { + addInfo(peerId + ex); + } + } + + + + /** + * Creates a new {@link SocketConnector}. + *

+ * The default implementation creates an instance of {@link DefaultSocketConnector}. + * A subclass may override to provide a different {@link SocketConnector} + * implementation. + * + * @param address target remote address + * @param port target remote port + * @param initialDelay delay before the first connection attempt + * @param retryDelay delay before a reconnection attempt + * @return socket connector + */ + protected SocketConnector newConnector(InetAddress address, + int port, int initialDelay, int retryDelay) { + return new DefaultSocketConnector(address, port, initialDelay, retryDelay); + } + + /** + * Gets the default {@link SocketFactory} for the platform. + *

+ * Subclasses may override to provide a custom socket factory. + */ + protected SocketFactory getSocketFactory() { + return SocketFactory.getDefault(); + } + + /** + * Creates a blocking queue that will be used to hold logging events until + * they can be delivered to the remote receiver. + *

+ * The default implementation creates a (bounded) {@link ArrayBlockingQueue} + * for positive queue sizes. Otherwise it creates a {@link SynchronousQueue}. + *

+ * This method is exposed primarily to support instrumentation for unit + * testing. + * + * @param queueSize size of the queue + * @return + */ + BlockingQueue newBlockingQueue(int queueSize) { + return queueSize <= 0 ? + new SynchronousQueue() : new ArrayBlockingQueue(queueSize); + } + + /** + * Post-processes an event before it is serialized for delivery to the + * remote receiver. + * @param event the event to post-process + */ + protected abstract void postProcessEvent(E event); + + /** + * Get the pre-serialization transformer that will be used to transform + * each event into a Serializable object before delivery to the remote + * receiver. + * @return transformer object + */ + protected abstract PreSerializationTransformer getPST(); + + /* + * This method is used by logback modules only in the now deprecated + * convenience constructors for SocketAppender + */ + @Deprecated + protected static InetAddress getAddressByName(String host) { + try { + return InetAddress.getByName(host); + } catch (Exception e) { + // addError("Could not find address of [" + host + "].", e); + return null; + } + } + + /** + * The RemoteHost property takes the name of of the host where a corresponding server is running. + */ + public void setRemoteHost(String host) { + remoteHost = host; + } + + /** + * Returns value of the RemoteHost property. + */ + public String getRemoteHost() { + return remoteHost; + } + + /** + * The Port property takes a positive integer representing the port + * where the server is waiting for connections. + */ + public void setPort(int port) { + this.port = port; + } + + /** + * Returns value of the Port property. + */ + public int getPort() { + return port; + } + + /** + * The reconnectionDelay property takes a positive integer representing + * the number of milliseconds to wait between each failed connection attempt + * to the server. The default value of this option is 30000 which corresponds + * to 30 seconds. + * + *

+ * Setting this option to zero turns off reconnection capability. + */ + public void setReconnectionDelay(int delay) { + this.reconnectionDelay = delay; + } + + /** + * Returns value of the reconnectionDelay property. + */ + public int getReconnectionDelay() { + return reconnectionDelay; + } + + /** + * The queueSize property takes a non-negative integer representing + * the number of logging events to retain for delivery to the remote receiver. + * When the queue size is zero, event delivery to the remote receiver is + * synchronous. When the queue size is greater than zero, the + * {@link #append(Object)} method returns immediately after enqueing the + * event, assuming that there is space available in the queue. Using a + * non-zero queue length can improve performance by eliminating delays + * caused by transient network delays. If the queue is full when the + * {@link #append(Object)} method is called, the event is summarily + * and silently dropped. + * + * @param queueSize the queue size to set. + */ + public void setQueueSize(int queueSize) { + this.queueSize = queueSize; + } + + /** + * Returns the value of the queueSize property. + */ + public int getQueueSize() { + return queueSize; + } + + /** + * Sets the timeout that controls how long we'll wait for the remote + * peer to accept our connection attempt. + *

+ * This property is configurable primarily to support instrumentation + * for unit testing. + * + * @param acceptConnectionTimeout timeout value in milliseconds + */ + void setAcceptConnectionTimeout(int acceptConnectionTimeout) { + this.acceptConnectionTimeout = acceptConnectionTimeout; + } + +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/DefaultSocketConnector.java b/logback-core/src/main/java/ch/qos/logback/core/net/DefaultSocketConnector.java new file mode 100644 index 0000000000000000000000000000000000000000..6aa8a5808032f88530203b7abd60488468d42efe --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/net/DefaultSocketConnector.java @@ -0,0 +1,125 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package ch.qos.logback.core.net; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.Socket; + +import javax.net.SocketFactory; + +import ch.qos.logback.core.util.DelayStrategy; +import ch.qos.logback.core.util.FixedDelay; + +/** + * Default implementation of {@link SocketConnector}. + * + * @author Carl Harris + * @since 1.0.12 + */ +public class DefaultSocketConnector implements SocketConnector { + + private final InetAddress address; + private final int port; + private final DelayStrategy delayStrategy; + + private ExceptionHandler exceptionHandler; + private SocketFactory socketFactory; + + /** + * Constructs a new connector. + * + * @param address address of remote listener + * @param port port of remote listener + * @param initialDelay delay before initial connection attempt + * @param retryDelay delay after failed connection attempt + */ + public DefaultSocketConnector(InetAddress address, int port, + int initialDelay, int retryDelay) { + this(address, port, new FixedDelay(initialDelay, retryDelay)); + } + + /** + * Constructs a new connector. + * + * @param address address of remote listener + * @param port port of remote listener + * @param delayStrategy strategy for choosing the delay to impose before + * each connection attempt + */ + public DefaultSocketConnector(InetAddress address, int port, + DelayStrategy delayStrategy) { + this.address = address; + this.port = port; + this.delayStrategy = delayStrategy; + } + + /** + * Loops until the desired connection is established and returns the resulting connector. + */ + public Socket call() throws InterruptedException { + useDefaultsForMissingFields(); + Socket socket = createSocket(); + while (socket == null && !Thread.currentThread().isInterrupted()) { + Thread.sleep(delayStrategy.nextDelay()); + socket = createSocket(); + } + return socket; + } + + private Socket createSocket() { + Socket newSocket = null; + try { + newSocket = socketFactory.createSocket(address, port); + } catch (IOException ioex) { + exceptionHandler.connectionFailed(this, ioex); + } + return newSocket; + } + + private void useDefaultsForMissingFields() { + if (exceptionHandler == null) { + exceptionHandler = new ConsoleExceptionHandler(); + } + if (socketFactory == null) { + socketFactory = SocketFactory.getDefault(); + } + } + + /** + * {@inheritDoc} + */ + public void setExceptionHandler(ExceptionHandler exceptionHandler) { + this.exceptionHandler = exceptionHandler; + } + + /** + * {@inheritDoc} + */ + public void setSocketFactory(SocketFactory socketFactory) { + this.socketFactory = socketFactory; + } + + /** + * A default {@link ExceptionHandler} that writes to {@code System.out} + */ + private static class ConsoleExceptionHandler implements ExceptionHandler { + + public void connectionFailed(SocketConnector connector, Exception ex) { + System.out.println(ex); + } + + } + +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/JMSAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/JMSAppenderBase.java index 754f066f826a42548df9de141c543dfaed945d84..3e06cc27d39d18fa6eec9a1ef1f4b984dcf881d9 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/JMSAppenderBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/JMSAppenderBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/LoginAuthenticator.java b/logback-core/src/main/java/ch/qos/logback/core/net/LoginAuthenticator.java index 4d495ca4ec26c52e0af8f19f77e5b5063abd893e..257c2003331575b8b9b0510fc9b8a5f1f7c1bb20 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/LoginAuthenticator.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/LoginAuthenticator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -16,6 +16,9 @@ package ch.qos.logback.core.net; import javax.mail.Authenticator; import javax.mail.PasswordAuthentication; +/** + * Used by SMTPAppender for authentication purposes. + */ public class LoginAuthenticator extends Authenticator { String username; diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java old mode 100644 new mode 100755 index 5baeb0ff7faf087e7b03ee701b99c37f11e4ad11..affb616529a767363bff46f708012b290dbcf951 --- a/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -42,7 +42,6 @@ import ch.qos.logback.core.pattern.PatternLayoutBase; import ch.qos.logback.core.sift.DefaultDiscriminator; import ch.qos.logback.core.sift.Discriminator; import ch.qos.logback.core.spi.CyclicBufferTracker; -import ch.qos.logback.core.spi.CyclicBufferTrackerImpl; import ch.qos.logback.core.util.ContentTypeUtil; import ch.qos.logback.core.util.OptionHelper; @@ -116,7 +115,7 @@ public abstract class SMTPAppenderBase extends AppenderBase { public void start() { if (cbTracker == null) { - cbTracker = new CyclicBufferTrackerImpl(); + cbTracker = new CyclicBufferTracker(); } Session session = null; @@ -236,14 +235,14 @@ public abstract class SMTPAppenderBase extends AppenderBase { } // immediately remove the buffer if asked by the user - if (isEventMarkedForBufferRemoval(eventObject)) { - cbTracker.removeBuffer(key); + if (eventMarksEndOfLife(eventObject)) { + cbTracker.endOfLife(key); } - cbTracker.clearStaleBuffers(now); + cbTracker.removeStaleComponents(now); if (lastTrackerStatusPrint + delayBetweenStatusMessages < now) { - addInfo("SMTPAppender [" + name + "] is tracking [" + cbTracker.size() + "] buffers"); + addInfo("SMTPAppender [" + name + "] is tracking [" + cbTracker.getComponentCount() + "] buffers"); lastTrackerStatusPrint = now; // quadruple 'delay' assuming less than max delay if (delayBetweenStatusMessages < MAX_DELAY_BETWEEN_STATUS_MESSAGES) { @@ -252,7 +251,7 @@ public abstract class SMTPAppenderBase extends AppenderBase { } } - abstract protected boolean isEventMarkedForBufferRemoval(E eventObject); + abstract protected boolean eventMarksEndOfLife(E eventObject); abstract protected void subAppend(CyclicBuffer cb, E eventObject); @@ -311,11 +310,11 @@ public abstract class SMTPAppenderBase extends AppenderBase { for (int i = 0; i < len; i++) { try { PatternLayoutBase emailPL = toPatternLayoutList.get(i); - String email = emailPL.doLayout(event); - if (email == null || email.length() == 0) { + String emailAdrr = emailPL.doLayout(event); + if (emailAdrr == null || emailAdrr.length() == 0) { continue; } - InternetAddress[] tmp = InternetAddress.parse(email, true); + InternetAddress[] tmp = InternetAddress.parse(emailAdrr, true); iaList.addAll(Arrays.asList(tmp)); } catch (AddressException e) { addError("Could not parse email address for [" + toPatternLayoutList.get(i) + "] for event [" + event + "]", e); @@ -392,8 +391,8 @@ public abstract class SMTPAppenderBase extends AppenderBase { mimeMsg.setContent(mp); mimeMsg.setSentDate(new Date()); + addInfo("About to send out SMTP message \"" + subjectStr + "\" to " + Arrays.toString(toAddressArray)); Transport.send(mimeMsg); - addInfo("Sent out SMTP message \"" + subjectStr + "\" to " + Arrays.toString(toAddressArray)); } catch (Exception e) { addError("Error occurred while sending e-mail notification.", e); } diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SocketAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/SocketAppenderBase.java deleted file mode 100644 index 5e409713ca901c26ca3820f3285475da6676f572..0000000000000000000000000000000000000000 --- a/logback-core/src/main/java/ch/qos/logback/core/net/SocketAppenderBase.java +++ /dev/null @@ -1,314 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -// Contributors: Dan MacDonald -package ch.qos.logback.core.net; - -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.net.InetAddress; -import java.net.Socket; -import javax.net.SocketFactory; - -import ch.qos.logback.core.AppenderBase; -import ch.qos.logback.core.CoreConstants; -import ch.qos.logback.core.spi.PreSerializationTransformer; - -/** - * - * This is the base class for module specific SocketAppender implementations. - * - * @author Ceki Gülcü - * @author Sébastien Pennec - */ - -public abstract class SocketAppenderBase extends AppenderBase { - - /** - * The default port number of remote logging server (4560). - */ - public static final int DEFAULT_PORT = 4560; - - /** - * The default reconnection delay (30000 milliseconds or 30 seconds). - */ - public static final int DEFAULT_RECONNECTION_DELAY = 30000; - - /** - * We remember host name as String in addition to the resolved InetAddress so - * that it can be returned via getOption(). - */ - protected String remoteHost; - - protected InetAddress address; - protected int port = DEFAULT_PORT; - protected ObjectOutputStream oos; - protected int reconnectionDelay = DEFAULT_RECONNECTION_DELAY; - - private Connector connector; - - protected int counter = 0; - - /** - * Start this appender. - */ - public void start() { - int errorCount = 0; - if (port == 0) { - errorCount++; - addError("No port was configured for appender" - + name - + " For more information, please visit http://logback.qos.ch/codes.html#socket_no_port"); - } - - if (address == null) { - errorCount++; - addError("No remote address was configured for appender" - + name - + " For more information, please visit http://logback.qos.ch/codes.html#socket_no_host"); - } - - connect(address, port); - - if (errorCount == 0) { - this.started = true; - } - } - - /** - * Strop this appender. - * - *

- * This will mark the appender as closed and call then {@link #cleanUp} - * method. - */ - @Override - public void stop() { - if (!isStarted()) - return; - - this.started = false; - cleanUp(); - } - - /** - * Drop the connection to the remote host and release the underlying connector - * thread if it has been created - */ - public void cleanUp() { - if (oos != null) { - try { - oos.close(); - } catch (IOException e) { - addError("Could not close oos.", e); - } - oos = null; - } - if (connector != null) { - addInfo("Interrupting the connector."); - connector.interrupted = true; - connector = null; // allow gc - } - } - - void connect(InetAddress address, int port) { - if (this.address == null) - return; - try { - // First, close the previous connection if any. - cleanUp(); - oos = new ObjectOutputStream(getSocketFactory() - .createSocket(address, port).getOutputStream()); - } catch (IOException e) { - - String msg = "Could not connect to remote logback server at [" - + address.getHostName() + "]."; - if (reconnectionDelay > 0) { - msg += " We will try again later."; - fireConnector(); // fire the connector thread - } - addInfo(msg, e); - } - } - - /** - * Gets the default {@link SocketFactory} for the platform. - *

- * Subclasses may override to provide a custom socket factory. - */ - protected SocketFactory getSocketFactory() { - return SocketFactory.getDefault(); - } - - @Override - protected void append(E event) { - - if (event == null) - return; - - if (address == null) { - addError("No remote host is set for SocketAppender named \"" - + this.name - + "\". For more information, please visit http://logback.qos.ch/codes.html#socket_no_host"); - return; - } - - if (oos != null) { - try { - postProcessEvent(event); - Serializable serEvent = getPST().transform(event); - oos.writeObject(serEvent); - oos.flush(); - if (++counter >= CoreConstants.OOS_RESET_FREQUENCY) { - counter = 0; - // Failing to reset the object output stream every now and - // then creates a serious memory leak. - // System.err.println("Doing oos.reset()"); - oos.reset(); - } - } catch (IOException e) { - if (oos != null) { - try { - oos.close(); - } catch (IOException ignore) { - } - } - - oos = null; - addWarn("Detected problem with connection: " + e); - if (reconnectionDelay > 0) { - fireConnector(); - } - } - } - } - - protected abstract void postProcessEvent(E event); - protected abstract PreSerializationTransformer getPST(); - - void fireConnector() { - if (connector == null) { - addInfo("Starting a new connector thread."); - connector = new Connector(); - connector.setDaemon(true); - connector.setPriority(Thread.MIN_PRIORITY); - connector.start(); - } - } - - protected static InetAddress getAddressByName(String host) { - try { - return InetAddress.getByName(host); - } catch (Exception e) { - // addError("Could not find address of [" + host + "].", e); - return null; - } - } - - /** - * The RemoteHost property takes the name of of the host where a corresponding server is running. - */ - public void setRemoteHost(String host) { - address = getAddressByName(host); - remoteHost = host; - } - - /** - * Returns value of the RemoteHost property. - */ - public String getRemoteHost() { - return remoteHost; - } - - /** - * The Port property takes a positive integer representing the port - * where the server is waiting for connections. - */ - public void setPort(int port) { - this.port = port; - } - - /** - * Returns value of the Port property. - */ - public int getPort() { - return port; - } - - /** - * The reconnectionDelay property takes a positive integer representing - * the number of milliseconds to wait between each failed connection attempt - * to the server. The default value of this option is 30000 which corresponds - * to 30 seconds. - * - *

- * Setting this option to zero turns off reconnection capability. - */ - public void setReconnectionDelay(int delay) { - this.reconnectionDelay = delay; - } - - /** - * Returns value of the reconnectionDelay property. - */ - public int getReconnectionDelay() { - return reconnectionDelay; - } - - - /** - * The Connector will reconnect when the server becomes available again. It - * does this by attempting to open a new connection every - * reconnectionDelay milliseconds. - * - *

- * It stops trying whenever a connection is established. It will restart to - * try reconnect to the server when previously open connection is dropped. - * - * @author Ceki Gülcü - * @since 0.8.4 - */ - class Connector extends Thread { - - boolean interrupted = false; - - public void run() { - Socket socket; - while (!interrupted) { - try { - sleep(reconnectionDelay); - SocketAppenderBase.this.addInfo("Attempting connection to " + address.getHostName()); - socket = getSocketFactory().createSocket(address, port); - synchronized (this) { - oos = new ObjectOutputStream(socket.getOutputStream()); - connector = null; - addInfo("Connection established. Exiting connector thread."); - break; - } - } catch (InterruptedException e) { - addInfo("Connector interrupted. Leaving loop."); - return; - } catch (java.net.ConnectException e) { - addInfo("Remote host " + address.getHostName() - + " refused connection."); - } catch (IOException e) { - addInfo("Could not connect to " + address.getHostName() - + ". Exception is " + e); - } - } - // addInfo("Exiting Connector.run() method."); - } - } - -} diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SocketConnector.java b/logback-core/src/main/java/ch/qos/logback/core/net/SocketConnector.java index aa4e5ebc34e233a0e996843814e4964888521770..a2134dafd15e6c9f905af777c616fbb6014f4ae4 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/SocketConnector.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/SocketConnector.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -14,6 +14,7 @@ package ch.qos.logback.core.net; import java.net.Socket; +import java.util.concurrent.Callable; import javax.net.SocketFactory; @@ -25,7 +26,7 @@ import javax.net.SocketFactory; * * @author Carl Harris */ -public interface SocketConnector extends Runnable { +public interface SocketConnector extends Callable { /** * An exception handler that is notified of all exceptions that occur @@ -41,21 +42,12 @@ public interface SocketConnector extends Runnable { * @return the connected socket * @throws InterruptedException */ - Socket awaitConnection() throws InterruptedException; + Socket call() throws InterruptedException; - /** - * Blocks the calling thread until a connection is successfully - * established or timeout occurs. - * @param the maximum time to wait (in milliseconds) - * @return the connected socket or {@code null} if timeout occurs - * @throws InterruptedException - */ - Socket awaitConnection(long delay) throws InterruptedException; - /** * Sets the connector's exception handler. *

- * The handler must be set before the {@link run()} method is invoked. + * The handler must be set before the {@link #call()} method is invoked. * @param exceptionHandler the handler to set */ void setExceptionHandler(ExceptionHandler exceptionHandler); diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SocketConnectorBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/SocketConnectorBase.java deleted file mode 100644 index 4329a02f9099c667faa4a7b87773cb499150be2c..0000000000000000000000000000000000000000 --- a/logback-core/src/main/java/ch/qos/logback/core/net/SocketConnectorBase.java +++ /dev/null @@ -1,191 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.core.net; - -import java.net.InetAddress; -import java.net.Socket; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.Condition; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -import javax.net.SocketFactory; - -/** - * Base implementation of {@link SocketConnector}. - * - * @author Carl Harris - */ -public class SocketConnectorBase implements SocketConnector { - - /** - * A strategy for choosing a delay after a failed connection attempt. - */ - public interface DelayStrategy { - int nextDelay(); - } - - private final Lock lock = new ReentrantLock(); - private final Condition connectCondition = lock.newCondition(); - - private final InetAddress address; - private final int port; - - private ExceptionHandler exceptionHandler; - private SocketFactory socketFactory; - private DelayStrategy delayStrategy; - private Socket socket; - - /** - * Constructs a new connector. - * @param address address of remote listener - * @param port port of remote listener - * @param initialDelay delay before initial connection attempt - * @param retryDelay delay after failed connection attempt - */ - public SocketConnectorBase(InetAddress address, int port, - int initialDelay, int retryDelay) { - this(address, port, new FixedDelay(initialDelay, retryDelay)); - } - - /** - * Constructs a new connector. - * @param address address of remote listener - * @param port port of remote listener - * @param delayStrategy strategy for choosing the delay to impose before - * each connection attempt - */ - public SocketConnectorBase(InetAddress address, int port, - DelayStrategy delayStrategy) { - this.address = address; - this.port = port; - this.delayStrategy = delayStrategy; - } - - /** - * {@inheritDoc} - */ - public void run() { - if (socket != null) { - throw new IllegalStateException("connector cannot be reused"); - } - if (exceptionHandler == null) { - exceptionHandler = new ConsoleExceptionHandler(); - } - if (socketFactory == null) { - socketFactory = SocketFactory.getDefault(); - } - try { - while (!Thread.currentThread().isInterrupted()) { - Thread.sleep(delayStrategy.nextDelay()); - try { - socket = socketFactory.createSocket(address, port); - signalConnected(); - break; - } - catch (Exception ex) { - exceptionHandler.connectionFailed(this, ex); - } - } - } - catch (InterruptedException ex) { - exceptionHandler.connectionFailed(this, ex); - } - } - - /** - * Signals any threads waiting on {@code connectCondition} that the - * connection has been established. - */ - private void signalConnected() { - lock.lock(); - try { - connectCondition.signalAll(); - } - finally { - lock.unlock(); - } - } - - /** - * {@inheritDoc} - */ - public Socket awaitConnection() throws InterruptedException { - return awaitConnection(Long.MAX_VALUE); - } - - /** - * {@inheritDoc} - */ - public Socket awaitConnection(long delay) throws InterruptedException { - lock.lock(); - try { - boolean timeout = false; - while (socket == null && !timeout) { - timeout = !connectCondition.await(delay, TimeUnit.MILLISECONDS); - } - return socket; - } - finally { - lock.unlock(); - } - } - - /** - * {@inheritDoc} - */ - public void setExceptionHandler(ExceptionHandler exceptionHandler) { - this.exceptionHandler = exceptionHandler; - } - - /** - * {@inheritDoc} - */ - public void setSocketFactory(SocketFactory socketFactory) { - this.socketFactory = socketFactory; - } - - /** - * A default {@link ExceptionHandler} that writes to {@code System.out} - */ - private static class ConsoleExceptionHandler implements ExceptionHandler { - - public void connectionFailed(SocketConnector connector, Exception ex) { - System.out.println(ex); - } - - } - - /** - * A default {@link DelayStrategy} that implements a simple fixed delay. - */ - private static class FixedDelay implements DelayStrategy { - - private final int retryDelay; - private int nextDelay; - - public FixedDelay(int initialDelay, int retryDelay) { - this.nextDelay = initialDelay; - this.retryDelay = retryDelay; - } - - public int nextDelay() { - int delay = nextDelay; - nextDelay = retryDelay; - return delay; - } - - } - -} diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SyslogAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/SyslogAppenderBase.java index ee6b3ac5592b266f6c5d9636b94de08938b02ed8..060e44b1c02ad254f150d5d8a6950fe158f3a7a8 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/SyslogAppenderBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/SyslogAppenderBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -33,7 +33,6 @@ public abstract class SyslogAppenderBase extends AppenderBase { final static String SYSLOG_LAYOUT_URL = CoreConstants.CODES_URL + "#syslog_layout"; - final static int MSG_SIZE_LIMIT = 256 * 1024; Layout layout; String facilityStr; @@ -41,6 +40,7 @@ public abstract class SyslogAppenderBase extends AppenderBase { protected String suffixPattern; SyslogOutputStream sos; int port = SyslogConstants.SYSLOG_PORT; + int maxMessageSize = 65000; public void start() { int errorCount = 0; @@ -84,8 +84,8 @@ public abstract class SyslogAppenderBase extends AppenderBase { if(msg == null) { return; } - if (msg.length() > MSG_SIZE_LIMIT) { - msg = msg.substring(0, MSG_SIZE_LIMIT); + if (msg.length() > maxMessageSize) { + msg = msg.substring(0, maxMessageSize); } sos.write(msg.getBytes()); sos.flush(); @@ -211,6 +211,25 @@ public abstract class SyslogAppenderBase extends AppenderBase { this.port = port; } + /** + * + * @return + */ + public int getMaxMessageSize() { + return maxMessageSize; + } + + /** + * Maximum size for the syslog message (in characters); messages + * longer than this are truncated. The default value is 65400 (which + * is near the maximum for syslog-over-UDP). Note that the value is + * characters; the number of bytes may vary if non-ASCII characters + * are present. + */ + public void setMaxMessageSize(int maxMessageSize) { + this.maxMessageSize = maxMessageSize; + } + public Layout getLayout() { return layout; } diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SyslogConstants.java b/logback-core/src/main/java/ch/qos/logback/core/net/SyslogConstants.java index 302c5819462406dae15227e1e19b00533bd2553d..008a3dc9c1c5ecb501ca944a663bf880b188f2e4 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/SyslogConstants.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/SyslogConstants.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SyslogOutputStream.java b/logback-core/src/main/java/ch/qos/logback/core/net/SyslogOutputStream.java index c5969f4aa4c9e4a5632151162fdf8c9a229442f6..7069eb7059113e77fd68a8a1255a305fbbe369b7 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/SyslogOutputStream.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/SyslogOutputStream.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerSocketAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/AbstractServerSocketAppender.java similarity index 69% rename from logback-core/src/main/java/ch/qos/logback/core/net/server/ServerSocketAppenderBase.java rename to logback-core/src/main/java/ch/qos/logback/core/net/server/AbstractServerSocketAppender.java index 1b2f125267c263f3c9ada52addf12d620eacddea..d6e1bc1777bbf4359894f37340fd3f394eed5424 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerSocketAppenderBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/AbstractServerSocketAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -19,22 +19,21 @@ import java.net.InetAddress; import java.net.ServerSocket; import java.net.UnknownHostException; import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; import javax.net.ServerSocketFactory; import ch.qos.logback.core.AppenderBase; -import ch.qos.logback.core.net.SocketAppenderBase; +import ch.qos.logback.core.net.AbstractSocketAppender; import ch.qos.logback.core.spi.PreSerializationTransformer; /** * - * This is the base class for module specific ServerSocketAppender - * implementations. + * This is the super class for module specific ServerSocketAppender + * implementations can derive from. * * @author Carl Harris */ -public abstract class ServerSocketAppenderBase extends AppenderBase { +public abstract class AbstractServerSocketAppender extends AppenderBase { /** * Default {@link ServerSocket} backlog @@ -46,15 +45,13 @@ public abstract class ServerSocketAppenderBase extends AppenderBase { */ public static final int DEFAULT_CLIENT_QUEUE_SIZE = 100; - private int port = SocketAppenderBase.DEFAULT_PORT; + private int port = AbstractSocketAppender.DEFAULT_PORT; private int backlog = DEFAULT_BACKLOG; private int clientQueueSize = DEFAULT_CLIENT_QUEUE_SIZE; private String address; - private ThreadPoolFactoryBean threadPool; - private ExecutorService executor; - private ServerRunner runner; + private ServerRunner runner; @Override public void start() { @@ -62,27 +59,26 @@ public abstract class ServerSocketAppenderBase extends AppenderBase { try { ServerSocket socket = getServerSocketFactory().createServerSocket( getPort(), getBacklog(), getInetAddress()); - ServerListener listener = createServerListener(socket); - executor = getThreadPool().createExecutor(); - runner = createServerRunner(listener, executor); + ServerListener listener = createServerListener(socket); + + runner = createServerRunner(listener, getContext().getExecutorService()); runner.setContext(getContext()); - runner.start(); + getContext().getExecutorService().execute(runner); super.start(); - } - catch (Exception ex) { + } catch (Exception ex) { addError("server startup error: " + ex, ex); } } - protected ServerListener createServerListener( + protected ServerListener createServerListener( ServerSocket socket) { - return new RemoteLoggerServerListener(socket); + return new RemoteReceiverServerListener(socket); } - protected ServerRunner createServerRunner( - ServerListener listener, + protected ServerRunner createServerRunner( + ServerListener listener, Executor executor) { - return new RemoteLoggerServerRunner(listener, executor, + return new RemoteReceiverServerRunner(listener, executor, getClientQueueSize()); } @@ -91,7 +87,6 @@ public abstract class ServerSocketAppenderBase extends AppenderBase { if (!isStarted()) return; try { runner.stop(); - executor.shutdownNow(); super.stop(); } catch (IOException ex) { @@ -99,22 +94,13 @@ public abstract class ServerSocketAppenderBase extends AppenderBase { } } - /** - * Gets a flag indicating whether the server is running. - * @return flag state - */ - @Override - public final boolean isStarted() { - return runner != null && runner.isStarted() && super.isStarted(); - } - @Override protected void append(E event) { if (event == null) return; postProcessEvent(event); final Serializable serEvent = getPST().transform(event); - runner.accept(new ClientVisitor() { - public void visit(RemoteLoggerClient client) { + runner.accept(new ClientVisitor() { + public void visit(RemoteReceiverClient client) { client.offer(serEvent); } }); @@ -180,7 +166,7 @@ public abstract class ServerSocketAppenderBase extends AppenderBase { * @return queue depth * @see java.net.ServerSocket */ - public Integer getBacklog() { + public int getBacklog() { return backlog; } @@ -192,7 +178,7 @@ public abstract class ServerSocketAppenderBase extends AppenderBase { * @param backlog the queue depth to set * @see java.net.ServerSocket */ - public void setBacklog(Integer backlog) { + public void setBacklog(int backlog) { this.backlog = backlog; } @@ -228,25 +214,5 @@ public abstract class ServerSocketAppenderBase extends AppenderBase { this.clientQueueSize = clientQueueSize; } - /** - * Gets the server's thread pool configuration. - * @return thread pool configuration; if no thread pool configuration was - * provided, a default configuration is returned - */ - public ThreadPoolFactoryBean getThreadPool() { - if (threadPool == null) { - return new ThreadPoolFactoryBean(); - } - return threadPool; - } - - /** - * Sets the server's thread pool configuration. - * @param threadPool the configuration to set - */ - public void setThreadPool(ThreadPoolFactoryBean threadPool) { - this.threadPool = threadPool; - } - } diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/Client.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/Client.java index 18553c56fe134539ddf8bf09a99962a6e785ad0c..7176fe0c7fb77343ec1770542ba4b90def5be695 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/server/Client.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/Client.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/ClientVisitor.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/ClientVisitor.java index 1b965e0cf3ac652392009465d6274da9eec9d14c..ac261c9090dad1da28995a0b68c7533cba631253 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/server/ClientVisitor.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/ClientVisitor.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.core.net.server; /** diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/ConcurrentServerRunner.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/ConcurrentServerRunner.java index 29e3dbef87b013ad369ab355d85624ae5cba2db1..47d1f4bfd072b25892ef2fb2d15ffc19020d512b 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/server/ConcurrentServerRunner.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/ConcurrentServerRunner.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -55,7 +55,7 @@ public abstract class ConcurrentServerRunner private final ServerListener listener; private final Executor executor; - private boolean started; + private boolean running; /** * Constructs a new server runner. @@ -74,31 +74,24 @@ public abstract class ConcurrentServerRunner /** * {@inheritDoc} */ - public void start() throws IOException { - if (isStarted()) return; - executor.execute(this); - started = true; + public boolean isRunning() { + return running; } + protected void setRunning(boolean running) { + this.running = running; + } + /** * {@inheritDoc} */ public void stop() throws IOException { - if (!isStarted()) return; listener.close(); accept(new ClientVisitor() { public void visit(T client) { client.close(); } }); - started = false; - } - - /** - * {@inheritDoc} - */ - public boolean isStarted() { - return started; } /** @@ -136,6 +129,7 @@ public abstract class ConcurrentServerRunner * {@inheritDoc} */ public void run() { + setRunning(true); try { addInfo("listening on " + listener); while (!Thread.currentThread().isInterrupted()) { @@ -160,7 +154,8 @@ public abstract class ConcurrentServerRunner catch (Exception ex) { addError("listener: " + ex); } - + + setRunning(false); addInfo("shutting down"); listener.close(); } diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerClient.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverClient.java similarity index 91% rename from logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerClient.java rename to logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverClient.java index 1af2b908d5d9a8687276dcca5fc71b6f5f8b539a..aba637a23bc1418eac5584398c54be7d251ee555 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerClient.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverClient.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.core.net.server; import java.io.Serializable; @@ -26,7 +25,7 @@ import ch.qos.logback.core.spi.ContextAware; * * @author Carl Harris */ -interface RemoteLoggerClient extends Client, ContextAware { +interface RemoteReceiverClient extends Client, ContextAware { /** * Sets the client's event queue. diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerServerListener.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverServerListener.java similarity index 70% rename from logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerServerListener.java rename to logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverServerListener.java index 70ca05a8ec4ad69d45f92e3cc11a25e0805fc327..97e3bd5d5009413742d5bde41778e74a2ab8ab8e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerServerListener.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverServerListener.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.core.net.server; import java.io.IOException; @@ -19,20 +18,20 @@ import java.net.ServerSocket; import java.net.Socket; /** - * A {@link ServerListener} that accepts connections from remote logger - * clients. + * A {@link ServerListener} that accepts connections from remote receiver + * component clients. * * @author Carl Harris */ -class RemoteLoggerServerListener - extends ServerSocketListener { +class RemoteReceiverServerListener + extends ServerSocketListener { /** * Constructs a new listener. * @param serverSocket server socket from which new client connections * will be accepted */ - public RemoteLoggerServerListener(ServerSocket serverSocket) { + public RemoteReceiverServerListener(ServerSocket serverSocket) { super(serverSocket); } @@ -40,9 +39,9 @@ class RemoteLoggerServerListener * {@inheritDoc} */ @Override - protected RemoteLoggerClient createClient(String id, Socket socket) + protected RemoteReceiverClient createClient(String id, Socket socket) throws IOException { - return new RemoteLoggerStreamClient(id, socket); + return new RemoteReceiverStreamClient(id, socket); } } diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerServerRunner.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverServerRunner.java similarity index 72% rename from logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerServerRunner.java rename to logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverServerRunner.java index 47c01599ab3549b215320ec96cbdb5ded735b0a8..c80d327647e8c22643d2c522bf64b20985df0521 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerServerRunner.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverServerRunner.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.core.net.server; import java.io.Serializable; @@ -19,13 +18,13 @@ import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.Executor; /** - * A {@link ServerRunner} that sends logging events to remote logger - * clients. + * A {@link ServerRunner} that listens for connections from remote receiver + * component clients and delivers logging events to all connected clients. * * @author Carl Harris */ -class RemoteLoggerServerRunner - extends ConcurrentServerRunner { +class RemoteReceiverServerRunner + extends ConcurrentServerRunner { private final int clientQueueSize; @@ -38,8 +37,8 @@ class RemoteLoggerServerRunner * @param queueSize size of the event queue that will be maintained for * each client */ - public RemoteLoggerServerRunner( - ServerListener listener, Executor executor, + public RemoteReceiverServerRunner( + ServerListener listener, Executor executor, int clientQueueSize) { super(listener, executor); this.clientQueueSize = clientQueueSize; @@ -49,7 +48,7 @@ class RemoteLoggerServerRunner * {@inheritDoc} */ @Override - protected boolean configureClient(RemoteLoggerClient client) { + protected boolean configureClient(RemoteReceiverClient client) { client.setContext(getContext()); client.setQueue(new ArrayBlockingQueue(clientQueueSize)); return true; diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerStreamClient.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverStreamClient.java similarity index 88% rename from logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerStreamClient.java rename to logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverStreamClient.java index 57b83fbe9f3d8d53fd2466d8c95396634c38fb3e..c2c7971adefe9dfef702ffb3c0f18173d9bf4859 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerStreamClient.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverStreamClient.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.core.net.server; import java.io.IOException; @@ -27,13 +26,13 @@ import ch.qos.logback.core.spi.ContextAwareBase; import ch.qos.logback.core.util.CloseUtil; /** - * A {@link RemoteLoggerClient} that writes serialized logging events to an + * A {@link RemoteReceiverClient} that writes serialized logging events to an * {@link OutputStream}. * * @author Carl Harris */ -class RemoteLoggerStreamClient - extends ContextAwareBase implements RemoteLoggerClient { +class RemoteReceiverStreamClient + extends ContextAwareBase implements RemoteReceiverClient { private final String clientId; private final Socket socket; @@ -46,7 +45,7 @@ class RemoteLoggerStreamClient * @param id identifier string for the client * @param socket socket to which logging events will be written */ - public RemoteLoggerStreamClient(String id, Socket socket) { + public RemoteReceiverStreamClient(String id, Socket socket) { this.clientId = "client " + id + ": "; this.socket = socket; this.outputStream = null; @@ -61,7 +60,7 @@ class RemoteLoggerStreamClient * @param id identifier string for the client * @param outputStream output stream to which logging Events will be written */ - public RemoteLoggerStreamClient(String id, OutputStream outputStream) { + RemoteReceiverStreamClient(String id, OutputStream outputStream) { this.clientId = "client " + id + ": "; this.socket = null; this.outputStream = outputStream; @@ -109,7 +108,7 @@ class RemoteLoggerStreamClient oos.flush(); if (++counter >= CoreConstants.OOS_RESET_FREQUENCY) { // failing to reset the stream periodically will result in a - // serious memory leak (as noted in SocketAppenderBase) + // serious memory leak (as noted in AbstractSocketAppender) counter = 0; oos.reset(); } diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/SSLServerSocketAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/SSLServerSocketAppenderBase.java index ba4865287b1158077eb4d4d703544d1abbc1e6c2..e61efb427b49b5116970890e7be710627f6ba53c 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/server/SSLServerSocketAppenderBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/SSLServerSocketAppenderBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -17,6 +17,7 @@ import javax.net.ServerSocketFactory; import javax.net.ssl.SSLContext; import ch.qos.logback.core.net.ssl.ConfigurableSSLServerSocketFactory; +import ch.qos.logback.core.net.ssl.SSLComponent; import ch.qos.logback.core.net.ssl.SSLConfiguration; import ch.qos.logback.core.net.ssl.SSLParametersConfiguration; @@ -28,7 +29,7 @@ import ch.qos.logback.core.net.ssl.SSLParametersConfiguration; * @author Carl Harris */ public abstract class SSLServerSocketAppenderBase - extends ServerSocketAppenderBase { + extends AbstractServerSocketAppender implements SSLComponent { private SSLConfiguration ssl; private ServerSocketFactory socketFactory; diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerListener.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerListener.java index f83092c6fbc86673cc6d3482cacc1f52e9014857..b72f53c8cf1fe5a56f5655c69e735b1c103c9607 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerListener.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerListener.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerRunner.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerRunner.java index b155cd9d5abadaeb71e27d999e3982483f8f3fe0..5ee4ba7a251e471c37f0fd74e20ec4e202717377 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerRunner.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerRunner.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -26,18 +26,14 @@ import ch.qos.logback.core.spi.ContextAware; * * @author Carl Harris */ -public interface ServerRunner extends ContextAware { +public interface ServerRunner extends ContextAware, Runnable { /** - * Starts execution of the runner. - *

- * After scheduling execution of itself, the receiver must return - * immediately. If the receiver is already running, this method must have - * no effect. - * @throws IOException + * Gets a flag indicating whether the server is currently running. + * @return flag state */ - void start() throws IOException; - + boolean isRunning(); + /** * Stops execution of the runner. *

@@ -48,12 +44,6 @@ public interface ServerRunner extends ContextAware { */ void stop() throws IOException; - /** - * Gets a flag indicating whether the receiver is running. - * @return flag state - */ - boolean isStarted(); - /** * Presents each connected client to the given visitor. * @param visitor the subject visitor diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerSocketListener.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerSocketListener.java index 0af6e11b911b4758a428e36bfa25ad65a580f99f..8b2bfd6a203125f6ac2b8dd2f6129954f3275e56 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerSocketListener.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerSocketListener.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/ThreadPoolFactoryBean.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/ThreadPoolFactoryBean.java deleted file mode 100644 index 997bcafd2cc066472f077a2fe4e7f51ccacccf1a..0000000000000000000000000000000000000000 --- a/logback-core/src/main/java/ch/qos/logback/core/net/server/ThreadPoolFactoryBean.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.core.net.server; - -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.SynchronousQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -/** - * A factory bean that creates an {@link Executor}. - *

- * This object holds the configurable properties of a thread pool and creates a - * properly configured {@link Executor}. - *

- * The default configuration of this bean creates a {@link ThreadPoolExecutor} - * that is functionally equivalent to the executor service created by - * {@link java.util.concurrent.Executors#newCachedThreadPool()}. It configures - * the pool with a single core thread and an (effectively) unbounded maximum - * pool size. It uses a {@link SynchronousQueue} for direct handoff of - * submitted tasks to a thread in the pool, with no queueing. This - * configuration is suitable for most applications. - *

- * When the {@code queueSize} property is set to a non-zero value, the - * resulting thread pool uses a bounded queue to hold submitted tasks while - * the total number of active tasks in the pool is at the limit specified by - * the {@code maximumPoolSize} property. In general this behavior is - * not desirable for applications that use a listener socket to accept - * new clients, which are then submitted to the pool as asynchronous clients. - * In such applications, it is best to allow new clients that cannot be - * accommodated (because all threads in the pool are assigned to existing - * clients) to simply remain in the listener socket's queue, since this - * has the least impact on local resources. - * - * @author Carl Harris - */ -public class ThreadPoolFactoryBean { - - public static final int DEFAULT_CORE_POOL_SIZE = 1; - public static final int DEFAULT_MAXIMUM_POOL_SIZE = Integer.MAX_VALUE; - public static final int DEFAULT_KEEP_ALIVE_TIME = 60000; - public static final int DEFAULT_QUEUE_SIZE = 0; - - private int corePoolSize = DEFAULT_CORE_POOL_SIZE; - private int maximumPoolSize = DEFAULT_MAXIMUM_POOL_SIZE; - private long keepAliveTime = DEFAULT_KEEP_ALIVE_TIME; - private int queueSize = DEFAULT_QUEUE_SIZE; - - /** - * Creates the executor service based on the bean's configuration. - * @return executor service - */ - public ExecutorService createExecutor() { - return createThreadPool(createQueue()); - } - - /** - * Creates the queue for the thread pool. - * @return a synchronous queue or bounded queue, depending on the specified - * queue size - */ - private BlockingQueue createQueue() { - try { - return queueSize == 0 ? - new SynchronousQueue() : - new ArrayBlockingQueue(getQueueSize()); - } - catch (IllegalArgumentException ex) { - throw new IllegalArgumentException("illegal threadPool.queueSize"); - } - } - - /** - * Creates a thread pool with a given work queue. - * @param queue work queue for the thread pool - * @return - */ - private ExecutorService createThreadPool(BlockingQueue queue) { - try { - return new ThreadPoolExecutor(getCorePoolSize(), getMaximumPoolSize(), - getKeepAliveTime(), TimeUnit.MILLISECONDS, queue); - } - catch (IllegalArgumentException ex) { - throw new IllegalArgumentException( - "illegal thread pool configuration: " + ex, ex); - } - } - - /** - * Gets the core size of the thread pool. - * @return number of idle threads that will be maintained in the pool even - * when no tasks are executing - */ - public int getCorePoolSize() { - return corePoolSize; - } - - /** - * Sets the core pool size of the thread pool. - * @param corePoolSize number of idle threads that will be maintained in the - * pool when no tasks are executing; note that a core thread is created - * only in response to a task submission - */ - public void setCorePoolSize(int corePoolSize) { - this.corePoolSize = corePoolSize; - } - - /** - * Gets the maximum size of the thread pool. - * @return maximum number of threads that are allowed in the pool - */ - public int getMaximumPoolSize() { - return maximumPoolSize; - } - - /** - * Sets the maximum size of the thread pool. - * @param maximumPoolSize number of threads that are allowed in the pool - */ - public void setMaximumPoolSize(int maximumPoolSize) { - this.maximumPoolSize = maximumPoolSize; - } - - /** - * Gets the keep alive time for idle threads in the pool. - * @return number of milliseconds that an idle thread will remain in the - * pool; note that when the number of threads in the pool is less than - * or equal to {@code corePoolSize} the remaining threads are retained - * in the pool indefinitely. - */ - public long getKeepAliveTime() { - return keepAliveTime; - } - - /** - * Sets the keep alive time for idle threads in the pool. - * @param keepAliveTime number of milliseconds that an idle thread will - * remain in the pool; note that when the number of threads in the pool - * is less than or equal to {@code corePoolSize} the remaining threads - * are retained in the pool indefinitely. - */ - public void setKeepAliveTime(long keepAliveTime) { - this.keepAliveTime = keepAliveTime; - } - - /** - * Gets the size of the thread pool's work queue. - * @return queue size - */ - public int getQueueSize() { - return queueSize; - } - - /** - * Sets the size of the thread pool's work queue. - * @param queueSize the queue size to set. Note that when the queue size is - * zero, the work queue will effectively inhibit queuing of submitted - * tasks; each task will either be assigned to a thread or will be - * rejected immediately, if the maximum number of threads has been - * reached. A positive queue size will result in a bounded work queue - * of the given size. - */ - public void setQueueSize(int queueSize) { - this.queueSize = queueSize; - } - -} diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/ConfigurableSSLServerSocketFactory.java b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/ConfigurableSSLServerSocketFactory.java index acf1a30667ea906d03fb539983bbfd30f640a252..94404e72bd917f99b9349a5aee2dd36cc9fe73b3 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/ConfigurableSSLServerSocketFactory.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/ConfigurableSSLServerSocketFactory.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/ConfigurableSSLSocketFactory.java b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/ConfigurableSSLSocketFactory.java index 8e6a90c7b6ffdae1c19a1f0fcd894874f8a670fe..742a33cd3e0f743c0a4040d3c3e1f5ab5992b6cb 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/ConfigurableSSLSocketFactory.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/ConfigurableSSLSocketFactory.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/KeyManagerFactoryFactoryBean.java b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/KeyManagerFactoryFactoryBean.java index 72b162110edc9c9c3a1a36f55de2a9e0b3f962a7..2082f9c71aed2a16db6ccc069df6df1091e58acf 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/KeyManagerFactoryFactoryBean.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/KeyManagerFactoryFactoryBean.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/KeyStoreFactoryBean.java b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/KeyStoreFactoryBean.java index 8abe3691483bd594a36f0d2a5800904959452767..488e2756f6b9924840dce52bea67ee657066aa1a 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/KeyStoreFactoryBean.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/KeyStoreFactoryBean.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSL.java b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSL.java index f00b6efeb3b9a97716d14640793f59f4d641d384..739e73ec28b472c682c4fe635d73554d04b1e01c 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSL.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSL.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLComponent.java b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLComponent.java new file mode 100644 index 0000000000000000000000000000000000000000..1287bb5b07f9bf9d3fce250a8135a6300fd946e3 --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLComponent.java @@ -0,0 +1,27 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package ch.qos.logback.core.net.ssl; + +/** + * A interface used to identify components that have an SSL configuration. + * + * @author Carl Harris + */ +public interface SSLComponent { + + SSLConfiguration getSsl(); + + void setSsl(SSLConfiguration ssl); + +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLConfigurable.java b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLConfigurable.java index 1165f8a74ff7971e186f2059f21250ceaccffcd4..ac7bd4013f372bf75d44f57cc906457bc52121f1 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLConfigurable.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLConfigurable.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLConfigurableServerSocket.java b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLConfigurableServerSocket.java index a5e21ebd9f1c85472d9aa83518c742f83a20efc5..1b40dc1992bd22d0614e4da435bb53c1870d0807 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLConfigurableServerSocket.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLConfigurableServerSocket.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLConfigurableSocket.java b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLConfigurableSocket.java index ad61970228c247c15c698b46027003579319e5b8..f4820be930166bc95811669ac0b886ddf54f0abc 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLConfigurableSocket.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLConfigurableSocket.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLConfiguration.java b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLConfiguration.java index 1bf07702cb1f99fe78a93d451735f705aae77c24..5795735856e7de15e3094f83a62a7bafd864d215 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLConfiguration.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLConfiguration.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLContextFactoryBean.java b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLContextFactoryBean.java index 447caf6613d63bb3a17f607b7780f4cb01da80bf..a012135d162e0cb4453b3073231ef4ba2281b727 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLContextFactoryBean.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLContextFactoryBean.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -40,6 +40,9 @@ import ch.qos.logback.core.spi.ContextAware; */ public class SSLContextFactoryBean { + private static final String JSSE_KEY_STORE_PROPERTY = "javax.net.ssl.keyStore"; + private static final String JSSE_TRUST_STORE_PROPERTY = "javax.net.ssl.trustStore"; + private KeyStoreFactoryBean keyStore; private KeyStoreFactoryBean trustStore; private SecureRandomFactoryBean secureRandom; @@ -169,6 +172,9 @@ public class SSLContextFactoryBean { * configuration was provided */ public KeyStoreFactoryBean getKeyStore() { + if (keyStore == null) { + keyStore = keyStoreFromSystemProperties(JSSE_KEY_STORE_PROPERTY); + } return keyStore; } @@ -186,6 +192,9 @@ public class SSLContextFactoryBean { * configuration was provided */ public KeyStoreFactoryBean getTrustStore() { + if (trustStore == null) { + trustStore = keyStoreFromSystemProperties(JSSE_TRUST_STORE_PROPERTY); + } return trustStore; } @@ -197,6 +206,36 @@ public class SSLContextFactoryBean { this.trustStore = trustStore; } + /** + * Constructs a key store factory bean using JSSE system properties. + * @param property base property name (e.g. {@code javax.net.ssl.keyStore}) + * @return key store or {@code null} if no value is defined for the + * base system property name + */ + private KeyStoreFactoryBean keyStoreFromSystemProperties(String property) { + if (System.getProperty(property) == null) return null; + KeyStoreFactoryBean keyStore = new KeyStoreFactoryBean(); + keyStore.setLocation(locationFromSystemProperty(property)); + keyStore.setProvider(System.getProperty(property + "Provider")); + keyStore.setPassword(System.getProperty(property + "Password")); + keyStore.setType(System.getProperty(property + "Type")); + return keyStore; + } + + /** + * Constructs a resource location from a JSSE system property. + * @param name property name (e.g. {@code javax.net.ssl.keyStore}) + * @return URL for the location specified in the property or {@code null} + * if no value is defined for the property + */ + private String locationFromSystemProperty(String name) { + String location = System.getProperty(name); + if (location != null && !location.startsWith("file:")) { + location = "file:" + location; + } + return location; + } + /** * Gets the secure random generator configuration. * @return secure random factory bean; if no secure random generator diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLNestedComponentRegistryRules.java b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLNestedComponentRegistryRules.java index 3faa70052e1de9d238ba137ae8d08824d8d0fa6e..8efb2296741aa9662e4ef3428ac28a1301a9f108 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLNestedComponentRegistryRules.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLNestedComponentRegistryRules.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -25,6 +25,7 @@ public class SSLNestedComponentRegistryRules { static public void addDefaultNestedComponentRegistryRules( DefaultNestedComponentRegistry registry) { + registry.add(SSLComponent.class, "ssl", SSLConfiguration.class); registry.add(SSLConfiguration.class, "parameters", SSLParametersConfiguration.class); registry.add(SSLConfiguration.class, "keyStore", diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLParametersConfiguration.java b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLParametersConfiguration.java index 4214c789024de01fdcc95bf417782fa621628f06..9d3573def044e262d06557a9e7736dc8b5f60f6a 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLParametersConfiguration.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLParametersConfiguration.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SecureRandomFactoryBean.java b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SecureRandomFactoryBean.java index 56774e8a9bade502f634f885ef968568abced358..7078035be0303c739cf300903cd18e1667a3c6f4 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SecureRandomFactoryBean.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SecureRandomFactoryBean.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/TrustManagerFactoryFactoryBean.java b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/TrustManagerFactoryFactoryBean.java index 7a17ed5a6c15b23565bbdd3de2a8be4efc1aa627..9db23708cf6db684d897cae0fc4c5fb268580e0f 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/TrustManagerFactoryFactoryBean.java +++ b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/TrustManagerFactoryFactoryBean.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/CompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/CompositeConverter.java index 2b86a84eeb6eac784b210899651f5c39347e915f..c119d93d3aeb7a3e23edea299cc31a4e9303f221 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/CompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/CompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/Converter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/Converter.java index d13f761c2a030cc5945aec54382b0d90394051b9..00b3240a3570f5da40fee47b3c8b3999b31f232a 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/Converter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/Converter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/ConverterUtil.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/ConverterUtil.java index 956cbb374633d4d442918ad3eca8987bf3653a54..5ded00fd5e25fa89beceaec711f02d4d83437d9f 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/ConverterUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/ConverterUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/DynamicConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/DynamicConverter.java index d4b321ae64272c1bb4240b37f6e770c3324a80a2..a4e4c5a5885733690059a39a7ebe04ea45796481 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/DynamicConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/DynamicConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/FormatInfo.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/FormatInfo.java index a89af9bb514263b176b2dbe6f09f21293c8e5ef3..e5d26163bf37d606d9a9107eb22bf2e004d86b58 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/FormatInfo.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/FormatInfo.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/FormattingConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/FormattingConverter.java index 7f5f1abbc42d07e30708fd3cc472ea5549adfcb0..7410da41e0b712e43f49edf0174ed242b7dc2a80 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/FormattingConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/FormattingConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/IdentityCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/IdentityCompositeConverter.java index a2c105b6795594629ccd0a52d32854d7e326f089..c54cc67fc0e5f575f6b5c1383603dd7b5dd14d46 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/IdentityCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/IdentityCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/LiteralConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/LiteralConverter.java index cd8180822ac02e9158bbdcb1163667ebd4e6884e..c1fb2ac249565476aac55476b755fa9f30402fb0 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/LiteralConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/LiteralConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java index ddff1127a495963923f9bf0b1adf7ab57ac2d0d8..30c14e0dd905dd6854521ef21bcb8feda0060245 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutEncoderBase.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutEncoderBase.java index 628afa140da0d7ee189702fd72ca0021aa833843..768b9d59e1378251d9d4d22c5976b732ebc3c631 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutEncoderBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutEncoderBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/PostCompileProcessor.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/PostCompileProcessor.java index 2d9b1b9af35e84beb4065299906c00c61ad3e59a..6957bef165dcb62be15b8d649b9e88b3a5bb0268 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/PostCompileProcessor.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/PostCompileProcessor.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/ReplacingCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/ReplacingCompositeConverter.java index 51249c0e372c9064f949b183f1f6a070ada5d012..2f453a1f57a0dbf14bfa547c44a6fdeaac93b79e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/ReplacingCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/ReplacingCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/SpacePadder.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/SpacePadder.java index e3d467e6ae196ea09fc607990e0001c88626fde7..b23fc47e29fd7e8653dc08a7635e48a338c8d371 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/SpacePadder.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/SpacePadder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/ANSIConstants.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/ANSIConstants.java index d2d1a4447d6a6db80b3b242e163aff152d5665d4..196b1fe8e8146fc058f8906fad7a9c314f75c79c 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/ANSIConstants.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/ANSIConstants.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BlackCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BlackCompositeConverter.java index 544cd1a80bec5aca6d7996ae406cd91e2d095046..263ce64f7ec1f8fc4cfcd0639ccacb7398641afe 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BlackCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BlackCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BlueCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BlueCompositeConverter.java index a39df1afdb4e32fbc8c9484f1f1796b66e86b787..7cbe80af1de608e63b1ee03a473b2bbe34fa44c9 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BlueCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BlueCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldBlueCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldBlueCompositeConverter.java index f4cc892b508060314d22af7738065c77b50ac219..25949bc4ee88eaa9ffdef33da0df3ce49d722206 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldBlueCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldBlueCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldCyanCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldCyanCompositeConverter.java index d333655b20a64904204b592fc06b077472876ca6..772f32161dd805c0a7e45d8128b78b9d07309d13 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldCyanCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldCyanCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldGreenCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldGreenCompositeConverter.java index 7a05cdab63f18f257a99797c7b2c5a7d0cb0ee13..0a89c9e1170dab9b16f34c4f178bac1d0003df53 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldGreenCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldGreenCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldMagentaCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldMagentaCompositeConverter.java index fbc109125abfe5730c603d3f201f6c2ee2b9697e..6d494cce275952df1e9dfecd80715494bba67ec1 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldMagentaCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldMagentaCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldRedCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldRedCompositeConverter.java index 9c0701e2ff8c6e0a53c88a8f88ee6f36ce751432..ebd557143b6aa0450225c9b4d78f32c4a1d1ecb2 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldRedCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldRedCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldWhiteCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldWhiteCompositeConverter.java index e49628fa700da83629d6a39720230f0d51a58fd2..df1f3ffa4804394027aca3b2ca079b37aafa682d 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldWhiteCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldWhiteCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldYellowCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldYellowCompositeConverter.java index 6a96deecbc1348a353376e049f871aee34c552ce..88a6092c41f4877cb05afe5998d15a7c4839fdc3 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldYellowCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/BoldYellowCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/CyanCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/CyanCompositeConverter.java index 72fff4bd8b59c5f0af8739fe626a73e720a70838..d215beb0c5aea3053370e65fabbf7ef819847328 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/CyanCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/CyanCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/ForegroundCompositeConverterBase.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/ForegroundCompositeConverterBase.java index fd2787a760fd04f84ba862e37d2feb8573f647df..12f90fbe2c3b32874e792f9f17a52ddbe967fad1 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/ForegroundCompositeConverterBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/ForegroundCompositeConverterBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/GrayCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/GrayCompositeConverter.java index 63d93260dfd27eccf0143bcefea5f01957035684..0e4903e098300807ce9584ef0e9b1e4b1759d3f2 100755 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/GrayCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/GrayCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/GreenCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/GreenCompositeConverter.java index b3479aa02d322a3e323787169bc20f381ba17094..82e9b927e8f546cc0ca8f189cd687c2f918c2ef7 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/GreenCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/GreenCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/MagentaCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/MagentaCompositeConverter.java index 4b1ae526ab00752647a2b3f451be45777231ac87..659b4a49254c3da68bbe729796ec3f1833a23249 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/MagentaCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/MagentaCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/RedCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/RedCompositeConverter.java index 2fa15a87316b23d328e881f22b003e5565ce35b3..4480a4ff628868cd423336808ad51e413b39e26f 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/RedCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/RedCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/WhiteCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/WhiteCompositeConverter.java index 8b1aa13633f58a7ae66188d3222aa0347c486e1c..8935d15cea2c115077231d374eaa03b99773c37a 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/WhiteCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/WhiteCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/YellowCompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/YellowCompositeConverter.java index 9346ea411b54d5ff3e0b72d61491aa279c46691f..51ccdaf40f3051a28536bc4ee866bb72db29f199 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/color/YellowCompositeConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/color/YellowCompositeConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Compiler.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Compiler.java index 8e766d65de36a60c345a7fb2119a35e15360b4cb..1999b5e5773ce4094a415f8b999a7058d110fcfd 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Compiler.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Compiler.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/CompositeNode.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/CompositeNode.java index 8d9c5d0e8afce702195b60064c1a0e1c085b033f..f439b363dbd488ff694dc14c2f9a872ed22935f5 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/CompositeNode.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/CompositeNode.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/FormattingNode.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/FormattingNode.java index 4c9012eab12bdcfa85aa7f1509aed075562d9863..484d2f9a1a6210bcee6e3d88bbf58821b3feb62e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/FormattingNode.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/FormattingNode.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Node.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Node.java index 8f52b44bebf1c220ec0c8c235f46e310bf9d7c4a..75410bc7987278e5260ac7b3fcb4d43f31b67a0c 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Node.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Node.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/OptionTokenizer.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/OptionTokenizer.java index 1eac0cbc1fa5e2dd9168c24f2f5e7f698ba27f5a..343a5e51eb668252c86f27a8643f5428275bd9ed 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/OptionTokenizer.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/OptionTokenizer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Parser.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Parser.java index 433dce1df7f2a8f08b7c8cc801666e611d7a3aae..30c31bdd1c218b9d33ef485eed1821960a8bf165 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Parser.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Parser.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/SimpleKeywordNode.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/SimpleKeywordNode.java index 23997f83da760788312b96499c6fe133eb453535..df8d9b8823c26a08e01fdf39a774744095adf805 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/SimpleKeywordNode.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/SimpleKeywordNode.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Token.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Token.java index 2bfdb23809bea7b099a4004a049990c971c3020e..6efc117a5864bb5fcae9c27d7f0520872262db68 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Token.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Token.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/TokenStream.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/TokenStream.java index 69f915fe9a4dae15e4ae95e19187d24df07ef326..66c11156e52f31f763aad861cceabff3d9fd69e6 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/TokenStream.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/TokenStream.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/util/AlmostAsIsEscapeUtil.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/util/AlmostAsIsEscapeUtil.java index 86fdbab18eb70fb9e8514ef39cebe7f03a0a8e1f..8e02c0507095428dfb7ebae92c59511ebea5799d 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/util/AlmostAsIsEscapeUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/util/AlmostAsIsEscapeUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/util/AsIsEscapeUtil.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/util/AsIsEscapeUtil.java index e3f78107473b12248c46d1c4ebd928765fe13bcf..3366f7487877d1ed56b34c11639ed4fd0244ab85 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/util/AsIsEscapeUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/util/AsIsEscapeUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/util/IEscapeUtil.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/util/IEscapeUtil.java index 60abe9db8e0c49d6f29da84cb1cff1fe29a744f1..6a7d1b5e6a2199a5e96318bdff46b88615fd02b0 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/util/IEscapeUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/util/IEscapeUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/util/RegularEscapeUtil.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/util/RegularEscapeUtil.java index b4e2a0f9008f78fe9a679e40ac288a84d86e5bac..e3474cedd823413e2eb60f638e668ef94922faf3 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/util/RegularEscapeUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/util/RegularEscapeUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/util/RestrictedEscapeUtil.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/util/RestrictedEscapeUtil.java index c3ece9b1282375bff1beb521f1942894f1d5dcc4..66b638945a7ea3433a214eeb6d868f72a7829cd6 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/pattern/util/RestrictedEscapeUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/util/RestrictedEscapeUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/property/FileExistsPropertyDefiner.java b/logback-core/src/main/java/ch/qos/logback/core/property/FileExistsPropertyDefiner.java index 2f108eeec78bcfafeb9f5ffec1d5fe147a32ce9b..61c26155881c2304c4eda02b1127b611dfb7ea14 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/property/FileExistsPropertyDefiner.java +++ b/logback-core/src/main/java/ch/qos/logback/core/property/FileExistsPropertyDefiner.java @@ -1,9 +1,30 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.property; import ch.qos.logback.core.PropertyDefinerBase; +import ch.qos.logback.core.util.OptionHelper; + import java.io.File; /** + * In conjunction with {@link ch.qos.logback.core.joran.action.PropertyAction} sets + * the named variable to "true" if the file specified by {@link #setPath(String) path} + * property exists, to "false" otherwise. + * + * @see #getPropertyValue() + * * @author Ceki Gücü */ public class FileExistsPropertyDefiner extends PropertyDefinerBase { @@ -14,18 +35,28 @@ public class FileExistsPropertyDefiner extends PropertyDefinerBase { return path; } + /** + * The path for the file to search for. + * + * @param path + */ public void setPath(String path) { this.path = path; } + /** + * Returns "true" if the file specified by {@link #setPath(String) path} property exists. + * Returns "false" otherwise. + * + * @return "true"|"false" depending on the existence of file + */ public String getPropertyValue() { - if(path == null) - return "false"; + if (OptionHelper.isEmpty(path)) { + addError("The \"path\" property must be set."); + return null; + } + File file = new File(path); - System.out.println(file.getAbsolutePath()); - if(file.exists()) - return "true"; - else - return "false"; + return booleanAsStr(file.exists()); } } diff --git a/logback-core/src/main/java/ch/qos/logback/core/property/ResourceExistsPropertyDefiner.java b/logback-core/src/main/java/ch/qos/logback/core/property/ResourceExistsPropertyDefiner.java new file mode 100644 index 0000000000000000000000000000000000000000..47e0dcbd3e713f2ac74f7c0845e64614493ae7a3 --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/property/ResourceExistsPropertyDefiner.java @@ -0,0 +1,53 @@ +package ch.qos.logback.core.property; + +import ch.qos.logback.core.PropertyDefinerBase; +import ch.qos.logback.core.util.Loader; +import ch.qos.logback.core.util.OptionHelper; + +import java.net.URL; + +/** + * In conjunction with {@link ch.qos.logback.core.joran.action.PropertyAction} sets + * the named variable to "true" if the {@link #setResource(String) resource} specified + * by the user is available on the class path, "false" otherwise. + * + * @see #getPropertyValue() + * + * @author XuHuisheng + * @author Ceki Gulcu + * @since 1.1.0 + */ +public class ResourceExistsPropertyDefiner extends PropertyDefinerBase { + + String resourceStr; + + public String getResource() { + return resourceStr; + } + + /** + * The resource to search for on the class path. + * + * @param resource + */ + public void setResource(String resource) { + this.resourceStr = resource; + } + + /** + * Returns the string "true" if the {@link #setResource(String) resource} specified by the + * user is available on the class path, "false" otherwise. + * + * @return "true"|"false" depending on the availability of resource on the classpath + */ + public String getPropertyValue() { + if (OptionHelper.isEmpty(resourceStr)) { + addError("The \"resource\" property must be set."); + return null; + } + + URL resourceURL = Loader.getResourceBySelfClassLoader(resourceStr); + return booleanAsStr(resourceURL != null); + } + +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/read/CyclicBufferAppender.java b/logback-core/src/main/java/ch/qos/logback/core/read/CyclicBufferAppender.java index bfe26a7dc1a92f74dcb8d42354c5d0b6a7d72eb9..9bb569b6c288a2c2080c04dfb5518e33ed0d8ddd 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/read/CyclicBufferAppender.java +++ b/logback-core/src/main/java/ch/qos/logback/core/read/CyclicBufferAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/read/ListAppender.java b/logback-core/src/main/java/ch/qos/logback/core/read/ListAppender.java index c17e9d0fab772761b99c88bdec9916dddbf89043..73ba4c10c37a23446795598b11dea60857f86794 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/read/ListAppender.java +++ b/logback-core/src/main/java/ch/qos/logback/core/read/ListAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/recovery/RecoveryCoordinator.java b/logback-core/src/main/java/ch/qos/logback/core/recovery/RecoveryCoordinator.java index 41efbd1d025a5270252945899c1c23f8181a7d00..dc1b97fea6e5017b065b2d31b7055356fdc890a8 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/recovery/RecoveryCoordinator.java +++ b/logback-core/src/main/java/ch/qos/logback/core/recovery/RecoveryCoordinator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java index d8f4994815dd877cc5f449b36d391f6caf956104..bc6f01e8ae21849e71f37702c9ab51df3e67e27c 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java +++ b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientOutputStreamBase.java b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientOutputStreamBase.java index caf31f351a61c04bf2633bd57fc2a774f87c2dfc..6eea6d19f987cec7b7bee025d4f3fd7505005821 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientOutputStreamBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientOutputStreamBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientSyslogOutputStream.java b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientSyslogOutputStream.java index ae0e3f62a278481cb3ab4216b999d012b485036a..8061e07fc4575d8b8f1353755751f76ea56e0a8d 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientSyslogOutputStream.java +++ b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientSyslogOutputStream.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/DefaultTimeBasedFileNamingAndTriggeringPolicy.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/DefaultTimeBasedFileNamingAndTriggeringPolicy.java index 45ffa3b2eb385ed7f4ca9f4e765716a830679893..22f220b17999fe43443e625c4e5c86a4ae00037f 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/DefaultTimeBasedFileNamingAndTriggeringPolicy.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/DefaultTimeBasedFileNamingAndTriggeringPolicy.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java index 7479c421ff4e5966e55a099f0d37f0abe2a65753..7573a888f6587a1876b6fe1e4cf1c9f1a8381a6e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -40,9 +40,9 @@ public class FixedWindowRollingPolicy extends RollingPolicyBase { public static final String ZIP_ENTRY_DATE_PATTERN = "yyyy-MM-dd_HHmm"; /** - * It's almost always a bad idea to have a large window size, say over 12. + * It's almost always a bad idea to have a large window size, say over 20. */ - private static int MAX_WINDOW_SIZE = 12; + private static int MAX_WINDOW_SIZE = 20; public FixedWindowRollingPolicy() { minIndex = 1; @@ -80,9 +80,10 @@ public class FixedWindowRollingPolicy extends RollingPolicyBase { maxIndex = minIndex; } - if ((maxIndex - minIndex) > MAX_WINDOW_SIZE) { + final int maxWindowSize = getMaxWindowSize(); + if ((maxIndex - minIndex) > maxWindowSize) { addWarn("Large window sizes are not allowed."); - maxIndex = minIndex + MAX_WINDOW_SIZE; + maxIndex = minIndex + maxWindowSize; addWarn("MaxIndex reduced to " + maxIndex); } @@ -103,6 +104,15 @@ public class FixedWindowRollingPolicy extends RollingPolicyBase { super.start(); } + /** + * Subclasses can override this method to increase the max window size, if required. This is to + * address LOGBACK-266. + * @return + */ + protected int getMaxWindowSize() { + return MAX_WINDOW_SIZE; + } + private String transformFileNamePatternFromInt2Date(String fileNamePatternStr) { String slashified = FileFilterUtil.slashify(fileNamePatternStr); String stemOfFileNamePattern = FileFilterUtil.afterLastSlash(slashified); diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java index c056f91f08c87a939268ad9b561117bfbce3f314..c02c91ec4d533e8ea8f9bdd4d54077fdcb10b625 100755 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingPolicy.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingPolicy.java index 424affe7103a5443df1ee3beab1ec428c146c06f..aae183e4bad95f4dab17cc3226863e1ca2c75294 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingPolicy.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingPolicy.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingPolicyBase.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingPolicyBase.java index a17972b15f9cdaadae02ff9f5374511d425161e5..14a60600e198124571bd38aeb19eb847a37f209e 100755 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingPolicyBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingPolicyBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/RolloverFailure.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/RolloverFailure.java index a201b3b26057d769919e544d1a574c84c24fdd98..e94c72004d4df9f62511f06e255e91931db9b553 100755 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/RolloverFailure.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/RolloverFailure.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP.java index 954205e89fb8cbea1fd379f98c20f0819497516a..a3e3aa365d4b06ed008d9f60db0d758ea285b762 100755 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicy.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicy.java index 088ead5c7795262f5ca1546254cd71f79b258ae7..d1c735f699247c13a786de6494d1ab53207adcab 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicy.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicy.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicy.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicy.java index 79fa2842667718e8888fc41a0f3c7f7c141d8442..53d39b1359844b28a4e1866c177db9b33c61f99e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicy.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicy.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicyBase.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicyBase.java index 69d8b4299c2374d757c4c648a48a46c013e1b81e..307f20f7696da1249f057caed031acbe6837808d 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicyBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicyBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java index 0908a2f6f9f97f734f4da0c603ae4f248701f00b..4d1225b68b5e22f7a443ddd4509e2c233cde284d 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -15,7 +15,10 @@ package ch.qos.logback.core.rolling; import java.io.File; import java.util.Date; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import ch.qos.logback.core.CoreConstants; import ch.qos.logback.core.rolling.helper.*; @@ -101,6 +104,26 @@ public class TimeBasedRollingPolicy extends RollingPolicyBase implements super.start(); } + @Override + public void stop() { + if(!isStarted()) + return; + waitForAsynchronousJobToStop(); + super.stop(); + } + + + private void waitForAsynchronousJobToStop() { + if(future != null) { + try { + future.get(CoreConstants.SECONDS_TO_WAIT_FOR_COMPRESSION_JOBS, TimeUnit.SECONDS); + } catch (TimeoutException e) { + addError("Timeout while waiting for compression job to finish", e); + } catch (Exception e) { + addError("Unexpected exception while waiting for compression job to finish", e); + } + } + } private String transformFileNamePattern2ZipEntry(String fileNamePatternStr) { String slashified = FileFilterUtil.slashify(fileNamePatternStr); return FileFilterUtil.afterLastSlash(slashified); @@ -123,8 +146,7 @@ public class TimeBasedRollingPolicy extends RollingPolicyBase implements String elapsedPeriodsFileName = timeBasedFileNamingAndTriggeringPolicy .getElapsedPeriodsFileName(); - String elpasedPeriodStem = FileFilterUtil.afterLastSlash(elapsedPeriodsFileName); - + String elapsedPeriodStem = FileFilterUtil.afterLastSlash(elapsedPeriodsFileName); if (compressionMode == CompressionMode.NONE) { if (getParentsRawFileProperty() != null) { @@ -132,9 +154,9 @@ public class TimeBasedRollingPolicy extends RollingPolicyBase implements } // else { nothing to do if CompressionMode == NONE and parentsRawFileProperty == null } } else { if (getParentsRawFileProperty() == null) { - future = asyncCompress(elapsedPeriodsFileName, elapsedPeriodsFileName, elpasedPeriodStem); + future = asyncCompress(elapsedPeriodsFileName, elapsedPeriodsFileName, elapsedPeriodStem); } else { - future = renamedRawAndAsyncCompress(elapsedPeriodsFileName, elpasedPeriodStem); + future = renamedRawAndAsyncCompress(elapsedPeriodsFileName, elapsedPeriodStem); } } diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/TriggeringPolicy.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/TriggeringPolicy.java index 37412a8032cd49480eb44450881d7338a811e3ac..b8453ccce12258a753f2678107eca7a535829a7e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/TriggeringPolicy.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/TriggeringPolicy.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/TriggeringPolicyBase.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/TriggeringPolicyBase.java index 199dff30b4536a814735fad57bf084cb7ecb7a58..18bc15688a486c35dd2ae6dcb63be59f0182a945 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/TriggeringPolicyBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/TriggeringPolicyBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/ArchiveRemover.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/ArchiveRemover.java index f59d0dc815faad64145b31af0ce00cc281e2dd94..54095e2a55d71f6fe5a8cb1955aae8fc6713355d 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/ArchiveRemover.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/ArchiveRemover.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/AsynchronousCompressor.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/AsynchronousCompressor.java index c35e370b0b2307f0c87a90c2b813e134f7779ce8..ebfb2a5d1601410f631295b78b8fede41c71c90d 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/AsynchronousCompressor.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/AsynchronousCompressor.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/CompressionMode.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/CompressionMode.java index 4e816448d0af8d9c59555936c669490dce9e3aba..f5cc4981d7bc61a208f627a38256b1a231b15e5b 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/CompressionMode.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/CompressionMode.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/CompressionRunnable.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/CompressionRunnable.java index a13f6dcf392a1e5e3be171033f8d56e66791a111..0f2b12e7ced714eefe23f0dd39208db4bb488117 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/CompressionRunnable.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/CompressionRunnable.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/Compressor.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/Compressor.java index b90539e1fc58353214a46e25fda28d7849494bac..67fac08579d509a8828a7246c6042802beda03a7 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/Compressor.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/Compressor.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DateTokenConverter.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DateTokenConverter.java index cba96451c137194f6a13466256be73166c9b89b4..56b6571a30b03fe8b4f125d0d85f74eef132a40a 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DateTokenConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DateTokenConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DefaultArchiveRemover.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DefaultArchiveRemover.java index 825384449e696e641e1e3a9ee1fda3ea50c91264..ca5f33dce4d31a06a0999179953664f2f0c03f36 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DefaultArchiveRemover.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DefaultArchiveRemover.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileFilterUtil.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileFilterUtil.java index 7e5da7bddb25594d307eeae0ab0feaa77674ceab..e65d5162c852584fcc19d4f73fc1f06c533017a3 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileFilterUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileFilterUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileNamePattern.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileNamePattern.java index 38927bfad4de57ce20819543f0b3b6a6927fcfd0..9ffaf3ca56d1c47ff1c2159b304e0955ef092f57 100755 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileNamePattern.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileNamePattern.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/IntegerTokenConverter.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/IntegerTokenConverter.java index d914b5d4e6d2aa3544f7c2c86e8f30c095098ab0..708b83de1968ac0f46f0adea8122343ce6ab7fa7 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/IntegerTokenConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/IntegerTokenConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/MonoTypedConverter.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/MonoTypedConverter.java index bd63b2e23ed6c1bb177588038450741ba3d2ba7d..16bb87367417c66546cee842f098e4eb90725165 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/MonoTypedConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/MonoTypedConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/PeriodicityType.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/PeriodicityType.java index c315e9715ff710a14c4881b60946a99d780b240d..0aac593501aaff95c76769a506c6f9ba06e4b01b 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/PeriodicityType.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/PeriodicityType.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RenameUtil.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RenameUtil.java index 14c4e734f46fc8931f7f044679057ecd373494ae..a16b60ecee0b2af20759252e044931e33d670d02 100755 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RenameUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RenameUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RollingCalendar.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RollingCalendar.java index d4bd02bf7f6553596732fede590d8c1c503322f3..5411098396e161c6f292dac72b49294845672f74 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RollingCalendar.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RollingCalendar.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/SizeAndTimeBasedArchiveRemover.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/SizeAndTimeBasedArchiveRemover.java index 639a9bde57d9e75ccec516d83093a51427403ec7..3e98fce7b5397c778c78ea4c333291e06d27bb30 100755 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/SizeAndTimeBasedArchiveRemover.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/SizeAndTimeBasedArchiveRemover.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/TimeBasedArchiveRemover.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/TimeBasedArchiveRemover.java index 0a2a90bb55ffa03115b333bd872f9f7265dcdbe0..da280a595e973e5b2845cc2f328944c3e62cf2cd 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/TimeBasedArchiveRemover.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/TimeBasedArchiveRemover.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/TokenConverter.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/TokenConverter.java index 0998d6916f63cdfaf925b6bcb4010a68e1b003e8..21712b74cd44c30774aad6f4aa4ef6797932e7ba 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/TokenConverter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/TokenConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderFactoryBase.java b/logback-core/src/main/java/ch/qos/logback/core/sift/AbstractAppenderFactoryUsingJoran.java similarity index 53% rename from logback-core/src/main/java/ch/qos/logback/core/sift/AppenderFactoryBase.java rename to logback-core/src/main/java/ch/qos/logback/core/sift/AbstractAppenderFactoryUsingJoran.java index 44654fd95ec3133dad02fe58ff8bbfd2d6855bb1..b0434be98d94a6a545631cc9f2e2b112bb485d8a 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderFactoryBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/sift/AbstractAppenderFactoryUsingJoran.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,31 +13,39 @@ */ package ch.qos.logback.core.sift; -import java.util.ArrayList; import java.util.List; +import java.util.Map; import ch.qos.logback.core.Appender; import ch.qos.logback.core.Context; import ch.qos.logback.core.joran.event.SaxEvent; import ch.qos.logback.core.joran.spi.JoranException; -public abstract class AppenderFactoryBase { +/** + * Builds new appenders dynamically by running SiftingJoranConfigurator instance, + * a custom configurator tailored for the contents of the sift element. + * @param + */ +public abstract class AbstractAppenderFactoryUsingJoran implements AppenderFactory { final List eventList; - - protected AppenderFactoryBase(List eventList) { - this.eventList = new ArrayList(eventList); - removeSiftElement(); + protected String key; + protected Map parentPropertyMap; + + protected AbstractAppenderFactoryUsingJoran(List eventList, String key, Map parentPropertyMap) { + this.eventList = removeSiftElement(eventList); + this.key = key; + this.parentPropertyMap = parentPropertyMap; + } - void removeSiftElement() { - eventList.remove(0); - eventList.remove(eventList.size() - 1); + List removeSiftElement(List eventList) { + return eventList.subList(1, eventList.size() - 1); } public abstract SiftingJoranConfiguratorBase getSiftingJoranConfigurator(String k); - Appender buildAppender(Context context, String discriminatingValue) throws JoranException { + public Appender buildAppender(Context context, String discriminatingValue) throws JoranException { SiftingJoranConfiguratorBase sjc = getSiftingJoranConfigurator(discriminatingValue); sjc.setContext(context); sjc.doConfigure(eventList); diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/AbstractDiscriminator.java b/logback-core/src/main/java/ch/qos/logback/core/sift/AbstractDiscriminator.java new file mode 100644 index 0000000000000000000000000000000000000000..df1b8bb718361b157562970d0796259b080a1599 --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/sift/AbstractDiscriminator.java @@ -0,0 +1,26 @@ +package ch.qos.logback.core.sift; + +import ch.qos.logback.core.spi.ContextAwareBase; + +/** + * Base implementation of {@link Discriminator} that provides basic lifecycle management + * + * @author Tomasz Nurkiewicz + * @since 3/29/13, 3:28 PM + */ +public abstract class AbstractDiscriminator extends ContextAwareBase implements Discriminator { + + protected boolean started; + + public void start() { + started = true; + } + + public void stop() { + started = false; + } + + public boolean isStarted() { + return started; + } +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderFactory.java b/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..542d15994875a7e2df4d30e865e9d8d9b8baea10 --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderFactory.java @@ -0,0 +1,16 @@ +package ch.qos.logback.core.sift; + +import ch.qos.logback.core.Appender; +import ch.qos.logback.core.Context; +import ch.qos.logback.core.joran.spi.JoranException; + +/** + * Created with IntelliJ IDEA. + * User: ceki + * Date: 25.04.13 + * Time: 19:00 + * To change this template use File | Settings | File Templates. + */ +public interface AppenderFactory { + Appender buildAppender(Context context, String discriminatingValue) throws JoranException; +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTracker.java b/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTracker.java index 112cbbb6be64f5ad377dcc354eed85660ef22434..9e670e30fe30aee647dd67c5f7517590faa0704e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTracker.java +++ b/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTracker.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,19 +13,72 @@ */ package ch.qos.logback.core.sift; -import java.util.List; - import ch.qos.logback.core.Appender; +import ch.qos.logback.core.Context; import ch.qos.logback.core.CoreConstants; +import ch.qos.logback.core.helpers.NOPAppender; +import ch.qos.logback.core.joran.spi.JoranException; +import ch.qos.logback.core.spi.AbstractComponentTracker; +import ch.qos.logback.core.spi.ContextAwareImpl; + +/** + * Track appenders by key. When an appender is not used for + * longer than {@link #DEFAULT_TIMEOUT} it is stopped and removed. + * + * @author Tommy Becker + * @author Ceki Gulcu + * @author David Roussel + */ +public class AppenderTracker extends AbstractComponentTracker> { + + int nopaWarningCount = 0; + + final Context context; + final AppenderFactory appenderFactory; + final ContextAwareImpl contextAware; + + public AppenderTracker(Context context, AppenderFactory appenderFactory) { + super(); + this.context = context; + this.appenderFactory = appenderFactory; + this.contextAware = new ContextAwareImpl(context, this); + } + + + @Override + protected void processPriorToRemoval(Appender component) { + component.stop(); + } + + @Override + protected Appender buildComponent(String key) { + Appender appender = null; + try { + appender = appenderFactory.buildAppender(context, key); + } catch (JoranException je) { + contextAware.addError("Error while building appender with discriminating value [" + key + "]"); + } + if (appender == null) { + appender = buildNOPAppender(key); + } + + return appender; + } -public interface AppenderTracker { + private NOPAppender buildNOPAppender(String key) { + if (nopaWarningCount < CoreConstants.MAX_ERROR_COUNT) { + nopaWarningCount++; + contextAware.addError("Building NOPAppender for discriminating value [" + key + "]"); + } + NOPAppender nopa = new NOPAppender(); + nopa.setContext(context); + nopa.start(); + return nopa; + } - int THRESHOLD = 30 * 60 * CoreConstants.MILLIS_IN_ONE_SECOND; // 30 minutes + @Override + protected boolean isComponentStale(Appender appender) { + return !appender.isStarted(); + } - void put(String key, Appender value, long timestamp); - Appender get(String key, long timestamp); - void stopStaleAppenders(long timestamp); - List keyList(); - List> valueList(); - void stopAndRemoveNow(String key); -} \ No newline at end of file +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java b/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java deleted file mode 100644 index c5a361aeea72177fc6b621a371c80834eeb24651..0000000000000000000000000000000000000000 --- a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java +++ /dev/null @@ -1,239 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.core.sift; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import ch.qos.logback.core.Appender; -import ch.qos.logback.core.CoreConstants; - -/** - * Track appenders by a key. When an appender is not used for - * longer than THRESHOLD, stop it. - * @author Ceki Gulcu - */ -public class AppenderTrackerImpl implements AppenderTracker { - - Map map = new HashMap(); - - Entry head; // least recently used entries are towards the head - Entry tail; // most recently used entries are towards the tail - - long lastCheck = 0; - - AppenderTrackerImpl() { - head = new Entry(null, null, 0); - tail = head; - } - - - public synchronized void put(String key, Appender value, long timestamp) { - Entry entry = map.get(key); - if (entry == null) { - entry = new Entry(key, value, timestamp); - map.put(key, entry); - } - moveToTail(entry); - } - - public synchronized Appender get(String key, long timestamp) { - Entry existing = map.get(key); - if (existing == null) { - return null; - } else { - existing.setTimestamp(timestamp); - moveToTail(existing); - return existing.value; - } - } - - - public synchronized void stopStaleAppenders(long now) { - if (lastCheck + CoreConstants.MILLIS_IN_ONE_SECOND > now) { - return; - } - lastCheck = now; - while (head.value != null && isEntryStale(head,now)) { - Appender appender = head.value; - appender.stop(); - removeHead(); - } - } - - /** - * @since 0.9.19 - * @param key - */ - public synchronized void stopAndRemoveNow(String key) { - Entry e = head; - Entry found = null; - while (e != tail) { - if(key.equals(e.key)) { - found = e; - break; - } - e = e.next; - } - if(found != null) { - rearrangePreexistingLinks(e); - map.remove(key); - Appender appender = e.value; - appender.stop(); - } - } - - public List keyList() { - List result = new LinkedList(); - Entry e = head; - while (e != tail) { - result.add(e.key); - e = e.next; - } - return result; - } - - - private boolean isEntryStale(Entry entry, long now) { - // stopped or improperly started appenders are considered stale - // see also http://jira.qos.ch/browse/LBCLASSIC-316 - if(!entry.value.isStarted()) - return true; - - // unused appenders are also considered stale - return ((entry.timestamp + THRESHOLD) < now); - } - - - private void removeHead() { - // System.out.println("RemoveHead called"); - map.remove(head.key); - head = head.next; - head.prev = null; - } - - private void moveToTail(Entry e) { - rearrangePreexistingLinks(e); - rearrangeTailLinks(e); - } - - private void rearrangePreexistingLinks(Entry e) { - if (e.prev != null) { - e.prev.next = e.next; - } - if (e.next != null) { - e.next.prev = e.prev; - } - if (head == e) { - head = e.next; - } - } - - private void rearrangeTailLinks(Entry e) { - if (head == tail) { - head = e; - } - Entry preTail = tail.prev; - if (preTail != null) { - preTail.next = e; - } - e.prev = preTail; - e.next = tail; - tail.prev = e; - } - - public void dump() { - Entry e = head; - System.out.print("N:"); - while (e != null) { - // System.out.print(e+"->"); - System.out.print(e.key + ", "); - e = e.next; - } - System.out.println(); - } - - - - public List> valueList() { - List> result = new LinkedList>(); - Entry e = head; - while (e != tail) { - result.add(e.value); - e = e.next; - } - return result; - } - - // ================================================================ - private class Entry { - Entry next; - Entry prev; - - String key; - Appender value; - long timestamp; - - Entry(String k, Appender v, long timestamp) { - this.key = k; - this.value = v; - this.timestamp = timestamp; - } - -// public long getTimestamp() { -// return timestamp; -// } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((key == null) ? 0 : key.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - final Entry other = (Entry) obj; - if (key == null) { - if (other.key != null) - return false; - } else if (!key.equals(other.key)) - return false; - if (value == null) { - if (other.value != null) - return false; - } else if (!value.equals(other.value)) - return false; - return true; - } - - @Override - public String toString() { - return "(" + key + ", " + value + ")"; - } - } -} diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/DefaultDiscriminator.java b/logback-core/src/main/java/ch/qos/logback/core/sift/DefaultDiscriminator.java index 66c9c808cfe9153322fd69e218fa20a2628f224a..89743e0bebb60175431d7095245f0ce674d1269e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/sift/DefaultDiscriminator.java +++ b/logback-core/src/main/java/ch/qos/logback/core/sift/DefaultDiscriminator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,17 +13,14 @@ */ package ch.qos.logback.core.sift; -import ch.qos.logback.core.sift.Discriminator; /** * @author Ceki Gücü */ -public class DefaultDiscriminator implements Discriminator { +public class DefaultDiscriminator extends AbstractDiscriminator { static public final String DEFAULT = "default"; - boolean started = false; - public String getDiscriminatingValue(E e) { return DEFAULT; } @@ -32,15 +29,4 @@ public class DefaultDiscriminator implements Discriminator { return DEFAULT; } - public void start() { - started = true; - } - - public void stop() { - started = false; - } - - public boolean isStarted() { - return started; - } } diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/Discriminator.java b/logback-core/src/main/java/ch/qos/logback/core/sift/Discriminator.java index 2618a8e88bd4989f8961027c10114f97b2ec55b1..080750bfd7f1e015a84147572a9bfb28f59ccfe1 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/sift/Discriminator.java +++ b/logback-core/src/main/java/ch/qos/logback/core/sift/Discriminator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/SiftingAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/sift/SiftingAppenderBase.java index 12d3dc5d39143a956c1bc97882ec9f8ea1c1f13b..e919b93310ac33dc44f0816257915471e8d9ed39 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/sift/SiftingAppenderBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/sift/SiftingAppenderBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -15,28 +15,49 @@ package ch.qos.logback.core.sift; import ch.qos.logback.core.Appender; import ch.qos.logback.core.AppenderBase; -import ch.qos.logback.core.CoreConstants; -import ch.qos.logback.core.helpers.NOPAppender; -import ch.qos.logback.core.joran.spi.JoranException; +import ch.qos.logback.core.util.Duration; /** * This appender serves as the base class for actual SiftingAppenders * implemented by the logback-classic and logback-access modules. In a nutshell, * a SiftingAppender contains other appenders which it can build dynamically - * depending on discriminating values supplied by event currently being - * processed. The built appender is specified as part of a configuration file. - * + * depending on discriminating values supplied by the event currently being + * processed. The appender to build (dynamically) is specified as part of a + * configuration file. + * * @author Ceki Gulcu */ public abstract class SiftingAppenderBase extends - AppenderBase { + AppenderBase { - protected AppenderTracker appenderTracker = new AppenderTrackerImpl(); - AppenderFactoryBase appenderFactory; + protected AppenderTracker appenderTracker; + AppenderFactory appenderFactory; + Duration timeout = new Duration(AppenderTracker.DEFAULT_TIMEOUT); + int maxAppenderCount = AppenderTracker.DEFAULT_MAX_COMPONENTS; Discriminator discriminator; - public void setAppenderFactory(AppenderFactoryBase appenderFactory) { + public Duration getTimeout() { + return timeout; + } + + public void setTimeout(Duration timeout) { + this.timeout = timeout; + } + + public int getMaxAppenderCount() { + return maxAppenderCount; + } + + public void setMaxAppenderCount(int maxAppenderCount) { + this.maxAppenderCount = maxAppenderCount; + } + + /** + * This setter is intended to be invoked by SiftAction. Customers have no reason to invoke + * this method directly. + */ + public void setAppenderFactory(AppenderFactory appenderFactory) { this.appenderFactory = appenderFactory; } @@ -51,6 +72,14 @@ public abstract class SiftingAppenderBase extends addError("Discriminator has not started successfully. Aborting"); errors++; } + if (appenderFactory == null) { + addError("AppenderFactory has not been set. Aborting"); + errors++; + } else { + appenderTracker = new AppenderTracker(context, appenderFactory); + appenderTracker.setMaxComponents(maxAppenderCount); + appenderTracker.setTimeout(timeout.getMilliseconds()); + } if (errors == 0) { super.start(); } @@ -58,7 +87,7 @@ public abstract class SiftingAppenderBase extends @Override public void stop() { - for (Appender appender : appenderTracker.valueList()) { + for (Appender appender : appenderTracker.allComponents()) { appender.stop(); } } @@ -70,30 +99,20 @@ public abstract class SiftingAppenderBase extends if (!isStarted()) { return; } - String discriminatingValue = discriminator.getDiscriminatingValue(event); long timestamp = getTimestamp(event); - - Appender appender = appenderTracker.get(discriminatingValue, timestamp); - if (appender == null) { - try { - appender = appenderFactory.buildAppender(context, discriminatingValue); - if (appender == null) { - appender = buildNOPAppender(discriminatingValue); - } - appenderTracker.put(discriminatingValue, appender, timestamp); - - } catch (JoranException e) { - addError("Failed to build appender for [" + discriminatingValue + "]", - e); - return; - } + + Appender appender = appenderTracker.getOrCreate(discriminatingValue, timestamp); + // marks the appender for removal as specified by the user + if (eventMarksEndOfLife(event)) { + appenderTracker.endOfLife(discriminatingValue); } - appenderTracker.stopStaleAppenders(timestamp); - + appenderTracker.removeStaleComponents(timestamp); appender.doAppend(event); } + protected abstract boolean eventMarksEndOfLife(E event); + public Discriminator getDiscriminator() { return discriminator; } @@ -101,30 +120,18 @@ public abstract class SiftingAppenderBase extends public void setDiscriminator(Discriminator discriminator) { this.discriminator = discriminator; } - - - int nopaWarningCount = 0; - - NOPAppender buildNOPAppender(String discriminatingValue) { - if(nopaWarningCount < CoreConstants.MAX_ERROR_COUNT) { - nopaWarningCount++; - addError("Failed to build an appender for discriminating value ["+discriminatingValue+"]"); - } - NOPAppender nopa = new NOPAppender(); - nopa.setContext(context); - nopa.start(); - return nopa; - } - // sometime one needs to close a nested appender immediately + + // sometimes one needs to close a nested appender immediately // for example when executing a command which has its own nested appender // and the command also cleans up after itself. However, an open file appender // will prevent the folder from being deleted // see http://www.qos.ch/pipermail/logback-user/2010-March/001487.html + /** * @since 0.9.19 */ - public AppenderTracker getAppenderTracker() { + public AppenderTracker getAppenderTracker() { return appenderTracker; } diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/SiftingJoranConfiguratorBase.java b/logback-core/src/main/java/ch/qos/logback/core/sift/SiftingJoranConfiguratorBase.java index b5d56433e5376e07d8b92dadbb6d4ab13d58960a..3391c04c86279ae589cca935d1f6111c4609d934 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/sift/SiftingJoranConfiguratorBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/sift/SiftingJoranConfiguratorBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -19,17 +19,29 @@ import java.util.Map; import ch.qos.logback.core.Appender; import ch.qos.logback.core.CoreConstants; import ch.qos.logback.core.joran.GenericConfigurator; -import ch.qos.logback.core.joran.action.NestedBasicPropertyIA; -import ch.qos.logback.core.joran.action.NestedComplexPropertyIA; +import ch.qos.logback.core.joran.action.*; import ch.qos.logback.core.joran.event.SaxEvent; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.joran.spi.Interpreter; import ch.qos.logback.core.joran.spi.JoranException; +import ch.qos.logback.core.joran.spi.RuleStore; public abstract class SiftingJoranConfiguratorBase extends - GenericConfigurator { + GenericConfigurator { + + protected final String key; + protected final String value; + // properties inherited from the main joran run + protected final Map parentPropertyMap; + + protected SiftingJoranConfiguratorBase(String key, String value, Map parentPropertyMap) { + this.key = key; + this.value = value; + this.parentPropertyMap = parentPropertyMap; + } final static String ONE_AND_ONLY_ONE_URL = CoreConstants.CODES_URL - + "#1andOnly1"; + + "#1andOnly1"; @Override protected void addImplicitRules(Interpreter interpreter) { @@ -42,11 +54,18 @@ public abstract class SiftingJoranConfiguratorBase extends interpreter.addImplicitAction(nestedSimpleIA); } + @Override + protected void addInstanceRules(RuleStore rs) { + rs.addRule(new ElementSelector("configuration/property"), new PropertyAction()); + rs.addRule(new ElementSelector("configuration/timestamp"), new TimestampAction()); + rs.addRule(new ElementSelector("configuration/define"), new DefinePropertyAction()); + } + abstract public Appender getAppender(); int errorEmmissionCount = 0; - protected void oneAndOnlyOneCheck(Map appenderMap) { + protected void oneAndOnlyOneCheck(Map appenderMap) { String errMsg = null; if (appenderMap.size() == 0) { errorEmmissionCount++; @@ -54,7 +73,7 @@ public abstract class SiftingJoranConfiguratorBase extends } else if (appenderMap.size() > 1) { errorEmmissionCount++; errMsg = "Only and only one appender can be nested the element in SiftingAppender. See also " - + ONE_AND_ONLY_ONE_URL; + + ONE_AND_ONLY_ONE_URL; } if (errMsg != null && errorEmmissionCount < CoreConstants.MAX_ERROR_COUNT) { @@ -65,4 +84,9 @@ public abstract class SiftingJoranConfiguratorBase extends public void doConfigure(final List eventList) throws JoranException { super.doConfigure(eventList); } + + @Override + public String toString() { + return this.getClass().getName() + "{" + key + "=" + value + '}'; + } } diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/AbstractComponentTracker.java b/logback-core/src/main/java/ch/qos/logback/core/spi/AbstractComponentTracker.java new file mode 100755 index 0000000000000000000000000000000000000000..534af9a62766713e87db05d0843e9a6643e3ade7 --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/AbstractComponentTracker.java @@ -0,0 +1,310 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package ch.qos.logback.core.spi; + + +import ch.qos.logback.core.CoreConstants; + +import java.util.*; + +/** + * An abstract implementation of the ComponentTracker interface. Derived classes must implement + * {@link #buildComponent(String)}, {@link #processPriorToRemoval(Object)}, and {@link #isComponentStale(Object)} + * methods as appropriate for their component type. + * + * @param component type + * + * @author Tommy Becker + * @author Ceki Gulcu + * @author David Roussel + */ +abstract public class AbstractComponentTracker implements ComponentTracker { + private static final boolean ACCESS_ORDERED = true; + + // Components in lingering state last 10 seconds + final public static long LINGERING_TIMEOUT = 10 * CoreConstants.MILLIS_IN_ONE_SECOND; + + /** + * The minimum amount of time that has to elapse between successive removal iterations. + */ + final public static long WAIT_BETWEEN_SUCCESSIVE_REMOVAL_ITERATIONS = CoreConstants.MILLIS_IN_ONE_SECOND; + + protected int maxComponents = DEFAULT_MAX_COMPONENTS; + protected long timeout = DEFAULT_TIMEOUT; + + // an access ordered map. Least recently accessed element will be removed after a 'timeout' + LinkedHashMap> liveMap = new LinkedHashMap>(32, .75f, ACCESS_ORDERED); + + // an access ordered map. Least recently accessed element will be removed after LINGERING_TIMEOUT + LinkedHashMap> lingerersMap = new LinkedHashMap>(16, .75f, ACCESS_ORDERED); + long lastCheck = 0; + + /** + * Stop or clean the component. + * + * @param component + */ + abstract protected void processPriorToRemoval(C component); + + /** + * Build a component based on the key. + * + * @param key + * @return + */ + abstract protected C buildComponent(String key); + + /** + * Components can declare themselves stale. Such components may be + * removed before they time out. + * + * @param c + * @return + */ + protected abstract boolean isComponentStale(C c); + + + public int getComponentCount() { + return liveMap.size() + lingerersMap.size(); + } + + /** + * Get an entry from the liveMap, if not found search the lingerersMap. + * + * @param key + * @return + */ + private Entry getFromEitherMap(String key) { + Entry entry = liveMap.get(key); + if (entry != null) + return entry; + else { + return lingerersMap.get(key); + } + } + + /** + * {@inheritDoc} + * + *

Note that this method is synchronized.

+ * + * @param key {@inheritDoc} + * @return {@inheritDoc} + * + */ + public synchronized C find(String key) { + Entry entry = getFromEitherMap(key); + if (entry == null) return null; + else return entry.component; + } + + /** + * {@inheritDoc} + * + *

Note that this method is atomic, i.e. synchronized.

+ * + * @param key {@inheritDoc} + * @param timestamp {@inheritDoc} + * @return {@inheritDoc} + */ + public synchronized C getOrCreate(String key, long timestamp) { + Entry entry = getFromEitherMap(key); + if (entry == null) { + C c = buildComponent(key); + entry = new Entry(key, c, timestamp); + // new entries go into the main map + liveMap.put(key, entry); + } else { + entry.setTimestamp(timestamp); + } + return entry.component; + } + + /** + * Mark component identified by 'key' as having reached its end-of-life. + * + * @param key + */ + public void endOfLife(String key) { + Entry entry = liveMap.remove(key); + if (entry == null) + return; + lingerersMap.put(key, entry); + } + + /** + * Clear (and detach) components which are stale. Components which have not + * been accessed for more than a user-specified duration are deemed stale. + * + * @param now + */ + public synchronized void removeStaleComponents(long now) { + if (isTooSoonForRemovalIteration(now)) return; + removeExcedentComponents(); + removeStaleComponentsFromMainMap(now); + removeStaleComponentsFromLingerersMap(now); + } + + private void removeExcedentComponents() { + genericStaleComponentRemover(liveMap, 0, byExcedent); + } + + private void removeStaleComponentsFromMainMap(long now) { + genericStaleComponentRemover(liveMap, now, byTimeout); + } + + private void removeStaleComponentsFromLingerersMap(long now) { + genericStaleComponentRemover(lingerersMap, now, byLingering); + } + + private void genericStaleComponentRemover(LinkedHashMap> map, long now, + RemovalPredicator removalPredicator) { + Iterator>> iter = map.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry> mapEntry = iter.next(); + Entry entry = mapEntry.getValue(); + if (removalPredicator.isSlatedForRemoval(entry, now)) { + iter.remove(); + C c = entry.component; + processPriorToRemoval(c); + } else { + break; + } + } + } + + private RemovalPredicator byExcedent = new RemovalPredicator() { + public boolean isSlatedForRemoval(Entry entry, long timestamp) { + return (liveMap.size() > maxComponents); + } + }; + + private RemovalPredicator byTimeout = new RemovalPredicator() { + public boolean isSlatedForRemoval(Entry entry, long timestamp) { + return isEntryStale(entry, timestamp); + } + }; + private RemovalPredicator byLingering = new RemovalPredicator() { + public boolean isSlatedForRemoval(Entry entry, long timestamp) { + return isEntryDoneLingering(entry, timestamp); + } + }; + + private boolean isTooSoonForRemovalIteration(long now) { + if (lastCheck + WAIT_BETWEEN_SUCCESSIVE_REMOVAL_ITERATIONS > now) { + return true; + } + lastCheck = now; + return false; + } + + private boolean isEntryStale(Entry entry, long now) { + // stopped or improperly started appenders are considered stale + // see also http://jira.qos.ch/browse/LBCLASSIC-316 + C c = entry.component; + if (isComponentStale(c)) + return true; + + return ((entry.timestamp + timeout) < now); + } + + private boolean isEntryDoneLingering(Entry entry, long now) { + return ((entry.timestamp + LINGERING_TIMEOUT) < now); + } + + public Set allKeys() { + HashSet allKeys = new HashSet(liveMap.keySet()); + allKeys.addAll(lingerersMap.keySet()); + return allKeys; + } + + public Collection allComponents() { + List allComponents = new ArrayList(); + for (Entry e : liveMap.values()) + allComponents.add(e.component); + for (Entry e : lingerersMap.values()) + allComponents.add(e.component); + + return allComponents; + } + + public long getTimeout() { + return timeout; + } + + public void setTimeout(long timeout) { + this.timeout = timeout; + } + + public int getMaxComponents() { + return maxComponents; + } + + public void setMaxComponents(int maxComponents) { + this.maxComponents = maxComponents; + } + + // ================================================================ + private interface RemovalPredicator { + boolean isSlatedForRemoval(Entry entry, long timestamp); + } + // ================================================================ + private static class Entry { + String key; + C component; + long timestamp; + + Entry(String k, C c, long timestamp) { + this.key = k; + this.component = c; + this.timestamp = timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + @Override + public int hashCode() { + return key.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Entry other = (Entry) obj; + if (key == null) { + if (other.key != null) + return false; + } else if (!key.equals(other.key)) + return false; + if (component == null) { + if (other.component != null) + return false; + } else if (!component.equals(other.component)) + return false; + return true; + } + + @Override + public String toString() { + return "(" + key + ", " + component + ")"; + } + } +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/AppenderAttachable.java b/logback-core/src/main/java/ch/qos/logback/core/spi/AppenderAttachable.java index ad52a56755ae07c52521552ed9f5469dc4a2b693..ade2489a6ea883343bfadfa5a5c95f66415365c0 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/AppenderAttachable.java +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/AppenderAttachable.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -45,7 +45,7 @@ public interface AppenderAttachable { boolean isAttached(Appender appender); /** - * Detach and stop all previously added appenders. + * Detach and processPriorToRemoval all previously added appenders. */ void detachAndStopAllAppenders(); diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/AppenderAttachableImpl.java b/logback-core/src/main/java/ch/qos/logback/core/spi/AppenderAttachableImpl.java index fb542500b440a1fb0df62e0e97cc5d979f2f4b94..c08f19fc06d5eda5813b4fd22f5fd2659532e9da 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/AppenderAttachableImpl.java +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/AppenderAttachableImpl.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -97,7 +97,7 @@ public class AppenderAttachableImpl implements AppenderAttachable { } /** - * Remove and stop all previously attached appenders. + * Remove and processPriorToRemoval all previously attached appenders. */ public void detachAndStopAllAppenders() { for (Appender a : appenderList) { diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/ComponentTracker.java b/logback-core/src/main/java/ch/qos/logback/core/spi/ComponentTracker.java new file mode 100755 index 0000000000000000000000000000000000000000..72d666bec8cd0d2d1f497f7dac4f2a24a070a2ff --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/ComponentTracker.java @@ -0,0 +1,110 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package ch.qos.logback.core.spi; + + +import ch.qos.logback.core.CoreConstants; + +import java.util.Collection; +import java.util.Set; + +/** + * Interface for tracking various components by key. Components which have not + * been accessed for more than a user-specified duration are deemed stale and + * removed. Components can also be explicitly marked as having reached their + * {@link #endOfLife(String)} in which case they will linger for a few seconds + * and then be removed. + * + * @author Tommy Becker + * @author Ceki Gulcu + * @author David Roussel + * + * @since 1.0.12 + */ +public interface ComponentTracker { + + /** + * The default timeout duration is 30 minutes + */ + public final int DEFAULT_TIMEOUT = 30 * 60 * CoreConstants.MILLIS_IN_ONE_SECOND; // 30 minutes + + /** + * By default an unlimited number of elements can be tracked. + */ + int DEFAULT_MAX_COMPONENTS = Integer.MAX_VALUE; + + /** + * Returns the number of components tracked. + * @return number of components + */ + int getComponentCount(); + + + /** + * Find the component identified by 'key', without updating the timestamp. Returns null if no + * corresponding component could be found. + * + * @param key + * @return corresponding component, may be null + */ + C find(String key); + + /** + * Get the component identified by 'key', updating its timestamp in the + * process. If the corresponding component could not be found, it is created. + * + * @param key + * @param timestamp + * @return + */ + C getOrCreate(String key, long timestamp); + + + /** + * Remove components which are deemed stale. Components which have not + * been accessed for more than a user-specified duration are deemed stale. + * + *

If the number of components exceeds, {@link #getComponentCount()}, + * components in excess will be removed.

+ * + *

Depending on the component type, components will be cleared or stopped + * (as appropriate) right before removal.

+ * + * @param now current time in milliseconds + */ + void removeStaleComponents(long now); + + + /** + * Mark component identified by 'key' as having reached its end-of-life. End-of-lifed + * components will linger for a few more seconds before being removed. + * + * @param key + */ + void endOfLife(String key); + + /** + * Returns the collection of all components tracked by this instance. + * @return collection of components + */ + Collection allComponents(); + + + /** + * Set of all keys in this tracker in no particular order. + * + * @return + */ + Set allKeys(); +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAware.java b/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAware.java index bf6c4d7873ab3a146892070e0e97ece1fd1cf631..7a058672c86d37d3cc78b720ee98d5cff0751ee3 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAware.java +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAware.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAwareBase.java b/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAwareBase.java index 1e839a550560952ad8c553ba0d2f1a12ede23b18..7800272346fbceadca7e75862893aec3bb60c13a 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAwareBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAwareBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -34,7 +34,7 @@ public class ContextAwareBase implements ContextAware { public ContextAwareBase() { declaredOrigin = this; } - public ContextAwareBase(Object declaredOrigin) { + public ContextAwareBase(ContextAware declaredOrigin) { this.declaredOrigin = declaredOrigin; } diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAwareImpl.java b/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAwareImpl.java index 11a731b9147b11f36672596f0b1fe6ecb4999f0f..750edf79fb4c1a14b6a5a3fa54e1da7a1540f610 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAwareImpl.java +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/ContextAwareImpl.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -33,8 +33,10 @@ public class ContextAwareImpl implements ContextAware { protected Context context; final Object origin; - public ContextAwareImpl(Object origin) { + public ContextAwareImpl(Context context, Object origin) { + this.context = context; this.origin = origin; + } protected Object getOrigin() { diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTracker.java b/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTracker.java old mode 100644 new mode 100755 index 30ffa5c0d65952ad4f199dccfffd7901bbadfdf2..34f04af7e908bf5f5fd97332c6d7bed4faa02175 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTracker.java +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTracker.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,62 +13,59 @@ */ package ch.qos.logback.core.spi; -import ch.qos.logback.core.CoreConstants; import ch.qos.logback.core.helpers.CyclicBuffer; +import java.util.*; + /** - * An interface for tracking cyclic buffers by key. + * CyclicBufferTracker tracks {@link CyclicBuffer} instances. * * @author Ceki Gücü */ -public interface CyclicBufferTracker { - - int DEFAULT_BUFFER_SIZE = 256; - int DEFAULT_NUMBER_OF_BUFFERS = 64; - - int THRESHOLD = 30 * 60 * CoreConstants.MILLIS_IN_ONE_SECOND; // 30 minutes - - int getBufferSize(); - - void setBufferSize(int size); - int getMaxNumberOfBuffers(); - - /** - * Set the maximum number of tracked buffers. After reaching the maximum number of - * buffers, the creation of a new buffer implies the removal of the least recently - * used buffer. - * - * @param maxNumBuffers - */ - void setMaxNumberOfBuffers(int maxNumBuffers); - - - /** - * Get the cyclic buffer identified by 'key', updating its timestamp in the process. - * If there is no such buffer, create it. If the current number of buffers is - * above or equal to 'maxNumBuffers' then the least recently accessed buffer is removed. - * - * @param key - * @param timestamp - * @return - */ - CyclicBuffer getOrCreate(String key, long timestamp); - - /** - * Remove a cyclic buffer identified by its key. - */ - void removeBuffer(String key); - - /** - * Clear (and detach) buffers which are stale. - * - * @param now - */ - void clearStaleBuffers(long now); - - /** - * The size of the internal map/list/collection holding the cyclic buffers. - * @return size of internal collection - */ - int size(); +public class CyclicBufferTracker extends AbstractComponentTracker> { + + static final int DEFAULT_NUMBER_OF_BUFFERS = 64; + + static final int DEFAULT_BUFFER_SIZE = 256; + int bufferSize = DEFAULT_BUFFER_SIZE; + + + public CyclicBufferTracker() { + super(); + setMaxComponents(DEFAULT_NUMBER_OF_BUFFERS); + } + + public int getBufferSize() { + return bufferSize; + } + + public void setBufferSize(int bufferSize) { + this.bufferSize = bufferSize; + } + + @Override + protected void processPriorToRemoval(CyclicBuffer component) { + component.clear(); + } + + @Override + protected CyclicBuffer buildComponent(String key) { + return new CyclicBuffer(bufferSize); + } + + @Override + protected boolean isComponentStale(CyclicBuffer eCyclicBuffer) { + return false; + } + + // for testing purposes + List liveKeysAsOrderedList() { + return new ArrayList(liveMap.keySet()); + } + + List lingererKeysAsOrderedList() { + return new ArrayList(lingerersMap.keySet()); + + } + } diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTrackerImpl.java b/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTrackerImpl.java deleted file mode 100644 index cd4f85e71a15d9c017d7ca88f4e6c8639e35d91e..0000000000000000000000000000000000000000 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTrackerImpl.java +++ /dev/null @@ -1,230 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.core.spi; - -import ch.qos.logback.core.CoreConstants; -import ch.qos.logback.core.helpers.CyclicBuffer; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -/** - * @author Ceki Gücü - */ -public class CyclicBufferTrackerImpl implements CyclicBufferTracker { - - int bufferSize = DEFAULT_BUFFER_SIZE; - int maxNumBuffers = DEFAULT_NUMBER_OF_BUFFERS; - int bufferCount = 0; - - // 5 minutes - static final int DELAY_BETWEEN_CLEARING_STALE_BUFFERS = 300 * CoreConstants.MILLIS_IN_ONE_SECOND; - - - boolean isStarted = false; - - private Map map = new HashMap(); - - private Entry head; // least recently used entries are towards the head - private Entry tail; // most recently used entries are towards the tail - long lastCheck = 0; - - - public CyclicBufferTrackerImpl() { - head = new Entry(null, null, 0); - tail = head; - } - - public int getBufferSize() { - return bufferSize; - } - - public void setBufferSize(int bufferSize) { - this.bufferSize = bufferSize; - } - - public int getMaxNumberOfBuffers() { - return maxNumBuffers; - } - - public void setMaxNumberOfBuffers(int maxNumBuffers) { - this.maxNumBuffers = maxNumBuffers; - } - - public CyclicBuffer getOrCreate(String key, long timestamp) { - Entry existing = map.get(key); - if (existing == null) { - return processNewEntry(key, timestamp); - } else { - existing.setTimestamp(timestamp); - moveToTail(existing); - return existing.value; - } - } - - public void removeBuffer(String key) { - Entry existing = map.get(key); - if (existing != null) { - bufferCount--; - map.remove(key); - unlink(existing); - CyclicBuffer cb = existing.value; - if(cb != null) { - cb.clear(); - } - } - } - - private CyclicBuffer processNewEntry(String key, long timestamp) { - CyclicBuffer cb = new CyclicBuffer(bufferSize); - Entry entry = new Entry(key, cb, timestamp); - map.put(key, entry); - bufferCount++; - linkBeforeTail(entry); - if (bufferCount >= maxNumBuffers) { - removeHead(); - } - return cb; - } - - private void removeHead() { - CyclicBuffer cb = head.value; - if (cb != null) { - cb.clear(); - } - map.remove(head.key); - bufferCount--; - head = head.next; - head.prev = null; - } - - private void moveToTail(Entry e) { - unlink(e); - linkBeforeTail(e); - } - - private void unlink(Entry e) { - if (e.prev != null) { - e.prev.next = e.next; - } - if (e.next != null) { - e.next.prev = e.prev; - } - if (head == e) { - head = e.next; - } - } - - - public synchronized void clearStaleBuffers(long now) { - if (lastCheck + DELAY_BETWEEN_CLEARING_STALE_BUFFERS > now) { - return; - } - lastCheck = now; - - while (head.value != null && isEntryStale(head, now)) { - removeHead(); - } - } - - public int size() { - return map.size(); - } - - private boolean isEntryStale(Entry entry, long now) { - return ((entry.timestamp + THRESHOLD) < now); - } - - List keyList() { - List result = new LinkedList(); - Entry e = head; - while (e != tail) { - result.add(e.key); - e = e.next; - } - return result; - } - - private void linkBeforeTail(Entry e) { - if (head == tail) { - head = e; - } - Entry preTail = tail.prev; - if (preTail != null) { - preTail.next = e; - } - e.prev = preTail; - e.next = tail; - tail.prev = e; - } - - // ================================================================ - - private class Entry { - Entry next; - Entry prev; - - String key; - CyclicBuffer value; - long timestamp; - - Entry(String k, CyclicBuffer v, long timestamp) { - this.key = k; - this.value = v; - this.timestamp = timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((key == null) ? 0 : key.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - @SuppressWarnings("unchecked") - final Entry other = (Entry) obj; - if (key == null) { - if (other.key != null) - return false; - } else if (!key.equals(other.key)) - return false; - if (value == null) { - if (other.value != null) - return false; - } else if (!value.equals(other.value)) - return false; - return true; - } - - @Override - public String toString() { - return "(" + key + ", " + value + ")"; - } - } -} diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/DeferredProcessingAware.java b/logback-core/src/main/java/ch/qos/logback/core/spi/DeferredProcessingAware.java index 6d6e7dece1466f2caf2667d3837f1417c9776a0c..6672454b4d9ce4ccc2e1e4515aea3f2828bca499 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/DeferredProcessingAware.java +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/DeferredProcessingAware.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachable.java b/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachable.java index 09d1aad7a69c487f5c0d38601b899d0e871ac0da..ba1bb1f777ba1fc294d98180304e2ad482dfb799 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachable.java +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachable.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachableImpl.java b/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachableImpl.java index a98c06d7f5df08b2943be87992bd99ddf2ba94aa..e3133206359dfe4ea35c4d43df107fc950640bd9 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachableImpl.java +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachableImpl.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/FilterReply.java b/logback-core/src/main/java/ch/qos/logback/core/spi/FilterReply.java index 380d2172d1e1611a45b079e7027ca3f956ab1906..feb4b01d34f4062e9509a52702ea3973eabfbbc6 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/FilterReply.java +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/FilterReply.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/LifeCycle.java b/logback-core/src/main/java/ch/qos/logback/core/spi/LifeCycle.java index 9a33377486f410e87e43f623aed84d0c948bffae..c5178a07551d73206f714f6f1156aba955cd7d11 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/LifeCycle.java +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/LifeCycle.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/LogbackLock.java b/logback-core/src/main/java/ch/qos/logback/core/spi/LogbackLock.java index dff4d969287fee20fa20a85f97e9c557f8302d95..03137f40aaddac9bfc054b17cc5bee6dae0176f9 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/LogbackLock.java +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/LogbackLock.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/PreSerializationTransformer.java b/logback-core/src/main/java/ch/qos/logback/core/spi/PreSerializationTransformer.java index b89dde24b652b36352841f0ed7a3bda26993b7a9..bc00da1481ebe39433e1bf8484688ac78f0b97ba 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/PreSerializationTransformer.java +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/PreSerializationTransformer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/PropertyContainer.java b/logback-core/src/main/java/ch/qos/logback/core/spi/PropertyContainer.java index f6829eb328dd586162574988fa9f68c0dae3c500..7907962e05c3ea94082912ab01183f22f496ecf6 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/PropertyContainer.java +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/PropertyContainer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,7 +13,11 @@ */ package ch.qos.logback.core.spi; +import java.util.Map; + public interface PropertyContainer { String getProperty(String key); + + Map getCopyOfPropertyMap(); } diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/PropertyDefiner.java b/logback-core/src/main/java/ch/qos/logback/core/spi/PropertyDefiner.java index a715010c4514d4406ba8583c81e4c43793c55645..24adf124cea57df4a3414ed29eb07c852d84e3c6 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/PropertyDefiner.java +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/PropertyDefiner.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/ScanException.java b/logback-core/src/main/java/ch/qos/logback/core/spi/ScanException.java index b0e75d761efeaed802694a8787f89913b2274195..0093b5e2db51131f26f764093d41282523642f1e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/spi/ScanException.java +++ b/logback-core/src/main/java/ch/qos/logback/core/spi/ScanException.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/ErrorStatus.java b/logback-core/src/main/java/ch/qos/logback/core/status/ErrorStatus.java index e521ca1e7af3ae4abb5eb6062ce6edfd2b1d1c07..4b5a8aea1c1aa47e25dd788c6fc9d31c96e51362 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/status/ErrorStatus.java +++ b/logback-core/src/main/java/ch/qos/logback/core/status/ErrorStatus.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/InfoStatus.java b/logback-core/src/main/java/ch/qos/logback/core/status/InfoStatus.java index f0dd6c51ad000313cfeae8b72dc4fb10bde710fc..9869310ac10d9f21c6cbed3f51c5da31df4c56fb 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/status/InfoStatus.java +++ b/logback-core/src/main/java/ch/qos/logback/core/status/InfoStatus.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/NopStatusListener.java b/logback-core/src/main/java/ch/qos/logback/core/status/NopStatusListener.java index 58b001c7ef7327093906654fee61677f08ca80be..d49f8745a36274db7ddd0870ffe92c5b72772b31 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/status/NopStatusListener.java +++ b/logback-core/src/main/java/ch/qos/logback/core/status/NopStatusListener.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.status; /** diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/OnConsoleStatusListener.java b/logback-core/src/main/java/ch/qos/logback/core/status/OnConsoleStatusListener.java index c90e0cfe1eba6a482e51fe7f4b0b167cfa2bfb31..31b9df2e90eba9e5b6a76b5cbcaaddfd97e8e112 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/status/OnConsoleStatusListener.java +++ b/logback-core/src/main/java/ch/qos/logback/core/status/OnConsoleStatusListener.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/OnErrorConsoleStatusListener.java b/logback-core/src/main/java/ch/qos/logback/core/status/OnErrorConsoleStatusListener.java index 19da18e8d40e677544cff29f7f0aaced15280db8..37840fe67a0e7cdf366fefa50cde41cbbcdfd5c4 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/status/OnErrorConsoleStatusListener.java +++ b/logback-core/src/main/java/ch/qos/logback/core/status/OnErrorConsoleStatusListener.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.status; import java.io.PrintStream; diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/OnPrintStreamStatusListenerBase.java b/logback-core/src/main/java/ch/qos/logback/core/status/OnPrintStreamStatusListenerBase.java index e1250e39444cc9ee3a5f6f4b81315794b225fe67..ea44d9529f03355f6ba9a51aafff2615fbaf63de 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/status/OnPrintStreamStatusListenerBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/status/OnPrintStreamStatusListenerBase.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.status; import ch.qos.logback.core.spi.ContextAwareBase; diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/Status.java b/logback-core/src/main/java/ch/qos/logback/core/status/Status.java index fc1a98bf8a8c9a51f1891a655b2a52ab8f1e609d..bb05e75879243ac79ac8e82b309f5dce144aabb8 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/status/Status.java +++ b/logback-core/src/main/java/ch/qos/logback/core/status/Status.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/StatusBase.java b/logback-core/src/main/java/ch/qos/logback/core/status/StatusBase.java index 1a2fb0e249bfad783d8352e974b7702de56ab824..683806ba889eca306a0abd0eb174139d5c892962 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/status/StatusBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/status/StatusBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/StatusListener.java b/logback-core/src/main/java/ch/qos/logback/core/status/StatusListener.java index 1ece7ecbb6ee98a7992f88ce5f68abea6d2a0bdb..05ac5b6c74531f8f26be9443744c7e0c42764a52 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/status/StatusListener.java +++ b/logback-core/src/main/java/ch/qos/logback/core/status/StatusListener.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/StatusListenerAsList.java b/logback-core/src/main/java/ch/qos/logback/core/status/StatusListenerAsList.java index 3e1745e1ced3eafee042625e4f1657c04f6eb802..2de6e340e47418202ad915143ed7e611db246f49 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/status/StatusListenerAsList.java +++ b/logback-core/src/main/java/ch/qos/logback/core/status/StatusListenerAsList.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/StatusManager.java b/logback-core/src/main/java/ch/qos/logback/core/status/StatusManager.java index 83fb28b15e7602eaca0aa98268e620fab53245d1..2394bcd9d4ab9785240abd09ebfa3ae2c1fecfda 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/status/StatusManager.java +++ b/logback-core/src/main/java/ch/qos/logback/core/status/StatusManager.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/StatusUtil.java b/logback-core/src/main/java/ch/qos/logback/core/status/StatusUtil.java index 6772504878909a0f2f041cc00d109a9b48ad26a7..ac216f140d8dc49cfbca7d28366d773a510f3332 100755 --- a/logback-core/src/main/java/ch/qos/logback/core/status/StatusUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/status/StatusUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/ViewStatusMessagesServletBase.java b/logback-core/src/main/java/ch/qos/logback/core/status/ViewStatusMessagesServletBase.java index c60a323948634f478680d02e637e31d3d7b8779e..ecc856a3be147c791fd92711472e75d385f07fd9 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/status/ViewStatusMessagesServletBase.java +++ b/logback-core/src/main/java/ch/qos/logback/core/status/ViewStatusMessagesServletBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/WarnStatus.java b/logback-core/src/main/java/ch/qos/logback/core/status/WarnStatus.java index c388330eac63667e5d890f47ba11d2bf2fad9c4e..796462e318087e076aa6be909475214e075ac291 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/status/WarnStatus.java +++ b/logback-core/src/main/java/ch/qos/logback/core/status/WarnStatus.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/subst/Node.java b/logback-core/src/main/java/ch/qos/logback/core/subst/Node.java index 34a6c6a307d520c3d0006ee65563eb3f80ed3571..89968cbc3876fd814016239d78b1f22872efe4bb 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/subst/Node.java +++ b/logback-core/src/main/java/ch/qos/logback/core/subst/Node.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.subst; public class Node { @@ -22,6 +35,18 @@ public class Node { this.defaultPart = defaultPart; } + void append(Node newNode) { + if(newNode == null) + return; + Node n = this; + while(true) { + if(n.next == null) { + n.next = newNode; + return; + } + n = n.next; + } + } @Override public String toString() { diff --git a/logback-core/src/main/java/ch/qos/logback/core/subst/NodeToStringTransformer.java b/logback-core/src/main/java/ch/qos/logback/core/subst/NodeToStringTransformer.java index 171f53051949cc77d076e7a04523ed4081b8edfd..f8172d3b2836a41b23e195f8ec7b8f200096c8af 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/subst/NodeToStringTransformer.java +++ b/logback-core/src/main/java/ch/qos/logback/core/subst/NodeToStringTransformer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/subst/Parser.java b/logback-core/src/main/java/ch/qos/logback/core/subst/Parser.java index 2ad03dc423f145a3bffd2bcfc6b4822b587e710f..aacd8ce7f8c19fc2a9387a204b435d12d0dab56b 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/subst/Parser.java +++ b/logback-core/src/main/java/ch/qos/logback/core/subst/Parser.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.subst; @@ -9,9 +22,17 @@ import java.util.List; // E = TE|T // = T(E|~) // E = TEopt where Eopt = E|~ -// T = LITERAL | { E } |'${' V '}' -// V = (E|E :- E) +// T = LITERAL | { C } |'${' V '}' +// C = E|E :- E // = E(':-'E|~) +// V = E|E :- E +// = E(':-'E|~) + +/** + * Parse a token list returning a node chain. + * + * @author Ceki Gulcu + */ public class Parser { final List tokenList; @@ -32,15 +53,14 @@ public class Parser { } Node eOpt = Eopt(); if (eOpt != null) { - appendNode(t, eOpt); + t.append(eOpt); } return t; } // Eopt = E|~ private Node Eopt() throws ScanException { - Token next = getCurentToken(); - // System.out.println("Current token is " + next); + Token next = peekAtCurentToken(); if (next == null) { return null; } else { @@ -50,30 +70,26 @@ public class Parser { // T = LITERAL | '${' V '}' private Node T() throws ScanException { - Token t = getCurentToken(); + Token t = peekAtCurentToken(); switch (t.type) { case LITERAL: advanceTokenPointer(); - return new Node(Node.Type.LITERAL, t.payload); + return makeNewLiteralNode(t.payload); case CURLY_LEFT: advanceTokenPointer(); - Node inner = E(); - Token right = getCurentToken(); + Node innerNode = C(); + Token right = peekAtCurentToken(); expectCurlyRight(right); advanceTokenPointer(); - Node curlyLeft = new Node(Node.Type.LITERAL, CoreConstants.LEFT_ACCOLADE); - curlyLeft.next = inner; - Node curlyRightNode = new Node(Node.Type.LITERAL, CoreConstants.RIGHT_ACCOLADE); - if(inner == null) - curlyLeft.next = curlyRightNode; - else - appendNode(inner, curlyRightNode); + Node curlyLeft = makeNewLiteralNode(CoreConstants.LEFT_ACCOLADE); + curlyLeft.append(innerNode); + curlyLeft.append(makeNewLiteralNode(CoreConstants.RIGHT_ACCOLADE)); return curlyLeft; case START: advanceTokenPointer(); Node v = V(); - Token w = getCurentToken(); + Token w = peekAtCurentToken(); expectCurlyRight(w); advanceTokenPointer(); return v; @@ -82,30 +98,39 @@ public class Parser { } } - private void appendNode(Node node, Node additionalNode) { - Node n = node; - while(true) { - if(n.next == null) { - n.next = additionalNode; - return; - } - n = n.next; - } + private Node makeNewLiteralNode(String s) { + return new Node(Node.Type.LITERAL, s); } - // V = E(':='E|~) private Node V() throws ScanException { Node e = E(); Node variable = new Node(Node.Type.VARIABLE, e); - Token t = getCurentToken(); - if (t != null && t.type == Token.Type.DEFAULT) { + Token t = peekAtCurentToken(); + if (isDefaultToken(t)) { advanceTokenPointer(); Node def = E(); variable.defaultPart = def; } return variable; + } + + // C = E(':='E|~) + private Node C() throws ScanException { + Node e0 = E(); + Token t = peekAtCurentToken(); + if (isDefaultToken(t)) { + advanceTokenPointer(); + Node literal = makeNewLiteralNode(CoreConstants.DEFAULT_VALUE_SEPARATOR); + e0.append(literal); + Node e1 = E(); + e0.append(e1); + } + return e0; + } + private boolean isDefaultToken(Token t) { + return t != null && t.type == Token.Type.DEFAULT; } void advanceTokenPointer() { @@ -126,9 +151,9 @@ public class Parser { } } - Token getCurentToken() { + Token peekAtCurentToken() { if (pointer < tokenList.size()) { - return (Token) tokenList.get(pointer); + return tokenList.get(pointer); } return null; } diff --git a/logback-core/src/main/java/ch/qos/logback/core/subst/Token.java b/logback-core/src/main/java/ch/qos/logback/core/subst/Token.java index faacff8f9390c56c8fb9686b886769c678d88dec..2dd565577a4dda2f2af191583a45ade8805b8541 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/subst/Token.java +++ b/logback-core/src/main/java/ch/qos/logback/core/subst/Token.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.subst; public class Token { diff --git a/logback-core/src/main/java/ch/qos/logback/core/subst/Tokenizer.java b/logback-core/src/main/java/ch/qos/logback/core/subst/Tokenizer.java index 228d78690212fd7a92e55b422ff9c31a31346fb4..eee60ed8fd364d7ec2c8a46ccc8a1ad7f3c4eae2 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/subst/Tokenizer.java +++ b/logback-core/src/main/java/ch/qos/logback/core/subst/Tokenizer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -34,7 +34,7 @@ public class Tokenizer { TokenizerState state = TokenizerState.LITERAL_STATE; int pointer = 0; - List tokenize() throws ScanException { + List tokenize() throws ScanException { List tokenList = new ArrayList(); StringBuilder buf = new StringBuilder(); diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/AggregationType.java b/logback-core/src/main/java/ch/qos/logback/core/util/AggregationType.java index 7f675642597e859ddfb040ed737b5f658cee8b09..6dd1b2c5bb92827b5db6b8b3104a0d3920f6d9ad 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/AggregationType.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/AggregationType.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/CachingDateFormatter.java b/logback-core/src/main/java/ch/qos/logback/core/util/CachingDateFormatter.java index 6f00ed449a67a59e83d05d1d30f6f4d9eb22a5ba..110c84bd09122d65966156a8f665f384010d3d42 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/CachingDateFormatter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/CachingDateFormatter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/CharSequenceState.java b/logback-core/src/main/java/ch/qos/logback/core/util/CharSequenceState.java index 38b206b9c15a21323ba0cd538ac71135434ce25b..396e7ac5cd23c8ddab965cff4571ee3928f5241e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/CharSequenceState.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/CharSequenceState.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/CharSequenceToRegexMapper.java b/logback-core/src/main/java/ch/qos/logback/core/util/CharSequenceToRegexMapper.java index 5a43bc363db8ffb0034aae605c80ba5a49532d1d..ecc57f1146adfc16335401dc2ed92b952b25507a 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/CharSequenceToRegexMapper.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/CharSequenceToRegexMapper.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/CloseUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/CloseUtil.java index acf1d96603deb9790d8cc0f773697e8a131c487e..f9da75d200dcecad4463f8e272711fa00adbf12e 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/CloseUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/CloseUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/ContentTypeUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/ContentTypeUtil.java index 03b95a0e5a78f8c589164edefead32db910972cb..bfee751463ba2a73e9ce379a05cf1a3b2841ade3 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/ContentTypeUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/ContentTypeUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/ContextUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/ContextUtil.java old mode 100644 new mode 100755 index 2f73542aa8d02b0fbed6ff8c9eaf5b93bb38aa3d..17472398d2d9cc6e614a8a168efdb31ee80b763a --- a/logback-core/src/main/java/ch/qos/logback/core/util/ContextUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/ContextUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,25 +13,57 @@ */ package ch.qos.logback.core.util; +import ch.qos.logback.core.Context; +import ch.qos.logback.core.CoreConstants; +import ch.qos.logback.core.spi.ContextAwareBase; + import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; import java.net.UnknownHostException; +import java.util.Enumeration; import java.util.Iterator; import java.util.List; import java.util.Properties; -import ch.qos.logback.core.Context; -import ch.qos.logback.core.CoreConstants; -import ch.qos.logback.core.spi.ContextAwareBase; - public class ContextUtil extends ContextAwareBase { public ContextUtil(Context context) { setContext(context); } - public static String getLocalHostName() throws UnknownHostException { - InetAddress localhost = InetAddress.getLocalHost(); - return localhost.getHostName(); + public static String getLocalHostName() throws UnknownHostException, + SocketException { + try { + InetAddress localhost = InetAddress.getLocalHost(); + return localhost.getHostName(); + } catch (UnknownHostException e) { + return getLocalAddressAsString(); + } + } + + private static String getLocalAddressAsString() throws UnknownHostException, + SocketException { + Enumeration interfaces = + NetworkInterface.getNetworkInterfaces(); + while (interfaces != null && interfaces.hasMoreElements()) { + Enumeration addresses = + interfaces.nextElement().getInetAddresses(); + while (addresses != null && addresses.hasMoreElements()) { + InetAddress address = addresses.nextElement(); + if (acceptableAddress(address)) { + return address.getHostAddress(); + } + } + } + throw new UnknownHostException(); + } + + private static boolean acceptableAddress(InetAddress address) { + return address != null + && !address.isLoopbackAddress() + && !address.isAnyLocalAddress() + && !address.isLinkLocalAddress(); } /** @@ -39,16 +71,18 @@ public class ContextUtil extends ContextAwareBase { */ public void addHostNameAsProperty() { try { - String localhostName = getLocalHostName(); + String localhostName = getLocalHostName(); context.putProperty(CoreConstants.HOSTNAME_KEY, localhostName); } catch (UnknownHostException e) { addError("Failed to get local hostname", e); + } catch (SocketException e) { + addError("Failed to get local hostname", e); } catch (SecurityException e) { addError("Failed to get local hostname", e); } } - public void addProperties(Properties props) { + public void addProperties(Properties props) { if (props == null) { return; } @@ -66,7 +100,7 @@ public class ContextUtil extends ContextAwareBase { } public void addFrameworkPackage(List frameworkPackages, String packageName) { - if(!frameworkPackages.contains(packageName)) { + if (!frameworkPackages.contains(packageName)) { frameworkPackages.add(packageName); } } diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/DatePatternToRegexUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/DatePatternToRegexUtil.java index ff001be54a445ef9716689f2ae8bad3a0cca7392..15f4c0dbf4002c28c17d548303996999bf517cb6 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/DatePatternToRegexUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/DatePatternToRegexUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/DelayStrategy.java b/logback-core/src/main/java/ch/qos/logback/core/util/DelayStrategy.java new file mode 100644 index 0000000000000000000000000000000000000000..eaad27f074db73357b9adfee1f3c98dd9942f652 --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/util/DelayStrategy.java @@ -0,0 +1,28 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package ch.qos.logback.core.util; + +/** + * A strategy for computing a delay. + * + * @author Carl Harris + * @since 1.1.0 + */ +public interface DelayStrategy { + /** + * The value computed by this {@code DelayStrategy} for the next delay. + * @return a delay value + */ + int nextDelay(); +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/Duration.java b/logback-core/src/main/java/ch/qos/logback/core/util/Duration.java index ba1730807d0cb5fdbf80737ed662c702115a80d1..9d00c3ffaa50ce1bd61a2c5888b6e28eb4fa8888 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/Duration.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/Duration.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -18,14 +18,13 @@ import java.util.regex.Pattern; /** * Duration instances represent a lapse of time. Internally, the duration is - * stored in milliseconds. - *

- * - * The {@link #valueOf} method can convert strings such as "3.5 minutes", "5 - * hours", into Duration instances. The recognized units of time are the - * "millisecond", "second", "minute" "hour" and "day". The unit name may be - * followed by an "s". Thus, "2 day" and "2 days" are equivalent. In the absence - * of a time unit specification, milliseconds are assumed. + * stored in milliseconds. This class follows the {@link #valueOf} convention meaning that it can + * convert an appropriately formatted string into a Duration object. + * + *

For example, string such as "3.5 minutes" or "5 hours" can be converted into Durations. + * The recognized units of time are the "millisecond", "second", "minute" "hour" and "day". + * The unit name may be followed by an "s". Thus, "2 day" and "2 days" are equivalent. In the + * absence of a time unit specification, milliseconds are assumed. * * * @author Ceki Gulcu diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/DynamicClassLoadingException.java b/logback-core/src/main/java/ch/qos/logback/core/util/DynamicClassLoadingException.java index 96f8ceefc99e564da3f273c3886db1707b9efb84..134fe9092e3ca8aee02007b98b48865e0b6af312 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/DynamicClassLoadingException.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/DynamicClassLoadingException.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/EnvUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/EnvUtil.java index d07cd9ade87f399fa39c8da08a09055982b3035f..4ff74ab8b0c35c560becb1ba320fedcae55ade74 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/EnvUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/EnvUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/ExecutorServiceUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/ExecutorServiceUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..c7a9d3e4c5d1ec4b590d6ad587cf7425ae98c52e --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/util/ExecutorServiceUtil.java @@ -0,0 +1,51 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ + +package ch.qos.logback.core.util; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import ch.qos.logback.core.CoreConstants; + +/** + * Static utility methods for manipulating an {@link ExecutorService}. + * + * @author Carl Harris + */ +public class ExecutorServiceUtil { + + /** + * Creates an executor service suitable for use by logback components. + * @return executor service + */ + static public ExecutorService newExecutorService() { + return new ThreadPoolExecutor(CoreConstants.CORE_POOL_SIZE, + CoreConstants.MAX_POOL_SIZE, + 0L, TimeUnit.MILLISECONDS, + new SynchronousQueue()); + } + + /** + * Shuts down an executor service. + *

+ * @param executorService the executor service to shut down + */ + static public void shutdown(ExecutorService executorService) { + executorService.shutdownNow(); + } + +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/FileSize.java b/logback-core/src/main/java/ch/qos/logback/core/util/FileSize.java index 544882ada13c6f2fe42bcc2b0b38905d5c9c1061..15820d236a436db84468179bff3437643a93847a 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/FileSize.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/FileSize.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java index fcbc8a19ebdd3b5443180c4d8aa016ccc580a8c5..c7c5df863928df5cdd3b51ae4814b8ade801be53 100755 --- a/logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/FixedDelay.java b/logback-core/src/main/java/ch/qos/logback/core/util/FixedDelay.java new file mode 100644 index 0000000000000000000000000000000000000000..d94674ada44b2f9f373823cf0e3f3594672ece54 --- /dev/null +++ b/logback-core/src/main/java/ch/qos/logback/core/util/FixedDelay.java @@ -0,0 +1,59 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package ch.qos.logback.core.util; + +/** + * A default {@link DelayStrategy} that implements a simple fixed delay. + * + * @author Carl Harris + * @since 1.1.0 + */ +public class FixedDelay implements DelayStrategy { + + private final int subsequentDelay; + private int nextDelay; + + /** + * Initialize a new {@code FixedDelay} with a given {@code initialDelay} and + * {@code subsequentDelay}. + * + * @param initialDelay value for the initial delay + * @param subsequentDelay value for all other delays + */ + public FixedDelay(int initialDelay, int subsequentDelay) { + String s = new String(); + this.nextDelay = initialDelay; + this.subsequentDelay = subsequentDelay; + } + + /** + * Initialize a new {@code FixedDelay} with fixed delay value given by {@code delay} + * parameter. + * + * @param delay value for all delays + */ + public FixedDelay(int delay) { + this(delay, delay); + } + + /** + * {@inheritDoc} + */ + public int nextDelay() { + int delay = nextDelay; + nextDelay = subsequentDelay; + return delay; + } + +} diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/IncompatibleClassException.java b/logback-core/src/main/java/ch/qos/logback/core/util/IncompatibleClassException.java index 4b2efd74122d60b53169e0ddf6b23d354b560e55..17048b458763518ebfb2d210a43029181eed8e57 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/IncompatibleClassException.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/IncompatibleClassException.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/InvocationGate.java b/logback-core/src/main/java/ch/qos/logback/core/util/InvocationGate.java index 8e00df5eabb438bce66d64fe4f57a5d3ec31997e..2bc4d565419b1c2ad883da741bb80508fac45233 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/InvocationGate.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/InvocationGate.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.util; /** diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/Loader.java b/logback-core/src/main/java/ch/qos/logback/core/util/Loader.java index 40deb74284e43aad0c16de923bc5538e7bc9aebc..0d4cb791b400792544c7fec8b5f93bd30ebb3e14 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/Loader.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/Loader.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/LocationUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/LocationUtil.java index 4e984c1c19de957f4901c83c8aca954e5afc72a7..e45a5776c40f2a9217f1ca11d6d7e2297dacf042 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/LocationUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/LocationUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java b/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java index 13c2af86e704dc821f12ac84d2f194d423799e0b..db21042f3fb068799ca9cd20aecd3056dcd8ed40 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -222,9 +222,19 @@ public class OptionHelper { } } - @Deprecated + /** + * Return a String[] of size two. The first item containing the key part and the second item + * containing a default value specified by the user. The second item will be null if no default value + * is specified. + * + * @param key + * @return + */ static public String[] extractDefaultReplacement(String key) { String[] result = new String[2]; + if(key == null) + return result; + result[0] = key; int d = key.indexOf(DELIM_DEFAULT); if (d != -1) { diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/PropertySetterException.java b/logback-core/src/main/java/ch/qos/logback/core/util/PropertySetterException.java index 7d054ac234d1120c49aaaaab9c40e2359e0c3ae1..d4167587039f4e721dcde2bbe2d33845c7b21746 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/PropertySetterException.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/PropertySetterException.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/StatusPrinter.java b/logback-core/src/main/java/ch/qos/logback/core/util/StatusPrinter.java index 1c0cda7fc1a445dc7e46b5bae547a8a0457988b1..42a55523a65b86dc3a643a72176bdad83753a67b 100755 --- a/logback-core/src/main/java/ch/qos/logback/core/util/StatusPrinter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/StatusPrinter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/StringCollectionUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/StringCollectionUtil.java index 42eaeaac0df32d01ee4d018f9c75f12b77f71002..10599326f66bfc8adebb40a5cbe7e64ae4095e90 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/StringCollectionUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/StringCollectionUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/SystemInfo.java b/logback-core/src/main/java/ch/qos/logback/core/util/SystemInfo.java index 57e2780a620b30562794c7e8d99094b3abf2e51b..53bf552327b17c2be612f6987c0fcacbdf0d4cb1 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/SystemInfo.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/SystemInfo.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/TimeUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/TimeUtil.java index ae27933afdd8cc4976132b97108b259fb8f591e3..6388f3a846b1d64422a7810b82985128890496e0 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/TimeUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/TimeUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/input/joran/inclusion/topOptional.xml b/logback-core/src/test/input/joran/inclusion/topOptional.xml new file mode 100644 index 0000000000000000000000000000000000000000..3625575e203678b95ffe4080a31ffca19914d8a7 --- /dev/null +++ b/logback-core/src/test/input/joran/inclusion/topOptional.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/logback-core/src/test/java/ch/qos/logback/core/AllCoreTest.java b/logback-core/src/test/java/ch/qos/logback/core/AllCoreTest.java index 8dcf9d19c8d6bc85d9960af4f41ac2d770504b18..54660b4f40c0cad6db5122ecb7bf299b4696f7e9 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/AllCoreTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/AllCoreTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -29,6 +29,7 @@ import org.junit.runners.Suite.SuiteClasses; ch.qos.logback.core.appender.PackageTest.class, ch.qos.logback.core.spi.PackageTest.class, ch.qos.logback.core.rolling.PackageTest.class, + ch.qos.logback.core.net.PackageTest.class, ch.qos.logback.core.sift.PackageTest.class, ch.qos.logback.core.encoder.PackageTest.class, ch.qos.logback.core.recovery.PackageTest.class}) diff --git a/logback-core/src/test/java/ch/qos/logback/core/AsyncAppenderBaseTest.java b/logback-core/src/test/java/ch/qos/logback/core/AsyncAppenderBaseTest.java index f7ba2435087ac66d6e8af63ebdfe754d8a955f28..ddf8cfd4cad5f5cbe037da74c992da0f749acd37 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/AsyncAppenderBaseTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/AsyncAppenderBaseTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/BasicStatusManagerTest.java b/logback-core/src/test/java/ch/qos/logback/core/BasicStatusManagerTest.java index fb86c6c63eea4221336fcd39d1b8b4c3315a1d1f..9823372b716d7385d9e62d354eb59fd85d49ec38 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/BasicStatusManagerTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/BasicStatusManagerTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/ContextBaseTest.java b/logback-core/src/test/java/ch/qos/logback/core/ContextBaseTest.java index e55a48a0714ebb24068612b557149ca62c489f97..b2491ade5b7a257294f606df8d0c2bc31a03a595 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/ContextBaseTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/ContextBaseTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -15,13 +15,21 @@ package ch.qos.logback.core; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import org.junit.Test; +import ch.qos.logback.core.spi.LifeCycle; + public class ContextBaseTest { - ContextBase context = new ContextBase(); + private InstrumentedLifeCycleManager lifeCycleManager = + new InstrumentedLifeCycleManager(); + + private InstrumentedContextBase context = + new InstrumentedContextBase(lifeCycleManager); @Test public void renameDefault() { @@ -53,9 +61,13 @@ public class ContextBaseTest { context.putObject("keyA", "valA"); assertEquals("valA", context.getProperty("keyA")); assertEquals("valA", context.getObject("keyA")); + MockLifeCycleComponent component = new MockLifeCycleComponent(); + context.register(component); + assertSame(component, lifeCycleManager.getLastComponent()); context.reset(); assertNull(context.getProperty("keyA")); assertNull(context.getObject("keyA")); + assertTrue(lifeCycleManager.isReset()); } @Test @@ -68,4 +80,47 @@ public class ContextBaseTest { // not go through CoreConstants assertEquals(HELLO, context.getProperty("CONTEXT_NAME")); } + + private static class InstrumentedContextBase extends ContextBase { + + private final LifeCycleManager lifeCycleManager; + + public InstrumentedContextBase(LifeCycleManager lifeCycleManager) { + this.lifeCycleManager = lifeCycleManager; + } + + @Override + protected LifeCycleManager getLifeCycleManager() { + return lifeCycleManager; + } + + } + + private static class InstrumentedLifeCycleManager extends LifeCycleManager { + + private LifeCycle lastComponent; + private boolean reset; + + @Override + public void register(LifeCycle component) { + lastComponent = component; + super.register(component); + } + + @Override + public void reset() { + reset = true; + super.reset(); + } + + public LifeCycle getLastComponent() { + return lastComponent; + } + + public boolean isReset() { + return reset; + } + + } + } diff --git a/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java b/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java index ae100f4ec73b5380833ac6793a11a0ad08e03cdf..b5654b86997e1e61252ed4c1e8f851df463957af 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -85,10 +85,12 @@ public class FileAppenderResilienceTest { t.join(); double bestCaseSuccessRatio = 1/delayCoefficient; - double lossinessFactor = 0.8; + // expect to loose at most 35% of the events + double lossinessFactor = 0.35; + double resilianceFactor = (1-lossinessFactor); ResilienceUtil - .verify(logfileStr, "^hello (\\d{1,5})$", runner.getCounter(), bestCaseSuccessRatio * lossinessFactor); + .verify(logfileStr, "^hello (\\d{1,5})$", runner.getCounter(), bestCaseSuccessRatio * resilianceFactor); } private void closeLogFileOnPurpose() throws IOException { diff --git a/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilience_AS_ROOT_Test.java b/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilience_AS_ROOT_Test.java index 42e904911f623734d577aa769f84fc48cc93a6e8..b5afe53ea41e5bba63eb735bca10dbe45e526d9a 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilience_AS_ROOT_Test.java +++ b/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilience_AS_ROOT_Test.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/LifeCycleManagerTest.java b/logback-core/src/test/java/ch/qos/logback/core/LifeCycleManagerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d1247ad7fb8f8fcbdb149899dad6395739fca393 --- /dev/null +++ b/logback-core/src/test/java/ch/qos/logback/core/LifeCycleManagerTest.java @@ -0,0 +1,40 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ + +package ch.qos.logback.core; + +import static org.junit.Assert.assertFalse; + +import org.junit.Test; + + +/** + * Unit tests for {@link LifeCycleManager}. + * + * @author Carl Harris + */ +public class LifeCycleManagerTest { + + private LifeCycleManager manager = new LifeCycleManager(); + + @Test + public void testRegisterAndReset() { + MockLifeCycleComponent component = new MockLifeCycleComponent(); + manager.register(component); + component.start(); + manager.reset(); + assertFalse(component.isStarted()); + } + +} diff --git a/logback-core/src/test/java/ch/qos/logback/core/MockLifeCycleComponent.java b/logback-core/src/test/java/ch/qos/logback/core/MockLifeCycleComponent.java new file mode 100644 index 0000000000000000000000000000000000000000..3b7241ebefa74e3df77f4412997de8a93002f7f1 --- /dev/null +++ b/logback-core/src/test/java/ch/qos/logback/core/MockLifeCycleComponent.java @@ -0,0 +1,21 @@ +package ch.qos.logback.core; + +import ch.qos.logback.core.spi.LifeCycle; + +public class MockLifeCycleComponent implements LifeCycle { + + private boolean started; + + public void start() { + started = true; + } + + public void stop() { + started = false; + } + + public boolean isStarted() { + return started; + } + +} \ No newline at end of file diff --git a/logback-core/src/test/java/ch/qos/logback/core/OutputStreamAppenderTest.java b/logback-core/src/test/java/ch/qos/logback/core/OutputStreamAppenderTest.java index c0caf51a11ca7f5be592bc19c4df9aed2443e5ec..e187b782d5ca43def9e24d38ecff4ba487964c4e 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/OutputStreamAppenderTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/OutputStreamAppenderTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/PackageTest.java index 66a28be98c9cce6f5ea748d5704cb89a7a18ee3f..4a365c9e610fde516bf76dfe3b439a0963d56162 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/appender/ConsoleAppenderTest.java b/logback-core/src/test/java/ch/qos/logback/core/appender/ConsoleAppenderTest.java index be02cafa7ece574956950bf7235976df91fed989..902adbae7ff0f81f3bbd4ac23ebb4e52cc60a396 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/appender/ConsoleAppenderTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/appender/ConsoleAppenderTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,16 +13,6 @@ */ package ch.qos.logback.core.appender; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; - -import java.io.PrintStream; -import java.io.UnsupportedEncodingException; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - import ch.qos.logback.core.Appender; import ch.qos.logback.core.ConsoleAppender; import ch.qos.logback.core.CoreConstants; @@ -32,7 +22,19 @@ import ch.qos.logback.core.encoder.NopEncoder; import ch.qos.logback.core.layout.DummyLayout; import ch.qos.logback.core.status.Status; import ch.qos.logback.core.status.StatusChecker; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.io.PrintStream; +import java.io.UnsupportedEncodingException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +/** + * Redirecting System.out is quite messy. Disable this test in Maven bu not in Package.class + */ public class ConsoleAppenderTest extends AbstractAppenderTest { XTeeOutputStream tee; @@ -139,7 +141,8 @@ public class ConsoleAppenderTest extends AbstractAppenderTest { public void wrongTarget() { ConsoleAppender ca = (ConsoleAppender) getAppender(); EchoEncoder encoder = new EchoEncoder(); - System.out.println("xxx"); + encoder.setContext(context); + ca.setContext(context); ca.setTarget("foo"); ca.setEncoder(encoder); ca.start(); @@ -147,8 +150,9 @@ public class ConsoleAppenderTest extends AbstractAppenderTest { StatusChecker checker = new StatusChecker(context); //21:28:01,246 + WARN in ch.qos.logback.core.ConsoleAppender[null] - [foo] should be one of [SystemOut, SystemErr] //21:28:01,246 |-WARN in ch.qos.logback.core.ConsoleAppender[null] - Using previously set target, System.out by default. +// StatusPrinter.print(context); - checker.assertContainsMatch(Status.ERROR, "\\[foo\\] should be one of \\[SystemOut, SystemErr\\]"); + checker.assertContainsMatch(Status.WARN, "\\[foo\\] should be one of \\[SystemOut, SystemErr\\]"); } diff --git a/logback-core/src/test/java/ch/qos/logback/core/appender/DummyAppenderTest.java b/logback-core/src/test/java/ch/qos/logback/core/appender/DummyAppenderTest.java index 67540a440fce64d8e2ec9ad1443cdf1bc4783137..85692a55c8388dff7334cdfddc47542077e2883b 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/appender/DummyAppenderTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/appender/DummyAppenderTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/appender/DummyWriterAppender.java b/logback-core/src/test/java/ch/qos/logback/core/appender/DummyWriterAppender.java index 9b5f11d4d878075fa9ea657e8606577f8d4cd068..6a04c1920037b3df8cf0714cdd1a9dbef9bd301a 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/appender/DummyWriterAppender.java +++ b/logback-core/src/test/java/ch/qos/logback/core/appender/DummyWriterAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java b/logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java index 355213b54fca790a573e770db70ef7253aaa8983..8201e5bac5d70bc6987a1272b81a414c628107a9 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -53,7 +53,7 @@ public class FileAppenderTest extends AbstractAppenderTest { @Test public void smoke() { - String filename = CoreTestConstants.OUTPUT_DIR_PREFIX + "temp.log"; + String filename = CoreTestConstants.OUTPUT_DIR_PREFIX + "/fat-smoke.log"; FileAppender appender = new FileAppender(); appender.setEncoder(new DummyEncoder()); @@ -72,8 +72,8 @@ public class FileAppenderTest extends AbstractAppenderTest { @Test public void testCreateParentFolders() { - String filename = CoreTestConstants.OUTPUT_DIR_PREFIX + "/fat" + diff - + "/testing.txt"; + String filename = CoreTestConstants.OUTPUT_DIR_PREFIX + "/fat-testCreateParentFolders-" + diff + + "/testCreateParentFolders.txt"; File file = new File(filename); FileAppender appender = new FileAppender(); appender.setEncoder(new DummyEncoder()); @@ -95,12 +95,12 @@ public class FileAppenderTest extends AbstractAppenderTest { @Test public void testPrudentModeLogicalImplications() { - String filename = CoreTestConstants.OUTPUT_DIR_PREFIX + diff + "testing.txt"; + String filename = CoreTestConstants.OUTPUT_DIR_PREFIX + diff + "fat-testPrudentModeLogicalImplications.txt"; File file = new File(filename); FileAppender appender = new FileAppender(); appender.setEncoder(new DummyEncoder()); appender.setFile(filename); - appender.setName("testPrudentMode"); + appender.setName("testPrudentModeLogicalImplications"); appender.setContext(context); appender.setAppend(false); diff --git a/logback-core/src/test/java/ch/qos/logback/core/appender/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/appender/PackageTest.java index c808ef704c5341663f03136f8d373e46877e5cb2..cc61e74bdbe670f8068c301c65dcce89cb63eafe 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/appender/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/appender/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -17,10 +17,10 @@ import org.junit.runner.RunWith; import org.junit.runners.Suite; - @RunWith(Suite.class) -@Suite.SuiteClasses( { DummyAppenderTest.class, ConsoleAppenderTest.class, - FileAppenderTest.class}) - +@Suite.SuiteClasses({DummyAppenderTest.class, + ConsoleAppenderTest.class, + FileAppenderTest.class}) + public class PackageTest { } diff --git a/logback-core/src/test/java/ch/qos/logback/core/appender/XTeeOutputStream.java b/logback-core/src/test/java/ch/qos/logback/core/appender/XTeeOutputStream.java index f2c933efee7f6be302e341933534ec9d8a7188d8..5552646aa24e86b7e34601dbd97da440d105cca1 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/appender/XTeeOutputStream.java +++ b/logback-core/src/test/java/ch/qos/logback/core/appender/XTeeOutputStream.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/boolex/MatcherTest.java b/logback-core/src/test/java/ch/qos/logback/core/boolex/MatcherTest.java index f82b53a0ddcbe60ad465831c319e6e9dbe1818c9..b68b3454b9b12c483c99d1970410f5862d916341 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/boolex/MatcherTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/boolex/MatcherTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/contention/AbstractMultiThreadedHarness.java b/logback-core/src/test/java/ch/qos/logback/core/contention/AbstractMultiThreadedHarness.java index aa4d4fd5ec4e19e8abfd550890ca7089f1f6cb5e..1373135ee11f033ee23a38e6df7c790d26217280 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/contention/AbstractMultiThreadedHarness.java +++ b/logback-core/src/test/java/ch/qos/logback/core/contention/AbstractMultiThreadedHarness.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.contention; abstract public class AbstractMultiThreadedHarness { diff --git a/logback-core/src/test/java/ch/qos/logback/core/contention/MultiThreadedHarness.java b/logback-core/src/test/java/ch/qos/logback/core/contention/MultiThreadedHarness.java index 8b9f744a0639e16efdd3fdfdfb727b8673db711c..0b004d667bd322765aeb7ff11b5f3f3453afedae 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/contention/MultiThreadedHarness.java +++ b/logback-core/src/test/java/ch/qos/logback/core/contention/MultiThreadedHarness.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -15,7 +15,7 @@ package ch.qos.logback.core.contention; /** - * Useful scaffolding/harness to start and stop multiple threads. + * Useful scaffolding/harness to start and processPriorToRemoval multiple threads. * * @author Joern Huxhorn * @author Ralph Goers diff --git a/logback-core/src/test/java/ch/qos/logback/core/contention/RunnableWithCounterAndDone.java b/logback-core/src/test/java/ch/qos/logback/core/contention/RunnableWithCounterAndDone.java index 485054ec8dd0023047a952c12c1a33ec6f448231..ab7f5d2ba17c53bd2dae95df4767544c1be9df32 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/contention/RunnableWithCounterAndDone.java +++ b/logback-core/src/test/java/ch/qos/logback/core/contention/RunnableWithCounterAndDone.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/contention/ThreadedThroughputCalculator.java b/logback-core/src/test/java/ch/qos/logback/core/contention/ThreadedThroughputCalculator.java index b4b8707143e497b063298c4e77cd81f3acbff3ce..31e65afe53e67ea10126786d979c23bff049cb2d 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/contention/ThreadedThroughputCalculator.java +++ b/logback-core/src/test/java/ch/qos/logback/core/contention/ThreadedThroughputCalculator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/contention/WaitOnExecutionMultiThreadedHarness.java b/logback-core/src/test/java/ch/qos/logback/core/contention/WaitOnExecutionMultiThreadedHarness.java index f61311af2b3e79e623f9fa0485532f950b7b85fc..aa5f167e8af76ff96987640b236debc9460d9aac 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/contention/WaitOnExecutionMultiThreadedHarness.java +++ b/logback-core/src/test/java/ch/qos/logback/core/contention/WaitOnExecutionMultiThreadedHarness.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.contention; import java.util.concurrent.ThreadPoolExecutor; diff --git a/logback-core/src/test/java/ch/qos/logback/core/encoder/ByteArrayUtilTest.java b/logback-core/src/test/java/ch/qos/logback/core/encoder/ByteArrayUtilTest.java index 356864b7aec7747607f083b3f06c462c96e4dfd3..38c9c332284cea75ece70280b1dd3f61c7ff5e73 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/encoder/ByteArrayUtilTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/encoder/ByteArrayUtilTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/encoder/DummyEncoder.java b/logback-core/src/test/java/ch/qos/logback/core/encoder/DummyEncoder.java index 7f91f3f63d9f41b4e38221090d552bd75ec8a0fe..0b8b8baac8e399ab9fb59bd9869ae614bd34e94b 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/encoder/DummyEncoder.java +++ b/logback-core/src/test/java/ch/qos/logback/core/encoder/DummyEncoder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/encoder/NopEncoder.java b/logback-core/src/test/java/ch/qos/logback/core/encoder/NopEncoder.java index 4d63d0c4d7e37af11954eda5c93d6b2f53d91930..bbb57f26eeaad7411ba45b63ded8f7c9b4204b4f 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/encoder/NopEncoder.java +++ b/logback-core/src/test/java/ch/qos/logback/core/encoder/NopEncoder.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/encoder/ObjectEncodeDecodeTest.java b/logback-core/src/test/java/ch/qos/logback/core/encoder/ObjectEncodeDecodeTest.java index c26ffb0d88e2dd434e7f6ac53bada173ba116d67..4f260b463a5373cf709d8ce490fccfc506c707ed 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/encoder/ObjectEncodeDecodeTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/encoder/ObjectEncodeDecodeTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/encoder/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/encoder/PackageTest.java index 9d5986d7dfd93e63d70d107384e5bd4cbff4187e..6529cfa15571861f49ade231a0aadaa65c891445 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/encoder/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/encoder/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/helpers/CyclicBufferTest.java b/logback-core/src/test/java/ch/qos/logback/core/helpers/CyclicBufferTest.java index e4fd7f41a6a458fc905b46f73de44c66d343c2ce..b48278344868f7c4196a0ae976e3a936b3b500a8 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/helpers/CyclicBufferTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/helpers/CyclicBufferTest.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.helpers; import org.junit.Test; diff --git a/logback-core/src/test/java/ch/qos/logback/core/helpers/FileFilterUtilTest.java b/logback-core/src/test/java/ch/qos/logback/core/helpers/FileFilterUtilTest.java index 143482fdaa0ede7b2e8693943401bb209f96e46f..cf70fa3488ec354fd3e9ae64acdebab50e957d1d 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/helpers/FileFilterUtilTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/helpers/FileFilterUtilTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/helpers/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/helpers/PackageTest.java index 053db9218544bf82b3a7a3d10165358169474fce..c4645642f4b50bf9f06896ed5db430ab715e07d4 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/helpers/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/helpers/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/helpers/ThrowableToStringArrayTest.java b/logback-core/src/test/java/ch/qos/logback/core/helpers/ThrowableToStringArrayTest.java index f41722e36100ee98a73fd9a7f77130fa967b0fa1..5b0908185e1cd6d25ec2a4e5ebe55ac65bd4c725 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/helpers/ThrowableToStringArrayTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/helpers/ThrowableToStringArrayTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/issue/LBCORE97.java b/logback-core/src/test/java/ch/qos/logback/core/issue/LBCORE97.java index c14dd7d4e9610105dbc51c4f960d0121944df0ed..489e099e03e9e06658797fa11fba82ec15061f6f 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/issue/LBCORE97.java +++ b/logback-core/src/test/java/ch/qos/logback/core/issue/LBCORE97.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/issue/LOGBACK_849/Basic.java b/logback-core/src/test/java/ch/qos/logback/core/issue/LOGBACK_849/Basic.java new file mode 100644 index 0000000000000000000000000000000000000000..2eee415d8491f16ed003813ec91dc9497b874b6e --- /dev/null +++ b/logback-core/src/test/java/ch/qos/logback/core/issue/LOGBACK_849/Basic.java @@ -0,0 +1,62 @@ +package ch.qos.logback.core.issue.LOGBACK_849; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.TimeUnit; + +import org.junit.Ignore; +import org.junit.Test; + +import ch.qos.logback.core.Context; +import ch.qos.logback.core.ContextBase; +import ch.qos.logback.core.util.ExecutorServiceUtil; + + +public class Basic { + + ExecutorService executor = ExecutorServiceUtil.newExecutorService(); + Context context = new ContextBase(); + + @Test(timeout = 100) + public void withNoSubmittedTasksShutdownNowShouldReturnImmediately() throws InterruptedException { + executor.shutdownNow(); + executor.awaitTermination(5000, TimeUnit.MILLISECONDS); + } + + @Ignore + @Test + public void withOneSlowTask() throws InterruptedException { + executor.execute(new InterruptIgnoring(1000)); + Thread.sleep(100); + ExecutorServiceUtil.shutdown(executor); + } + + // InterruptIgnoring =========================================== + static class InterruptIgnoring implements Runnable { + + int delay; + + InterruptIgnoring(int delay) { + this.delay = delay; + } + + public void run() { + long runUntil = System.currentTimeMillis() + delay; + + while (true) { + try { + long sleep = runUntil - System.currentTimeMillis(); + System.out.println("will sleep " + sleep); + if (sleep > 0) { + Thread.currentThread().sleep(delay); + } else { + return; + } + } catch (InterruptedException e) { + // ignore the exception + } + } + } + } + + +} diff --git a/logback-core/src/test/java/ch/qos/logback/core/issue/LockThroughput.java b/logback-core/src/test/java/ch/qos/logback/core/issue/LockThroughput.java index 7a5897bcf68b5262482a7335c60689aa28449e92..327b53f34ca187900b8e9136ea779528479ec522 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/issue/LockThroughput.java +++ b/logback-core/src/test/java/ch/qos/logback/core/issue/LockThroughput.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/issue/LockingInJava.java b/logback-core/src/test/java/ch/qos/logback/core/issue/LockingInJava.java index 1ae7e27f6dbabe5442ab0831091252098af29357..c341cb049e361c9f8189096bd727410c7b066044 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/issue/LockingInJava.java +++ b/logback-core/src/test/java/ch/qos/logback/core/issue/LockingInJava.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/issue/NoLockThroughput.java b/logback-core/src/test/java/ch/qos/logback/core/issue/NoLockThroughput.java index 217e2e514f0a6b21e94b724951154a2e49f5db03..aeb3d70bfca9e20ef8ab0e5356cfc56bce009d92 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/issue/NoLockThroughput.java +++ b/logback-core/src/test/java/ch/qos/logback/core/issue/NoLockThroughput.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/issue/NoLockingInJava.java b/logback-core/src/test/java/ch/qos/logback/core/issue/NoLockingInJava.java index 11483018dc77ec9384ec820ea49e1ca227bc0cce..51d2e90dd86d7c7b55c96e0a0ab21993f217758b 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/issue/NoLockingInJava.java +++ b/logback-core/src/test/java/ch/qos/logback/core/issue/NoLockingInJava.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/issue/SelectiveLockRunnable.java b/logback-core/src/test/java/ch/qos/logback/core/issue/SelectiveLockRunnable.java index 3f0022e8354e8f4bc1939eeaf201871a7a65ea11..b781a1c2e8156db5ca5bc046b631c6f2a96f6254 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/issue/SelectiveLockRunnable.java +++ b/logback-core/src/test/java/ch/qos/logback/core/issue/SelectiveLockRunnable.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/issue/lbcore258/FileLockSimulator.java b/logback-core/src/test/java/ch/qos/logback/core/issue/lbcore258/FileLockSimulator.java index 92e86884ef4c509c5c7b49ed3b11550d6a99ae1e..f21d74132d7b382b916393aa3313da2d95f153fb 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/issue/lbcore258/FileLockSimulator.java +++ b/logback-core/src/test/java/ch/qos/logback/core/issue/lbcore258/FileLockSimulator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java index 07f227f09493fb65eef1ff51429582bd0827e1ba..8802e6826ab93d960b7a9077ea8a80fefe12070b 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/SimpleConfigurator.java b/logback-core/src/test/java/ch/qos/logback/core/joran/SimpleConfigurator.java index 6f8455b6efb463c9ebae9428b7196cd8916574bd..81ab4f0f48f19bc3d9e48c9139862633da399f08 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/SimpleConfigurator.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/SimpleConfigurator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -15,19 +15,18 @@ package ch.qos.logback.core.joran; import java.util.HashMap; -import ch.qos.logback.core.joran.GenericConfigurator; import ch.qos.logback.core.joran.action.Action; import ch.qos.logback.core.joran.action.NestedComplexPropertyIA; import ch.qos.logback.core.joran.action.NestedBasicPropertyIA; import ch.qos.logback.core.joran.spi.Interpreter; -import ch.qos.logback.core.joran.spi.Pattern; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.joran.spi.RuleStore; public class SimpleConfigurator extends GenericConfigurator { - HashMap rulesMap; + HashMap rulesMap; - public SimpleConfigurator(HashMap rules) { + public SimpleConfigurator(HashMap rules) { this.rulesMap = rules; } @@ -48,9 +47,9 @@ public class SimpleConfigurator extends GenericConfigurator { @Override protected void addInstanceRules(RuleStore rs) { - for(Pattern pattern : rulesMap.keySet()) { - Action action = rulesMap.get(pattern); - rs.addRule(pattern, action); + for(ElementSelector elementSelector : rulesMap.keySet()) { + Action action = rulesMap.get(elementSelector); + rs.addRule(elementSelector, action); } } diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java index 4df15f276b25cb6222728e411e5a23a8a852b5e9..9ec812cf6c34a3944fac4d60ff8fa8b27bd6c581 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -23,6 +23,7 @@ import java.util.List; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import ch.qos.logback.core.joran.spi.ElementSelector; import org.junit.Test; import ch.qos.logback.core.Context; @@ -34,7 +35,6 @@ import ch.qos.logback.core.joran.action.ext.BadEndAction; import ch.qos.logback.core.joran.action.ext.HelloAction; import ch.qos.logback.core.joran.action.ext.TouchAction; import ch.qos.logback.core.joran.spi.ActionException; -import ch.qos.logback.core.joran.spi.Pattern; import ch.qos.logback.core.status.Status; import ch.qos.logback.core.status.StatusManager; import ch.qos.logback.core.util.CoreTestConstants; @@ -47,7 +47,7 @@ import ch.qos.logback.core.util.CoreTestConstants; */ public class SkippingInInterpreterTest { - HashMap rulesMap = new HashMap(); + HashMap rulesMap = new HashMap(); Context context = new ContextBase(); StatusManager sm = context.getStatusManager(); @@ -59,18 +59,18 @@ public class SkippingInInterpreterTest { void doTest(String filename, Integer expectedInt, Class exceptionClass) throws Exception { - rulesMap.put(new Pattern("test"), new NOPAction()); - rulesMap.put(new Pattern("test/badBegin"), new BadBeginAction()); - rulesMap.put(new Pattern("test/badBegin/touch"), new TouchAction()); - rulesMap.put(new Pattern("test/badEnd"), new BadEndAction()); - rulesMap.put(new Pattern("test/badEnd/touch"), new TouchAction()); - rulesMap.put(new Pattern("test/hello"), new HelloAction()); - - rulesMap.put(new Pattern("test/isolate"), new NOPAction()); - rulesMap.put(new Pattern("test/isolate/badEnd"), new BadEndAction()); - rulesMap.put(new Pattern("test/isolate/badEnd/touch"), new TouchAction()); - rulesMap.put(new Pattern("test/isolate/touch"), new TouchAction()); - rulesMap.put(new Pattern("test/hello"), new HelloAction()); + rulesMap.put(new ElementSelector("test"), new NOPAction()); + rulesMap.put(new ElementSelector("test/badBegin"), new BadBeginAction()); + rulesMap.put(new ElementSelector("test/badBegin/touch"), new TouchAction()); + rulesMap.put(new ElementSelector("test/badEnd"), new BadEndAction()); + rulesMap.put(new ElementSelector("test/badEnd/touch"), new TouchAction()); + rulesMap.put(new ElementSelector("test/hello"), new HelloAction()); + + rulesMap.put(new ElementSelector("test/isolate"), new NOPAction()); + rulesMap.put(new ElementSelector("test/isolate/badEnd"), new BadEndAction()); + rulesMap.put(new ElementSelector("test/isolate/badEnd/touch"), new TouchAction()); + rulesMap.put(new ElementSelector("test/isolate/touch"), new TouchAction()); + rulesMap.put(new ElementSelector("test/hello"), new HelloAction()); TrivialConfigurator tc = new TrivialConfigurator(rulesMap); tc.setContext(context); diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java b/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java index 94daf1206eec279a6c604a50a0e432f97dd1f98e..496f8d4eb7f07da00d96940b724234bf16583f88 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -16,15 +16,15 @@ package ch.qos.logback.core.joran; import java.util.HashMap; import ch.qos.logback.core.joran.action.Action; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.joran.spi.Interpreter; -import ch.qos.logback.core.joran.spi.Pattern; import ch.qos.logback.core.joran.spi.RuleStore; public class TrivialConfigurator extends GenericConfigurator { - HashMap rulesMap; + HashMap rulesMap; - public TrivialConfigurator(HashMap rules) { + public TrivialConfigurator(HashMap rules) { this.rulesMap = rules; } @@ -34,9 +34,9 @@ public class TrivialConfigurator extends GenericConfigurator { @Override protected void addInstanceRules(RuleStore rs) { - for(Pattern pattern : rulesMap.keySet()) { - Action action = rulesMap.get(pattern); - rs.addRule(pattern, action); + for(ElementSelector elementSelector : rulesMap.keySet()) { + Action action = rulesMap.get(elementSelector); + rs.addRule(elementSelector, action); } } diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfiguratorTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfiguratorTest.java index a7397f3a6c081fc532ffb949f9c2ed73f6f89d92..eb9fb6cd9ca675c64b349ba52ed6994d0c3445cf 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfiguratorTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfiguratorTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -35,7 +35,7 @@ import ch.qos.logback.core.ContextBase; import ch.qos.logback.core.joran.action.Action; import ch.qos.logback.core.joran.action.ext.IncAction; import ch.qos.logback.core.joran.spi.JoranException; -import ch.qos.logback.core.joran.spi.Pattern; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.status.Status; import ch.qos.logback.core.status.TrivialStatusListener; import ch.qos.logback.core.testUtil.RandomUtil; @@ -44,12 +44,12 @@ import ch.qos.logback.core.util.CoreTestConstants; public class TrivialConfiguratorTest { Context context = new ContextBase(); - HashMap rulesMap = new HashMap(); + HashMap rulesMap = new HashMap(); public void doTest(String filename) throws Exception { // rule store is case insensitve - rulesMap.put(new Pattern("x/inc"), new IncAction()); + rulesMap.put(new ElementSelector("x/inc"), new IncAction()); TrivialConfigurator trivialConfigurator = new TrivialConfigurator(rulesMap); diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/action/AsLowerCasePropertyDefiner.java b/logback-core/src/test/java/ch/qos/logback/core/joran/action/AsLowerCasePropertyDefiner.java index 1aa0a623f2e0af768042dc1e183aa33501dbdce4..d9880ce21fd2b22e97b5f8bee71036cd2fdaee22 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/action/AsLowerCasePropertyDefiner.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/action/AsLowerCasePropertyDefiner.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/action/DefinePropertyActionTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/action/DefinePropertyActionTest.java index 401a5d0b43bab46c4099f8d0e00e6c77c4c8cb58..0cdd91dbff1d8e65f7eac762780a7dae938f6fef 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/action/DefinePropertyActionTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/action/DefinePropertyActionTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -19,6 +19,7 @@ import static org.junit.Assert.assertTrue; import java.util.HashMap; +import ch.qos.logback.core.joran.spi.ElementSelector; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -28,7 +29,6 @@ import ch.qos.logback.core.ContextBase; import ch.qos.logback.core.joran.SimpleConfigurator; import ch.qos.logback.core.joran.spi.InterpretationContext; import ch.qos.logback.core.joran.spi.JoranException; -import ch.qos.logback.core.joran.spi.Pattern; import ch.qos.logback.core.status.Status; import ch.qos.logback.core.status.StatusChecker; import ch.qos.logback.core.util.CoreTestConstants; @@ -56,8 +56,8 @@ public class DefinePropertyActionTest { @Before public void setUp() throws Exception { - HashMap rulesMap = new HashMap(); - rulesMap.put(new Pattern("define"), new DefinePropertyAction()); + HashMap rulesMap = new HashMap(); + rulesMap.put(new ElementSelector("define"), new DefinePropertyAction()); simpleConfigurator = new SimpleConfigurator(rulesMap); simpleConfigurator.setContext(context); } diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/action/DummyAttributes.java b/logback-core/src/test/java/ch/qos/logback/core/joran/action/DummyAttributes.java index fa6de59f8ae36c2398a2cc1cc793657dd52ecb96..3114c40d6f9034b407f3b047438fb0004c11416c 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/action/DummyAttributes.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/action/DummyAttributes.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java index 5aee968be801c2fdaa8a5e71b4cf3cac0df00200..aabe4caa7e2e77283c881a5e67520de66f6633a3 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -38,7 +38,7 @@ import ch.qos.logback.core.ContextBase; import ch.qos.logback.core.joran.TrivialConfigurator; import ch.qos.logback.core.joran.action.ext.StackAction; import ch.qos.logback.core.joran.spi.JoranException; -import ch.qos.logback.core.joran.spi.Pattern; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.status.Status; import ch.qos.logback.core.status.StatusChecker; import ch.qos.logback.core.testUtil.RandomUtil; @@ -60,6 +60,8 @@ public class IncludeActionTest { static final String TOP_BY_FILE = INCLUSION_DIR_PREFIX + "topByFile.xml"; + static final String TOP_OPTIONAL = INCLUSION_DIR_PREFIX + "topOptional.xml"; + static final String INTERMEDIARY_FILE = INCLUSION_DIR_PREFIX + "intermediaryByFile.xml"; @@ -89,10 +91,10 @@ public class IncludeActionTest { @Before public void setUp() throws Exception { FileTestUtil.makeTestOutputDir(); - HashMap rulesMap = new HashMap(); - rulesMap.put(new Pattern("x"), new NOPAction()); - rulesMap.put(new Pattern("x/include"), new IncludeAction()); - rulesMap.put(new Pattern("x/stack"), stackAction); + HashMap rulesMap = new HashMap(); + rulesMap.put(new ElementSelector("x"), new NOPAction()); + rulesMap.put(new ElementSelector("x/include"), new IncludeAction()); + rulesMap.put(new ElementSelector("x/stack"), stackAction); tc = new TrivialConfigurator(rulesMap); tc.setContext(context); @@ -115,6 +117,13 @@ public class IncludeActionTest { verifyConfig(new String[] { "IA", "IB" }); } + @Test + public void optionalFile() throws JoranException { + tc.doConfigure(TOP_OPTIONAL); + verifyConfig(new String[] { "IA", "IB" }); + StatusPrinter.print(context); + } + @Test public void basicResource() throws JoranException { System.setProperty(INCLUDE_KEY, INCLUDED_AS_RESOURCE); diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/action/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/action/PackageTest.java index ad8376c48254c36b0198da706336c92d8bf7ab94..7addc5e6559bc1391e92e2667c569e4f6c00acfb 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/action/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/action/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/action/PropertyActionTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/action/PropertyActionTest.java index acd8ce6a3921250238f1d2bdb587310764393d2e..e576ca4a24c9e2cadbfc2897bd4a05c3c9b0a549 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/action/PropertyActionTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/action/PropertyActionTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/BadBeginAction.java b/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/BadBeginAction.java index 831b836eb9ca407cee41c691be5686efad608320..1b02de4c7cca16f8b6fbdc8a7006a017626fff08 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/BadBeginAction.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/BadBeginAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/BadEndAction.java b/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/BadEndAction.java index adb7f303bed3063efcc3557f7532f7d9260340e1..ee4ebe50f0418420d0e2ddf0bbd96ffe598ad727 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/BadEndAction.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/BadEndAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/HelloAction.java b/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/HelloAction.java index 3e81d4b816288b57f3b8ea23305f758d6fc17f99..20620e31fdd2e9d67b561a35bf699dfe9cb34200 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/HelloAction.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/HelloAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/IncAction.java b/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/IncAction.java index ac9336f4c017a0a6cf563079e95e87c865975bf0..7d926ee048dbb02da9e3fed6a0e0255b8f081194 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/IncAction.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/IncAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/StackAction.java b/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/StackAction.java index ed78024f715b6d87bbc51a853ba647297f6a6fb8..c7597f34f015e41c27c6a41e97ceb554400542a6 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/StackAction.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/StackAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/TouchAction.java b/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/TouchAction.java index 7a59aca836094ebb073893bd6b9f4fab98d9c697..627d30d3af9a31c96246c0b76af0be2887694905 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/TouchAction.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/TouchAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/conditional/IfThenElseAndIncludeCompositionTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/conditional/IfThenElseAndIncludeCompositionTest.java index 471d22c58fab9d5dcf88636b1289c5e8047e5c8d..893a610d55171d270c6d3c1a244c281ae39d48f3 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/conditional/IfThenElseAndIncludeCompositionTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/conditional/IfThenElseAndIncludeCompositionTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -19,6 +19,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Stack; +import ch.qos.logback.core.joran.spi.ElementSelector; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -31,7 +32,6 @@ import ch.qos.logback.core.joran.action.IncludeAction; import ch.qos.logback.core.joran.action.NOPAction; import ch.qos.logback.core.joran.action.ext.StackAction; import ch.qos.logback.core.joran.spi.JoranException; -import ch.qos.logback.core.joran.spi.Pattern; import ch.qos.logback.core.testUtil.RandomUtil; import ch.qos.logback.core.util.CoreTestConstants; import ch.qos.logback.core.util.StatusPrinter; @@ -56,15 +56,15 @@ public class IfThenElseAndIncludeCompositionTest { @Before public void setUp() throws Exception { - HashMap rulesMap = new HashMap(); - rulesMap.put(new Pattern("x"), new NOPAction()); - rulesMap.put(new Pattern("x/stack"), stackAction); - rulesMap.put(new Pattern("*/if"), new IfAction()); - rulesMap.put(new Pattern("*/if/then"), new ThenAction()); - rulesMap.put(new Pattern("*/if/then/*"), new NOPAction()); - rulesMap.put(new Pattern("*/if/else"), new ElseAction()); - rulesMap.put(new Pattern("*/if/else/*"), new NOPAction()); - rulesMap.put(new Pattern("x/include"), new IncludeAction()); + HashMap rulesMap = new HashMap(); + rulesMap.put(new ElementSelector("x"), new NOPAction()); + rulesMap.put(new ElementSelector("x/stack"), stackAction); + rulesMap.put(new ElementSelector("*/if"), new IfAction()); + rulesMap.put(new ElementSelector("*/if/then"), new ThenAction()); + rulesMap.put(new ElementSelector("*/if/then/*"), new NOPAction()); + rulesMap.put(new ElementSelector("*/if/else"), new ElseAction()); + rulesMap.put(new ElementSelector("*/if/else/*"), new NOPAction()); + rulesMap.put(new ElementSelector("x/include"), new IncludeAction()); tc = new TrivialConfigurator(rulesMap); tc.setContext(context); diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/conditional/IfThenElseTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/conditional/IfThenElseTest.java index 6c6ebcc5196923edd3465f594ddebfa1853a9660..bd7d3d819526c1b50fa608aa2d05676f459b9ec7 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/conditional/IfThenElseTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/conditional/IfThenElseTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -19,6 +19,7 @@ import java.util.HashMap; import java.util.Stack; import ch.qos.logback.core.joran.action.PropertyAction; +import ch.qos.logback.core.joran.spi.ElementSelector; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -30,7 +31,6 @@ import ch.qos.logback.core.joran.action.Action; import ch.qos.logback.core.joran.action.NOPAction; import ch.qos.logback.core.joran.action.ext.StackAction; import ch.qos.logback.core.joran.spi.JoranException; -import ch.qos.logback.core.joran.spi.Pattern; import ch.qos.logback.core.status.StatusChecker; import ch.qos.logback.core.testUtil.RandomUtil; import ch.qos.logback.core.util.CoreTestConstants; @@ -56,15 +56,15 @@ public class IfThenElseTest { @Before public void setUp() throws Exception { - HashMap rulesMap = new HashMap(); - rulesMap.put(new Pattern("x"), new NOPAction()); - rulesMap.put(new Pattern("x/stack"), stackAction); - rulesMap.put(new Pattern("x/property"), new PropertyAction()); - rulesMap.put(new Pattern("*/if"), new IfAction()); - rulesMap.put(new Pattern("*/if/then"), new ThenAction()); - rulesMap.put(new Pattern("*/if/then/*"), new NOPAction()); - rulesMap.put(new Pattern("*/if/else"), new ElseAction()); - rulesMap.put(new Pattern("*/if/else/*"), new NOPAction()); + HashMap rulesMap = new HashMap(); + rulesMap.put(new ElementSelector("x"), new NOPAction()); + rulesMap.put(new ElementSelector("x/stack"), stackAction); + rulesMap.put(new ElementSelector("x/property"), new PropertyAction()); + rulesMap.put(new ElementSelector("*/if"), new IfAction()); + rulesMap.put(new ElementSelector("*/if/then"), new ThenAction()); + rulesMap.put(new ElementSelector("*/if/then/*"), new NOPAction()); + rulesMap.put(new ElementSelector("*/if/else"), new ElseAction()); + rulesMap.put(new ElementSelector("*/if/else/*"), new NOPAction()); tc = new TrivialConfigurator(rulesMap); tc.setContext(context); diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/conditional/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/conditional/PackageTest.java index 08e4120bfeb4f8fd3cd1237a0dba1819f5ca4eb0..1b4aad5089295eee905e94c70490a1d69d07b382 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/conditional/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/conditional/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/conditional/PropertyEvalScriptBuilderTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/conditional/PropertyEvalScriptBuilderTest.java index 98d68da65b0ee6481d2ba1114dd1240432817a07..20ed4e1aeb4dbd9db8b8147dc5c72d02a8bd4141 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/conditional/PropertyEvalScriptBuilderTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/conditional/PropertyEvalScriptBuilderTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java index 934ff18102ab1b513d43a4ebed03892901c02812..c2ae9dfe0bfa20582a0ed2d7fec4f39d5a79f42c 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -18,6 +18,8 @@ import static org.junit.Assert.assertTrue; import java.util.HashMap; +import ch.qos.logback.core.joran.spi.ElementPath; +import ch.qos.logback.core.joran.spi.ElementSelector; import org.junit.Test; import ch.qos.logback.core.Context; @@ -25,19 +27,18 @@ import ch.qos.logback.core.ContextBase; import ch.qos.logback.core.joran.TrivialConfigurator; import ch.qos.logback.core.joran.action.Action; import ch.qos.logback.core.joran.spi.JoranException; -import ch.qos.logback.core.joran.spi.Pattern; import ch.qos.logback.core.util.CoreTestConstants; public class InPlayFireTest { Context context = new ContextBase(); - HashMap rulesMap = new HashMap(); + HashMap rulesMap = new HashMap(); @Test public void testBasic() throws JoranException { ListenAction listenAction = new ListenAction(); - rulesMap.put(new Pattern("fire"), listenAction); + rulesMap.put(new ElementSelector("fire"), listenAction); TrivialConfigurator gc = new TrivialConfigurator(rulesMap); gc.setContext(context); @@ -57,7 +58,7 @@ public class InPlayFireTest { public void testReplay() throws JoranException { ListenAction listenAction = new ListenAction(); - rulesMap.put(new Pattern("fire"), listenAction); + rulesMap.put(new ElementSelector("fire"), listenAction); TrivialConfigurator gc = new TrivialConfigurator(rulesMap); gc.setContext(context); diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/event/ListenAction.java b/logback-core/src/test/java/ch/qos/logback/core/joran/event/ListenAction.java index d72e31d6511fbd8e847256a0a195cb4e056281f2..4ad6e3802740010042335c8cf56afc27b9c98171 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/event/ListenAction.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/event/ListenAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/event/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/event/PackageTest.java index 5d69a20b81c4c6f8f95b8057c3b60558f183846e..b80bc76d190ab2ed78f5cf320962f9aa819d833a 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/event/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/event/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/event/SaxEventRecorderTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/event/SaxEventRecorderTest.java index b3025ce7595623c7fda07071bae50c1b9926a24b..e1df97462f5d90e039b68f545628397986cd91af 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/event/SaxEventRecorderTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/event/SaxEventRecorderTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -47,8 +47,7 @@ public class SaxEventRecorderTest { } public List doTest(String filename) throws Exception { - SaxEventRecorder recorder = new SaxEventRecorder(); - recorder.setContext(context); + SaxEventRecorder recorder = new SaxEventRecorder(context); FileInputStream fis = new FileInputStream(CoreTestConstants.TEST_SRC_PREFIX + "input/joran/"+ filename); recorder.recordEvents(fis); diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/event/stax/StaxEventRecorderTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/event/stax/StaxEventRecorderTest.java new file mode 100755 index 0000000000000000000000000000000000000000..f5522c73d3efad7626143c4f8c9d311a890760d1 --- /dev/null +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/event/stax/StaxEventRecorderTest.java @@ -0,0 +1,84 @@ +package ch.qos.logback.core.joran.event.stax; + +import ch.qos.logback.core.Context; +import ch.qos.logback.core.ContextBase; +import ch.qos.logback.core.status.Status; +import ch.qos.logback.core.status.StatusChecker; +import ch.qos.logback.core.status.StatusManager; +import ch.qos.logback.core.util.CoreTestConstants; +import org.junit.Test; + +import javax.xml.stream.events.Attribute; +import java.io.FileInputStream; +import java.util.List; + +import static org.junit.Assert.*; + +public class StaxEventRecorderTest { + + + Context context = new ContextBase(); + StatusChecker statusChecker = new StatusChecker(context); + + + public List doTest(String filename) throws Exception { + StaxEventRecorder recorder = new StaxEventRecorder(context); + FileInputStream fis = new FileInputStream(CoreTestConstants.TEST_SRC_PREFIX + + "input/joran/" + filename); + recorder.recordEvents(fis); + return recorder.getEventList(); + } + + public void dump(List seList) { + for (StaxEvent se : seList) { + System.out.println(se); + } + } + + @Test + public void testParsingOfXMLWithAttributesAndBodyText() throws Exception { + List seList = doTest("event1.xml"); + assertTrue(statusChecker.getHighestLevel(0) == Status.INFO); + //dump(seList); + assertEquals(11, seList.size()); + assertEquals("test", seList.get(0).getName()); + assertEquals("badBegin", seList.get(1).getName()); + StartEvent startEvent = (StartEvent) seList.get(7); + assertEquals("John Doe", startEvent.getAttributeByName("name").getValue()); + assertEquals("XXX&", ((BodyEvent) seList.get(8)).getText()); + } + + @Test + public void testProcessingOfTextWithEntityCharacters() throws Exception { + List seList = doTest("ampEvent.xml"); + StatusManager sm = context.getStatusManager(); + assertTrue(statusChecker.getHighestLevel(0) == Status.INFO); + //dump(seList); + assertEquals(3, seList.size()); + + BodyEvent be = (BodyEvent) seList.get(1); + assertEquals("xxx & yyy", be.getText()); + } + + @Test + public void testAttributeProcessing() throws Exception { + List seList = doTest("inc.xml"); + StatusManager sm = context.getStatusManager(); + assertTrue(statusChecker.getHighestLevel(0) == Status.INFO); + assertEquals(4, seList.size()); + StartEvent se = (StartEvent) seList.get(1); + Attribute attr = se.getAttributeByName("increment"); + assertNotNull(attr); + assertEquals("1", attr.getValue()); + } + + @Test + public void bodyWithSpacesAndQuotes() throws Exception { + List seList = doTest("spacesAndQuotes.xml"); + assertEquals(3, seList.size()); + BodyEvent be = (BodyEvent) seList.get(1); + assertEquals("[x][x] \"xyz\"%n", be.getText()); + } +} + + diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/Cake.java b/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/Cake.java index 021d0e7dd0fe7705d22386261f4f230df191fdce..e07cac7e5ed7f17159580cbbe68a05dbb7b9fc6f 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/Cake.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/Cake.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/Fruit.java b/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/Fruit.java index 759a84f26fccc3dabf3341040fa4921723334305..9e97d074e8bbafefc87a2e54a4b88f4698092942 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/Fruit.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/Fruit.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/FruitContext.java b/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/FruitContext.java index 1e569d4481c1a3347d4571aaec4445cad8c05441..f773879203c76dadd134e2cfba76802efec91823 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/FruitContext.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/FruitContext.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/FruitContextAction.java b/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/FruitContextAction.java index 2194c6a0e73d951c7e9d9f6520ae87c0eecd0006..7a467a01be581d815a6614db5699930d39f789b8 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/FruitContextAction.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/FruitContextAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/ImplicitActionTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/ImplicitActionTest.java index 7ec32a2faf9e79bb982965406dd4133587186e5f..2948c607c6b3d2816e67009487f55f260705d387 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/ImplicitActionTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/ImplicitActionTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -24,7 +24,7 @@ import org.junit.Test; import ch.qos.logback.core.joran.SimpleConfigurator; import ch.qos.logback.core.joran.action.Action; -import ch.qos.logback.core.joran.spi.Pattern; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.util.CoreTestConstants; import ch.qos.logback.core.util.StatusPrinter; @@ -39,8 +39,8 @@ public class ImplicitActionTest { @Before public void setUp() throws Exception { fruitContext.setName("fruits"); - HashMap rulesMap = new HashMap(); - rulesMap.put(new Pattern("/context/"), new FruitContextAction()); + HashMap rulesMap = new HashMap(); + rulesMap.put(new ElementSelector("/context/"), new FruitContextAction()); simpleConfigurator = new SimpleConfigurator(rulesMap); simpleConfigurator.setContext(fruitContext); } diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/PackageTest.java index b856d7f4f01c6e5cf8ab856c62f29fa6bbf06fcc..27f0ebbb2aecdd94fcc8ec109d0518d119c86af9 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/Fruit.java b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/Fruit.java index 50aab7509ace2bec761aeaba4f9bce20ea41ec65..a997396ff6ce1537b434e70a3c133f30fd07a510 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/Fruit.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/Fruit.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurationTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurationTest.java index d5790f83066b8a5bf6ad4edea2d012a1ab1c5ccb..5a3f67fbcfaeccd23777316fe377f9d1edcb6907 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurationTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurationTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -20,12 +20,12 @@ import static org.junit.Assert.assertTrue; import java.util.HashMap; import java.util.List; +import ch.qos.logback.core.joran.spi.ElementSelector; import org.junit.Test; import ch.qos.logback.core.joran.SimpleConfigurator; import ch.qos.logback.core.joran.action.Action; import ch.qos.logback.core.joran.action.NOPAction; -import ch.qos.logback.core.joran.spi.Pattern; import ch.qos.logback.core.util.CoreTestConstants; import ch.qos.logback.core.util.StatusPrinter; @@ -39,11 +39,11 @@ public class FruitConfigurationTest { public List doFirstPart(String filename) throws Exception { try { - HashMap rulesMap = new HashMap(); - rulesMap.put(new Pattern("group/fruitShell"), new FruitShellAction()); - rulesMap.put(new Pattern("group/fruitShell/fruit"), + HashMap rulesMap = new HashMap(); + rulesMap.put(new ElementSelector("group/fruitShell"), new FruitShellAction()); + rulesMap.put(new ElementSelector("group/fruitShell/fruit"), new FruitFactoryAction()); - rulesMap.put(new Pattern("group/fruitShell/fruit/*"), new NOPAction()); + rulesMap.put(new ElementSelector("group/fruitShell/fruit/*"), new NOPAction()); SimpleConfigurator simpleConfigurator = new SimpleConfigurator(rulesMap); simpleConfigurator.setContext(fruitContext); diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurator.java b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurator.java index 8825cfe50df94b3b438d495abba740e80cd06d81..b5953174b513474d961e3b0f094f5dcdb342ab39 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurator.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -23,7 +23,7 @@ import ch.qos.logback.core.joran.event.SaxEvent; import ch.qos.logback.core.joran.spi.EventPlayer; import ch.qos.logback.core.joran.spi.Interpreter; import ch.qos.logback.core.joran.spi.JoranException; -import ch.qos.logback.core.joran.spi.Pattern; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.joran.spi.RuleStore; public class FruitConfigurator extends GenericConfigurator { @@ -56,7 +56,7 @@ public class FruitConfigurator extends GenericConfigurator { @Override protected void addInstanceRules(RuleStore rs) { - rs.addRule(new Pattern("fruitShell"), new NOPAction()); + rs.addRule(new ElementSelector("fruitShell"), new NOPAction()); } } diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitContext.java b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitContext.java index a082c8e155909e384612cf56ee4955fde6cbbbc5..7a4b10b380125aeccfa134ed232dfe924a2525df 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitContext.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitContext.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactory.java b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactory.java index e28f112fa21d04a4375f4c09494689b421e1d93a..dafb14df2a6b717bcac37b2d88ef2477582c3f48 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactory.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactory.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactoryAction.java b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactoryAction.java index d85ebf38df8605057b314740ba62f4fd38855037..7f6dcae5e30cbaf9f1ecc967468d1cdc64ec20e2 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactoryAction.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactoryAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShell.java b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShell.java index 1464d73784bf07a0e43fb50e0a44b2d895a2b371..cf7f93203b3dcc34c59a4bf6f660c7d336732433 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShell.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShell.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShellAction.java b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShellAction.java index e5b40d1e6f61a2bde00e0c663813a58c81875898..abc38eb774b3849c4d7819d009e50db987b7787c 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShellAction.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShellAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/PackageTest.java index a1ecf53d7b22430731d237a46b1dd3d4fc7b03eb..506578ff26f9b8dd6c41aa650617a223a944c758 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/WeightytFruit.java b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/WeightytFruit.java index cba69ee004a6bbcbe8aa27dcda736a68b0605249..cee9ec0d51c25de3e65dce2263da492fa9e4726c 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/replay/WeightytFruit.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/replay/WeightytFruit.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/CaseCombinator.java b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/CaseCombinator.java index fce697cd59c59cc1942f7f9a747843d3ff1a3a7e..175ae21b5336c3fd259e3a5679e4c2cd38701e2e 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/CaseCombinator.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/CaseCombinator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/CaseCombinatorTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/CaseCombinatorTest.java index b705b80adbcf552fa4f1ffe54ce159ef8d7bb7cf..86246c761d9396c6aa3fc23847a7159210084b6b 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/CaseCombinatorTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/CaseCombinatorTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/ConfigurationWatchListTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/ConfigurationWatchListTest.java index e80acc017b5a0257aaf537bc30911cc7aa6519b5..d6dde8a3bb3a3d878e6624b36e0984fe5e89135c 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/ConfigurationWatchListTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/ConfigurationWatchListTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/DefaultNestedComponentRegistryTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/DefaultNestedComponentRegistryTest.java index 076d2db1703aabad16966824b31d12644ac05326..202b88dcfe4bb021589c3cc49aa3e2c37f0306c9 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/DefaultNestedComponentRegistryTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/DefaultNestedComponentRegistryTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/DoNotAutoStart.java b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/DoNotAutoStart.java index 97862b7930e4a9d17131146f186f6b2968735d2f..e1aee24570685e5d8ddb60af2330f4463454b58f 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/DoNotAutoStart.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/DoNotAutoStart.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/ElementSelectorTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/ElementSelectorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c68940f07336db5e0cd9388c22a5552d5d5a9d9c --- /dev/null +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/ElementSelectorTest.java @@ -0,0 +1,179 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package ch.qos.logback.core.joran.spi; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +/** + * Test pattern manipulation code. + * + * @author Ceki Gulcu + */ +public class ElementSelectorTest { + + @Test + public void test1() { + ElementSelector p = new ElementSelector("a"); + assertEquals(1, p.size()); + assertEquals("a", p.peekLast()); + assertEquals("a", p.get(0)); + } + + @Test + public void testSuffix() { + ElementSelector p = new ElementSelector("a/"); + assertEquals(1, p.size()); + assertEquals("a", p.peekLast()); + assertEquals("a", p.get(0)); + } + + @Test + public void test2() { + ElementSelector p = new ElementSelector("a/b"); + assertEquals(2, p.size()); + assertEquals("b", p.peekLast()); + assertEquals("a", p.get(0)); + assertEquals("b", p.get(1)); + } + + @Test + public void test3() { + ElementSelector p = new ElementSelector("a123/b1234/cvvsdf"); + assertEquals(3, p.size()); + assertEquals("a123", p.get(0)); + assertEquals("b1234", p.get(1)); + assertEquals("cvvsdf", p.get(2)); + } + + @Test + public void test4() { + ElementSelector p = new ElementSelector("/a123/b1234/cvvsdf"); + assertEquals(3, p.size()); + assertEquals("a123", p.get(0)); + assertEquals("b1234", p.get(1)); + assertEquals("cvvsdf", p.get(2)); + } + + @Test + public void test5() { + ElementSelector p = new ElementSelector("//a"); + assertEquals(1, p.size()); + assertEquals("a", p.get(0)); + } + + @Test + public void test6() { + ElementSelector p = new ElementSelector("//a//b"); + assertEquals(2, p.size()); + assertEquals("a", p.get(0)); + assertEquals("b", p.get(1)); + } + + + // test tail matching + @Test + public void testTailMatch() { + { + ElementPath p = new ElementPath("/a/b"); + ElementSelector ruleElementSelector = new ElementSelector("*"); + assertEquals(0, ruleElementSelector.getTailMatchLength(p)); + } + + { + ElementPath p = new ElementPath("/a"); + ElementSelector ruleElementSelector = new ElementSelector("*/a"); + assertEquals(1, ruleElementSelector.getTailMatchLength(p)); + } + + { + ElementPath p = new ElementPath("/A"); + ElementSelector ruleElementSelector = new ElementSelector("*/a"); + assertEquals(1, ruleElementSelector.getTailMatchLength(p)); + } + + { + ElementPath p = new ElementPath("/a"); + ElementSelector ruleElementSelector = new ElementSelector("*/A"); + assertEquals(1, ruleElementSelector.getTailMatchLength(p)); + } + + + { + ElementPath p = new ElementPath("/a/b"); + ElementSelector ruleElementSelector = new ElementSelector("*/b"); + assertEquals(1, ruleElementSelector.getTailMatchLength(p)); + } + + { + ElementPath p = new ElementPath("/a/B"); + ElementSelector ruleElementSelector = new ElementSelector("*/b"); + assertEquals(1, ruleElementSelector.getTailMatchLength(p)); + } + + { + ElementPath p = new ElementPath("/a/b/c"); + ElementSelector ruleElementSelector = new ElementSelector("*/b/c"); + assertEquals(2, ruleElementSelector.getTailMatchLength(p)); + } + } + + // test prefix matching + @Test + public void testPrefixMatch() { + { + ElementPath p = new ElementPath("/a/b"); + ElementSelector ruleElementSelector = new ElementSelector("/x/*"); + assertEquals(0, ruleElementSelector.getPrefixMatchLength(p)); + } + + { + ElementPath p = new ElementPath("/a"); + ElementSelector ruleElementSelector = new ElementSelector("/x/*"); + assertEquals(0, ruleElementSelector.getPrefixMatchLength(p)); + } + + { + ElementPath p = new ElementPath("/a/b"); + ElementSelector ruleElementSelector = new ElementSelector("/a/*"); + assertEquals(1, ruleElementSelector.getPrefixMatchLength(p)); + } + + { + ElementPath p = new ElementPath("/a/b"); + ElementSelector ruleElementSelector = new ElementSelector("/A/*"); + assertEquals(1, ruleElementSelector.getPrefixMatchLength(p)); + } + + { + ElementPath p = new ElementPath("/A/b"); + ElementSelector ruleElementSelector = new ElementSelector("/a/*"); + assertEquals(1, ruleElementSelector.getPrefixMatchLength(p)); + } + + { + ElementPath p = new ElementPath("/a/b"); + ElementSelector ruleElementSelector = new ElementSelector("/a/b/*"); + assertEquals(2, ruleElementSelector.getPrefixMatchLength(p)); + } + + { + ElementPath p = new ElementPath("/a/b"); + ElementSelector ruleElementSelector = new ElementSelector("/*"); + assertEquals(0, ruleElementSelector.getPrefixMatchLength(p)); + } + } + +} diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/NoAutoStartUtilTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/NoAutoStartUtilTest.java index 78d810eab5b281f538e2aa49235a1c6cffc60666..43af2a0a04200ebe3c1e28e2a09357a50a384bff 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/NoAutoStartUtilTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/NoAutoStartUtilTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java index 692455cc53417bb509dd22e53e6a8ae3c7c4cdd2..401f75daf8bf7c58502d6633666148b16c83cb5c 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -18,7 +18,7 @@ import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) -@SuiteClasses( { PatternTest.class, SimpleRuleStoreTest.class, +@SuiteClasses( { ElementSelectorTest.class, SimpleRuleStoreTest.class, NoAutoStartUtilTest.class, ConfigurationWatchListTest.class, DefaultNestedComponentRegistryTest.class, CaseCombinatorTest.class }) public class PackageTest { diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PatternTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PatternTest.java deleted file mode 100644 index 1ac53d93697ae93a1df65f43257b5f312c1b0319..0000000000000000000000000000000000000000 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PatternTest.java +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.core.joran.spi; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -/** - * Test pattern manipulation code. - * - * @author Ceki Gulcu - */ -public class PatternTest { - - @Test - public void test1() { - Pattern p = new Pattern("a"); - assertEquals(1, p.size()); - assertEquals("a", p.peekLast()); - assertEquals("a", p.get(0)); - } - - @Test - public void testSuffix() { - Pattern p = new Pattern("a/"); - assertEquals(1, p.size()); - assertEquals("a", p.peekLast()); - assertEquals("a", p.get(0)); - } - - @Test - public void test2() { - Pattern p = new Pattern("a/b"); - assertEquals(2, p.size()); - assertEquals("b", p.peekLast()); - assertEquals("a", p.get(0)); - assertEquals("b", p.get(1)); - } - - @Test - public void test3() { - Pattern p = new Pattern("a123/b1234/cvvsdf"); - assertEquals(3, p.size()); - assertEquals("a123", p.get(0)); - assertEquals("b1234", p.get(1)); - assertEquals("cvvsdf", p.get(2)); - } - - @Test - public void test4() { - Pattern p = new Pattern("/a123/b1234/cvvsdf"); - assertEquals(3, p.size()); - assertEquals("a123", p.get(0)); - assertEquals("b1234", p.get(1)); - assertEquals("cvvsdf", p.get(2)); - } - - @Test - public void test5() { - Pattern p = new Pattern("//a"); - assertEquals(1, p.size()); - assertEquals("a", p.get(0)); - } - - @Test - public void test6() { - Pattern p = new Pattern("//a//b"); - assertEquals(2, p.size()); - assertEquals("a", p.get(0)); - assertEquals("b", p.get(1)); - } - - - // test tail matching - @Test - public void testTailMatch() { - { - Pattern p = new Pattern("/a/b"); - Pattern rulePattern = new Pattern("*"); - assertEquals(0, p.getTailMatchLength(rulePattern)); - } - - { - Pattern p = new Pattern("/a"); - Pattern rulePattern = new Pattern("*/a"); - assertEquals(1, p.getTailMatchLength(rulePattern)); - } - - { - Pattern p = new Pattern("/A"); - Pattern rulePattern = new Pattern("*/a"); - assertEquals(1, p.getTailMatchLength(rulePattern)); - } - - { - Pattern p = new Pattern("/a"); - Pattern rulePattern = new Pattern("*/A"); - assertEquals(1, p.getTailMatchLength(rulePattern)); - } - - - { - Pattern p = new Pattern("/a/b"); - Pattern rulePattern = new Pattern("*/b"); - assertEquals(1, p.getTailMatchLength(rulePattern)); - } - - { - Pattern p = new Pattern("/a/B"); - Pattern rulePattern = new Pattern("*/b"); - assertEquals(1, p.getTailMatchLength(rulePattern)); - } - - { - Pattern p = new Pattern("/a/b/c"); - Pattern rulePattern = new Pattern("*/b/c"); - assertEquals(2, p.getTailMatchLength(rulePattern)); - } - } - - // test prefix matching - @Test - public void testPrefixMatch() { - { - Pattern p = new Pattern("/a/b"); - Pattern rulePattern = new Pattern("/x/*"); - assertEquals(0, p.getPrefixMatchLength(rulePattern)); - } - - { - Pattern p = new Pattern("/a"); - Pattern rulePattern = new Pattern("/x/*"); - assertEquals(0, p.getPrefixMatchLength(rulePattern)); - } - - { - Pattern p = new Pattern("/a/b"); - Pattern rulePattern = new Pattern("/a/*"); - assertEquals(1, p.getPrefixMatchLength(rulePattern)); - } - - { - Pattern p = new Pattern("/a/b"); - Pattern rulePattern = new Pattern("/A/*"); - assertEquals(1, p.getPrefixMatchLength(rulePattern)); - } - - { - Pattern p = new Pattern("/A/b"); - Pattern rulePattern = new Pattern("/a/*"); - assertEquals(1, p.getPrefixMatchLength(rulePattern)); - } - - { - Pattern p = new Pattern("/a/b"); - Pattern rulePattern = new Pattern("/a/b/*"); - assertEquals(2, p.getPrefixMatchLength(rulePattern)); - } - - { - Pattern p = new Pattern("/a/b"); - Pattern rulePattern = new Pattern("/*"); - assertEquals(0, p.getPrefixMatchLength(rulePattern)); - } - } - -} diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/SimpleRuleStoreTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/SimpleRuleStoreTest.java index 81475da7e87ab2417e26aa84c773a05ae68017c9..b8efc5af2315eb09c8aca7788f7536da1c18c872 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/SimpleRuleStoreTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/SimpleRuleStoreTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -41,11 +41,12 @@ public class SimpleRuleStoreTest { @Test public void smoke() throws Exception { - srs.addRule(new Pattern("a/b"), new XAction()); + srs.addRule(new ElementSelector("a/b"), new XAction()); // test for all possible case combinations of "a/b" for (String s : cc.combinations("a/b")) { - List r = srs.matchActions(new Pattern(s)); + System.out.println("s="+s); + List r = srs.matchActions(new ElementPath(s)); assertNotNull(r); assertEquals(1, r.size()); @@ -57,11 +58,11 @@ public class SimpleRuleStoreTest { @Test public void smokeII() throws Exception { - srs.addRule(new Pattern("a/b"), new XAction()); - srs.addRule(new Pattern("a/b"), new YAction()); + srs.addRule(new ElementSelector("a/b"), new XAction()); + srs.addRule(new ElementSelector("a/b"), new YAction()); for (String s : cc.combinations("a/b")) { - List r = srs.matchActions(new Pattern(s)); + List r = srs.matchActions(new ElementPath(s)); assertNotNull(r); assertEquals(2, r.size()); @@ -77,11 +78,11 @@ public class SimpleRuleStoreTest { @Test public void testSlashSuffix() throws Exception { - Pattern pa = new Pattern("a/"); + ElementSelector pa = new ElementSelector("a/"); srs.addRule(pa, new XAction()); for (String s : cc.combinations("a")) { - List r = srs.matchActions(new Pattern(s)); + List r = srs.matchActions(new ElementPath(s)); assertNotNull(r); assertEquals(1, r.size()); @@ -94,10 +95,10 @@ public class SimpleRuleStoreTest { @Test public void testTail1() throws Exception { - srs.addRule(new Pattern("*/b"), new XAction()); + srs.addRule(new ElementSelector("*/b"), new XAction()); for (String s : cc.combinations("a/b")) { - List r = srs.matchActions(new Pattern(s)); + List r = srs.matchActions(new ElementPath(s)); assertNotNull(r); assertEquals(1, r.size()); @@ -111,10 +112,10 @@ public class SimpleRuleStoreTest { @Test public void testTail2() throws Exception { SimpleRuleStore srs = new SimpleRuleStore(new ContextBase()); - srs.addRule(new Pattern("*/c"), new XAction()); + srs.addRule(new ElementSelector("*/c"), new XAction()); for (String s : cc.combinations("a/b/c")) { - List r = srs.matchActions(new Pattern(s)); + List r = srs.matchActions(new ElementPath(s)); assertNotNull(r); assertEquals(1, r.size()); @@ -127,11 +128,11 @@ public class SimpleRuleStoreTest { @Test public void testTail3() throws Exception { - srs.addRule(new Pattern("*/b"), new XAction()); - srs.addRule(new Pattern("*/a/b"), new YAction()); + srs.addRule(new ElementSelector("*/b"), new XAction()); + srs.addRule(new ElementSelector("*/a/b"), new YAction()); for (String s : cc.combinations("a/b")) { - List r = srs.matchActions(new Pattern(s)); + List r = srs.matchActions(new ElementPath(s)); assertNotNull(r); assertEquals(1, r.size()); @@ -143,12 +144,12 @@ public class SimpleRuleStoreTest { @Test public void testTail4() throws Exception { - srs.addRule(new Pattern("*/b"), new XAction()); - srs.addRule(new Pattern("*/a/b"), new YAction()); - srs.addRule(new Pattern("a/b"), new ZAction()); + srs.addRule(new ElementSelector("*/b"), new XAction()); + srs.addRule(new ElementSelector("*/a/b"), new YAction()); + srs.addRule(new ElementSelector("a/b"), new ZAction()); for (String s : cc.combinations("a/b")) { - List r = srs.matchActions(new Pattern(s)); + List r = srs.matchActions(new ElementPath(s)); assertNotNull(r); assertEquals(1, r.size()); @@ -160,11 +161,11 @@ public class SimpleRuleStoreTest { @Test public void testSuffix() throws Exception { - srs.addRule(new Pattern("a"), new XAction()); - srs.addRule(new Pattern("a/*"), new YAction()); + srs.addRule(new ElementSelector("a"), new XAction()); + srs.addRule(new ElementSelector("a/*"), new YAction()); for (String s : cc.combinations("a/b")) { - List r = srs.matchActions(new Pattern(s)); + List r = srs.matchActions(new ElementPath(s)); assertNotNull(r); assertEquals(1, r.size()); assertTrue(r.get(0) instanceof YAction); @@ -173,23 +174,23 @@ public class SimpleRuleStoreTest { @Test public void testDeepSuffix() throws Exception { - srs.addRule(new Pattern("a"), new XAction(1)); - srs.addRule(new Pattern("a/b/*"), new XAction(2)); + srs.addRule(new ElementSelector("a"), new XAction(1)); + srs.addRule(new ElementSelector("a/b/*"), new XAction(2)); for (String s : cc.combinations("a/other")) { - List r = srs.matchActions(new Pattern(s)); + List r = srs.matchActions(new ElementPath(s)); assertNull(r); } } @Test public void testPrefixSuffixInteraction1() throws Exception { - srs.addRule(new Pattern("a"), new ZAction()); - srs.addRule(new Pattern("a/*"), new YAction()); - srs.addRule(new Pattern("*/a/b"), new XAction(3)); + srs.addRule(new ElementSelector("a"), new ZAction()); + srs.addRule(new ElementSelector("a/*"), new YAction()); + srs.addRule(new ElementSelector("*/a/b"), new XAction(3)); for (String s : cc.combinations("a/b")) { - List r = srs.matchActions(new Pattern(s)); + List r = srs.matchActions(new ElementPath(s)); assertNotNull(r); assertEquals(1, r.size()); @@ -202,13 +203,13 @@ public class SimpleRuleStoreTest { @Test public void testPrefixSuffixInteraction2() throws Exception { - srs.addRule(new Pattern("tG"), new XAction()); - srs.addRule(new Pattern("tG/tS"), new YAction()); - srs.addRule(new Pattern("tG/tS/test"), new ZAction()); - srs.addRule(new Pattern("tG/tS/test/*"), new XAction(9)); + srs.addRule(new ElementSelector("tG"), new XAction()); + srs.addRule(new ElementSelector("tG/tS"), new YAction()); + srs.addRule(new ElementSelector("tG/tS/test"), new ZAction()); + srs.addRule(new ElementSelector("tG/tS/test/*"), new XAction(9)); for (String s : cc.combinations("tG/tS/toto")) { - List r = srs.matchActions(new Pattern(s)); + List r = srs.matchActions(new ElementPath(s)); assertNull(r); } } diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/util/House.java b/logback-core/src/test/java/ch/qos/logback/core/joran/util/House.java index ec371596ad99b6802e1a368ef14ae28161c6a363..3813ac550fcece0d3760c90503e829cacf02511c 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/util/House.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/util/House.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/util/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/util/PackageTest.java index b6a7f2372115878afdc461f3360733a2f2ad93c7..36a03b72a2662b368d4ff26c5ff49bc0c9b0d3d2 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/util/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/util/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/util/PropertySetterTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/util/PropertySetterTest.java index 061a2ba266a98e46bb01be28f18964bf31820ff0..efe159289eacc4d1f211bf4d8695eee827759109 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/joran/util/PropertySetterTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/joran/util/PropertySetterTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/layout/DummyLayout.java b/logback-core/src/test/java/ch/qos/logback/core/layout/DummyLayout.java index f5649a907419558021c162d2c9d8bf1813089d63..73b9d78eada0961c5360f5fd5485ea8b1790a7ff 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/layout/DummyLayout.java +++ b/logback-core/src/test/java/ch/qos/logback/core/layout/DummyLayout.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/layout/NopLayout.java b/logback-core/src/test/java/ch/qos/logback/core/layout/NopLayout.java index 77316fe1b7f764d3113179bc80d96ff3487afdd4..c89375b252e3aede4d2d66ca340be410c2ea38c6 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/layout/NopLayout.java +++ b/logback-core/src/test/java/ch/qos/logback/core/layout/NopLayout.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/SSLSocketAppenderBaseTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/AbstractSSLSocketAppenderTest.java similarity index 81% rename from logback-core/src/test/java/ch/qos/logback/core/net/SSLSocketAppenderBaseTest.java rename to logback-core/src/test/java/ch/qos/logback/core/net/AbstractSSLSocketAppenderTest.java index 0f84fe9514970428495b1c5027c51369dcf3d0ab..e0822f9015b67bac6fc5f04821240c031220bc59 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/SSLSocketAppenderBaseTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/AbstractSSLSocketAppenderTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -22,11 +22,11 @@ import ch.qos.logback.core.net.mock.MockContext; import ch.qos.logback.core.spi.PreSerializationTransformer; /** - * Unit tests for {@link SSLSocketAppenderBase}. + * Unit tests for {@link AbstractSSLSocketAppender}. * * @author Carl Harris */ -public class SSLSocketAppenderBaseTest { +public class AbstractSSLSocketAppenderTest { private MockContext context = new MockContext(); @@ -40,13 +40,15 @@ public class SSLSocketAppenderBaseTest { @Test public void testUsingDefaultConfig() throws Exception { - // should be able to start successfully with no SSL configuration at all + // should be able to start and stop successfully with no SSL + // configuration at all appender.start(); assertNotNull(appender.getSocketFactory()); + appender.stop(); } private static class InstrumentedSSLSocketAppenderBase - extends SSLSocketAppenderBase { + extends AbstractSSLSocketAppender { @Override protected void postProcessEvent(Object event) { diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/AbstractSocketAppenderTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/AbstractSocketAppenderTest.java new file mode 100644 index 0000000000000000000000000000000000000000..289a800328ba84d7c69a59f41e9567d1bad3e2ff --- /dev/null +++ b/logback-core/src/test/java/ch/qos/logback/core/net/AbstractSocketAppenderTest.java @@ -0,0 +1,249 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ + +package ch.qos.logback.core.net; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.ObjectInputStream; +import java.io.Serializable; +import java.net.ServerSocket; +import java.net.Socket; +import java.util.List; +import java.util.concurrent.*; + +import ch.qos.logback.core.BasicStatusManager; +import ch.qos.logback.core.status.Status; +import ch.qos.logback.core.status.StatusListener; +import ch.qos.logback.core.status.StatusManager; +import ch.qos.logback.core.util.StatusPrinter; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +import ch.qos.logback.core.net.mock.MockContext; +import ch.qos.logback.core.net.server.ServerSocketUtil; +import ch.qos.logback.core.spi.PreSerializationTransformer; + +/** + * Unit tests for {@link AbstractSocketAppender}. + * + * @author Carl Harris + */ +public class AbstractSocketAppenderTest { + + private static final int DELAY = 10000; + + private ThreadPoolExecutor executorService = (ThreadPoolExecutor) Executors.newCachedThreadPool(); + private MockContext mockContext = new MockContext(executorService); + private InstrumentedSocketAppender instrumentedAppender = new InstrumentedSocketAppender(); + + @Before + public void setUp() throws Exception { + instrumentedAppender.setContext(mockContext); + } + + @After + public void tearDown() throws Exception { + instrumentedAppender.stop(); + assertFalse(instrumentedAppender.isStarted()); + executorService.shutdownNow(); + assertTrue(executorService.awaitTermination(DELAY, TimeUnit.MILLISECONDS)); + } + + @Test + public void appenderShouldFailToStartWithoutValidPort() throws Exception { + instrumentedAppender.setPort(-1); + instrumentedAppender.setRemoteHost("localhost"); + instrumentedAppender.setQueueSize(0); + instrumentedAppender.start(); + assertFalse(instrumentedAppender.isStarted()); + assertTrue(mockContext.getLastStatus().getMessage().contains("port")); + } + + @Test + public void appenderShouldFailToStartWithoutValidRemoteHost() throws Exception { + instrumentedAppender.setPort(1); + instrumentedAppender.setRemoteHost(null); + instrumentedAppender.setQueueSize(0); + instrumentedAppender.start(); + assertFalse(instrumentedAppender.isStarted()); + assertTrue(mockContext.getLastStatus().getMessage().contains("remote host")); + } + + @Test + public void appenderShouldFailToStartWithNegativeQueueSize() throws Exception { + instrumentedAppender.setPort(1); + instrumentedAppender.setRemoteHost("localhost"); + instrumentedAppender.setQueueSize(-1); + instrumentedAppender.start(); + assertFalse(instrumentedAppender.isStarted()); + assertTrue(mockContext.getLastStatus().getMessage().contains("Queue")); + } + + @Test + public void appenderShouldFailToStartWithUnresolvableRemoteHost() throws Exception { + instrumentedAppender.setPort(1); + instrumentedAppender.setRemoteHost("NOT.A.VALID.REMOTE.HOST.NAME"); + instrumentedAppender.setQueueSize(0); + instrumentedAppender.start(); + assertFalse(instrumentedAppender.isStarted()); + assertTrue(mockContext.getLastStatus().getMessage().contains("unknown host")); + } + + @Test + public void appenderShouldFailToStartWithZeroQueueLength() throws Exception { + instrumentedAppender.setPort(1); + instrumentedAppender.setRemoteHost("localhost"); + instrumentedAppender.setQueueSize(0); + instrumentedAppender.start(); + assertTrue(instrumentedAppender.isStarted()); + assertTrue(instrumentedAppender.lastQueue instanceof SynchronousQueue); + } + + @Test + public void appenderShouldStartWithValidParameters() throws Exception { + instrumentedAppender.setPort(1); + instrumentedAppender.setRemoteHost("localhost"); + instrumentedAppender.setQueueSize(1); + instrumentedAppender.start(); + assertTrue(instrumentedAppender.isStarted()); + assertTrue(instrumentedAppender.lastQueue instanceof ArrayBlockingQueue); + assertEquals(1, instrumentedAppender.lastQueue.remainingCapacity()); + } + + // this test takes 1 second and is deemed too long + @Ignore + @Test(timeout = 2000) + public void appenderShouldCleanupTasksWhenStopped() throws Exception { + mockContext.setStatusManager(new BasicStatusManager()); + instrumentedAppender.setPort(1); + instrumentedAppender.setRemoteHost("localhost"); + instrumentedAppender.setQueueSize(1); + instrumentedAppender.start(); + assertTrue(instrumentedAppender.isStarted()); + + waitForActiveCountToEqual(executorService, 2); + instrumentedAppender.stop(); + waitForActiveCountToEqual(executorService, 0); + StatusPrinter.print(mockContext); + assertEquals(0, executorService.getActiveCount()); + + } + + private void waitForActiveCountToEqual(ThreadPoolExecutor executorService, int i) { + while (executorService.getActiveCount() != i) { + try { + Thread.yield(); + Thread.sleep(1); + System.out.print("."); + } catch (InterruptedException e) { + } + } + } + + + @Test + public void testAppendWhenNotStarted() throws Exception { + instrumentedAppender.setRemoteHost("localhost"); + instrumentedAppender.start(); + instrumentedAppender.stop(); + + // make sure the appender task has stopped + executorService.shutdownNow(); + assertTrue(executorService.awaitTermination(DELAY, TimeUnit.MILLISECONDS)); + + instrumentedAppender.append("some event"); + assertTrue(instrumentedAppender.lastQueue.isEmpty()); + } + + @Test + public void testAppendNullEvent() throws Exception { + instrumentedAppender.setRemoteHost("localhost"); + instrumentedAppender.start(); + + instrumentedAppender.append("some event"); + assertTrue(instrumentedAppender.lastQueue.isEmpty()); + } + + @Test + public void testAppendEvent() throws Exception { + instrumentedAppender.setRemoteHost("localhost"); + instrumentedAppender.setQueueSize(1); + instrumentedAppender.start(); + + // stop the appender task, but don't stop the appender + executorService.shutdownNow(); + assertTrue(executorService.awaitTermination(DELAY, TimeUnit.MILLISECONDS)); + + instrumentedAppender.append("some event"); + assertEquals("some event", instrumentedAppender.lastQueue.poll()); + } + + @Test + public void testDispatchEvent() throws Exception { + ServerSocket serverSocket = ServerSocketUtil.createServerSocket(); + instrumentedAppender.setRemoteHost(serverSocket.getInetAddress().getHostAddress()); + instrumentedAppender.setPort(serverSocket.getLocalPort()); + instrumentedAppender.setQueueSize(1); + instrumentedAppender.start(); + + Socket appenderSocket = serverSocket.accept(); + serverSocket.close(); + + instrumentedAppender.append("some event"); + + final int shortDelay = 100; + for (int i = 0, retries = DELAY / shortDelay; + !instrumentedAppender.lastQueue.isEmpty() && i < retries; + i++) { + Thread.sleep(shortDelay); + } + assertTrue(instrumentedAppender.lastQueue.isEmpty()); + + ObjectInputStream ois = new ObjectInputStream(appenderSocket.getInputStream()); + assertEquals("some event", ois.readObject()); + appenderSocket.close(); + + } + + private static class InstrumentedSocketAppender extends AbstractSocketAppender { + + private BlockingQueue lastQueue; + + @Override + protected void postProcessEvent(String event) { + } + + @Override + protected PreSerializationTransformer getPST() { + return new PreSerializationTransformer() { + public Serializable transform(String event) { + return event; + } + }; + } + + @Override + BlockingQueue newBlockingQueue(int queueSize) { + lastQueue = super.newBlockingQueue(queueSize); + return lastQueue; + } + + } + +} diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/SocketConnectorBaseTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/DefaultSocketConnectorTest.java similarity index 58% rename from logback-core/src/test/java/ch/qos/logback/core/net/SocketConnectorBaseTest.java rename to logback-core/src/test/java/ch/qos/logback/core/net/DefaultSocketConnectorTest.java index f43cd3ebfd8fc7cccaa31c30528a5c7426e98cc2..4fc441cccfa517a6b51ecf408d37760690d37884 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/SocketConnectorBaseTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/DefaultSocketConnectorTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,16 +13,16 @@ */ package ch.qos.logback.core.net; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - import java.net.ConnectException; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketAddress; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; @@ -34,25 +34,35 @@ import org.junit.Test; import ch.qos.logback.core.net.SocketConnector.ExceptionHandler; import ch.qos.logback.core.net.server.ServerSocketUtil; +import static junit.framework.Assert.assertNotNull; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + + /** - * Unit tests for {@link SocketConnectorBase}. + * Unit tests for {@link DefaultSocketConnector}. * * @author Carl Harris */ -public class SocketConnectorBaseTest { +public class DefaultSocketConnectorTest { private static final int DELAY = 1000; - + private static final int SHORT_DELAY = 10; + private static final int RETRY_DELAY = 10; + private MockExceptionHandler exceptionHandler = new MockExceptionHandler(); private ServerSocket serverSocket; - private SocketConnectorBase connector; - + private DefaultSocketConnector connector; + + ExecutorService executor = Executors.newSingleThreadExecutor(); + @Before public void setUp() throws Exception { serverSocket = ServerSocketUtil.createServerSocket(); - connector = new SocketConnectorBase(serverSocket.getInetAddress(), - serverSocket.getLocalPort(), 0, DELAY); + connector = new DefaultSocketConnector(serverSocket.getInetAddress(), + serverSocket.getLocalPort(), 0, RETRY_DELAY); connector.setExceptionHandler(exceptionHandler); } @@ -65,53 +75,66 @@ public class SocketConnectorBaseTest { @Test public void testConnect() throws Exception { - Thread thread = new Thread(connector); - thread.start(); - Socket socket = connector.awaitConnection(2 * DELAY); + Future connectorTask = executor.submit(connector); + + Socket socket = connectorTask.get(2 * DELAY, TimeUnit.MILLISECONDS); assertNotNull(socket); - thread.join(DELAY); - assertFalse(thread.isAlive()); + connectorTask.cancel(true); + + assertTrue(connectorTask.isDone()); socket.close(); } @Test public void testConnectionFails() throws Exception { serverSocket.close(); - Thread thread = new Thread(connector); - thread.start(); - Socket socket = connector.awaitConnection(2 * DELAY); - assertNull(socket); + Future connectorTask = executor.submit(connector); + + // this connection attempt will always timeout + try { + connectorTask.get(SHORT_DELAY, TimeUnit.MILLISECONDS); + fail(); + } catch(TimeoutException e) { + } Exception lastException = exceptionHandler.awaitConnectionFailed(DELAY); assertTrue(lastException instanceof ConnectException); - assertTrue(thread.isAlive()); - thread.interrupt(); - thread.join(DELAY); - assertFalse(thread.isAlive()); + assertFalse(connectorTask.isDone()); + connectorTask.cancel(true); + + //thread.join(4 * DELAY); + assertTrue(connectorTask.isCancelled()); } - @Test + @Test(timeout = 5000) public void testConnectEventually() throws Exception { serverSocket.close(); - - Thread thread = new Thread(connector); - thread.start(); - Socket socket = connector.awaitConnection(2 * DELAY); - assertNull(socket); + + Future connectorTask = executor.submit(connector); + // this connection attempt will always timeout + try { + connectorTask.get(SHORT_DELAY, TimeUnit.MILLISECONDS); + fail(); + } catch(TimeoutException e) { + } + + + // on Ceki's machine (Windows 7) this always takes 1second regardless of the value of DELAY Exception lastException = exceptionHandler.awaitConnectionFailed(DELAY); + assertNotNull(lastException); assertTrue(lastException instanceof ConnectException); - assertTrue(thread.isAlive()); - + // now rebind to the same local address SocketAddress address = serverSocket.getLocalSocketAddress(); serverSocket = new ServerSocket(); serverSocket.setReuseAddress(true); serverSocket.bind(address); - + // now we should be able to connect - socket = connector.awaitConnection(2 * DELAY); + Socket socket = connectorTask.get(2 * DELAY, TimeUnit.MILLISECONDS); + assertNotNull(socket); - thread.join(DELAY); - assertFalse(thread.isAlive()); + + assertFalse(connectorTask.isCancelled()); socket.close(); } @@ -130,9 +153,12 @@ public class SocketConnectorBaseTest { throws InterruptedException { lock.lock(); try { - boolean timeout = false; - while (lastException == null && !timeout) { - timeout = !failedCondition.await(delay, TimeUnit.MILLISECONDS); + long increment = 10; + while (lastException == null && delay > 0) { + boolean success = failedCondition.await(increment, TimeUnit.MILLISECONDS); + delay -= increment; + if(success) break; + } return lastException; } diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/PackageTest.java new file mode 100644 index 0000000000000000000000000000000000000000..536d876848b3881e3a97396bd97c3487b9c88adc --- /dev/null +++ b/logback-core/src/test/java/ch/qos/logback/core/net/PackageTest.java @@ -0,0 +1,28 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ + +package ch.qos.logback.core.net; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + + +@RunWith(Suite.class) +@Suite.SuiteClasses({AbstractSocketAppenderTest.class, + DefaultSocketConnectorTest.class, + AbstractSSLSocketAppenderTest.class, + ch.qos.logback.core.net.server.PackageTest.class, + ch.qos.logback.core.net.ssl.PackageTest.class}) +public class PackageTest { +} diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/mock/MockContext.java b/logback-core/src/test/java/ch/qos/logback/core/net/mock/MockContext.java index ef640e4b472fa8291c3fc9e41236b878a73cb1d0..6b2133a5949fc137d634001c3085998ac81f08c4 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/mock/MockContext.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/mock/MockContext.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -14,6 +14,7 @@ package ch.qos.logback.core.net.mock; import java.util.List; +import java.util.concurrent.ExecutorService; import ch.qos.logback.core.Context; import ch.qos.logback.core.ContextBase; @@ -28,13 +29,22 @@ import ch.qos.logback.core.status.StatusManager; */ public class MockContext extends ContextBase { - private final MockStatusManager statusManager = new MockStatusManager(); + private final ExecutorService executorService; private Status lastStatus; + public MockContext() { + this(new MockExecutorService()); + } + + public MockContext(ExecutorService executorService) { + this.setStatusManager(new MockStatusManager()); + this.executorService = executorService; + } + @Override - public StatusManager getStatusManager() { - return statusManager; + public ExecutorService getExecutorService() { + return executorService; } public Status getLastStatus() { diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/mock/MockExecutorService.java b/logback-core/src/test/java/ch/qos/logback/core/net/mock/MockExecutorService.java new file mode 100644 index 0000000000000000000000000000000000000000..443a4da0d92f6e905fbae226786304ecc52819af --- /dev/null +++ b/logback-core/src/test/java/ch/qos/logback/core/net/mock/MockExecutorService.java @@ -0,0 +1,61 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package ch.qos.logback.core.net.mock; + +import java.util.Collections; +import java.util.List; +import java.util.concurrent.AbstractExecutorService; +import java.util.concurrent.TimeUnit; + +/** + * An {@link ExecutorService} with instrumentation for unit testing. + *

+ * This service is synchronous; submitted jobs are run on the calling thread. + * + * @author Carl Harris + */ +public class MockExecutorService extends AbstractExecutorService { + + private Runnable lastCommand; + + public Runnable getLastCommand() { + return lastCommand; + } + + public void shutdown() { + } + + public List shutdownNow() { + return Collections.emptyList(); + } + + public boolean isShutdown() { + return true; + } + + public boolean isTerminated() { + return true; + } + + public boolean awaitTermination(long timeout, TimeUnit unit) + throws InterruptedException { + return true; + } + + public void execute(Runnable command) { + command.run(); + lastCommand = command; + } + +} \ No newline at end of file diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketAppenderBaseTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/AbstractServerSocketAppenderTest.java similarity index 69% rename from logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketAppenderBaseTest.java rename to logback-core/src/test/java/ch/qos/logback/core/net/server/AbstractServerSocketAppenderTest.java index fd8fffa882a17a3cb5266ebfe167a4f20a7e7822..8878075bad83338529d7fcef0eef093fe8aa035f 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketAppenderBaseTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/AbstractServerSocketAppenderTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.core.net.server; import static org.junit.Assert.assertEquals; @@ -27,27 +26,25 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import ch.qos.logback.core.net.mock.MockContext; import ch.qos.logback.core.status.ErrorStatus; import ch.qos.logback.core.status.Status; /** - * Unit tests for {@link ServerSocketAppenderBase}. + * Unit tests for {@link AbstractServerSocketAppender}. * * @author Carl Harris */ -public class ServerSocketAppenderBaseTest { +public class AbstractServerSocketAppenderTest { private MockContext context = new MockContext(); - private MockServerRunner runner = - new MockServerRunner(); - - private MockServerListener listener = - new MockServerListener(); + private MockServerRunner runner = + new MockServerRunner(); - private MockThreadPoolFactoryBean threadPool = - new MockThreadPoolFactoryBean(); + private MockServerListener listener = + new MockServerListener(); private ServerSocket serverSocket; private InstrumentedServerSocketAppenderBase appender; @@ -56,7 +53,6 @@ public class ServerSocketAppenderBaseTest { public void setUp() throws Exception { serverSocket = ServerSocketUtil.createServerSocket(); appender = new InstrumentedServerSocketAppenderBase(serverSocket, listener, runner); - appender.setThreadPool(threadPool); appender.setContext(context); } @@ -69,24 +65,11 @@ public class ServerSocketAppenderBaseTest { public void testStartStop() throws Exception { appender.start(); assertTrue(runner.isContextInjected()); - assertTrue(runner.isStarted()); + assertTrue(runner.isRunning()); assertSame(listener, appender.getLastListener()); appender.stop(); - assertFalse(runner.isStarted()); - } - - @Test - public void testStartThrowsException() throws Exception { - IOException ex = new IOException("test exception"); - runner.setStartException(ex); - appender.start(); - assertFalse(appender.isStarted()); - Status status = context.getLastStatus(); - assertNotNull(status); - assertTrue(status instanceof ErrorStatus); - assertTrue(status.getMessage().contains(ex.getMessage())); - assertSame(ex, status.getThrowable()); + assertFalse(runner.isRunning()); } @Test diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/ConcurrentServerRunnerTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/ConcurrentServerRunnerTest.java index 5044c1568ee0a3485596c65830f1ad1033428483..2924800414d550898c6c29996b443a81805feb1d 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/server/ConcurrentServerRunnerTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/ConcurrentServerRunnerTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -22,20 +22,28 @@ import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Condition; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; import org.junit.After; import org.junit.Before; import org.junit.Test; +import ch.qos.logback.core.net.mock.MockContext; + public class ConcurrentServerRunnerTest { + private static final int DELAY = 10000; + private static final int SHORT_DELAY = 10; + private MockContext context = new MockContext(); private MockServerListener listener = new MockServerListener(); private ExecutorService executor = Executors.newCachedThreadPool(); - private ConcurrentServerRunner runner = + private InstrumentedConcurrentServerRunner runner = new InstrumentedConcurrentServerRunner(listener, executor); @Before @@ -45,75 +53,73 @@ public class ConcurrentServerRunnerTest { @After public void tearDown() throws Exception { - executor.shutdown(); - assertTrue(executor.awaitTermination(2000, TimeUnit.MILLISECONDS)); + executor.shutdownNow(); + assertTrue(executor.awaitTermination(DELAY, TimeUnit.MILLISECONDS)); } @Test public void testStartStop() throws Exception { - assertFalse(runner.isStarted()); - runner.start(); - assertTrue(runner.isStarted()); - int retries = 200; + assertFalse(runner.isRunning()); + executor.execute(runner); + assertTrue(runner.awaitRunState(true, DELAY)); + int retries = DELAY / SHORT_DELAY; synchronized (listener) { while (retries-- > 0 && listener.getWaiter() == null) { - listener.wait(10); + listener.wait(SHORT_DELAY); } } assertNotNull(listener.getWaiter()); runner.stop(); assertTrue(listener.isClosed()); - assertFalse(runner.isStarted()); - executor.shutdown(); - assertTrue(executor.awaitTermination(2000, TimeUnit.MILLISECONDS)); + assertFalse(runner.awaitRunState(false, DELAY)); } @Test public void testRunOneClient() throws Exception { - runner.start(); + executor.execute(runner); MockClient client = new MockClient(); listener.addClient(client); - int retries = 200; + int retries = DELAY / SHORT_DELAY; synchronized (client) { while (retries-- > 0 && !client.isRunning()) { - client.wait(10); + client.wait(SHORT_DELAY); } } - assertTrue(client.isRunning()); + assertTrue(runner.awaitRunState(true, DELAY)); client.close(); runner.stop(); } @Test public void testRunManyClients() throws Exception { - runner.start(); + executor.execute(runner); int count = 10; while (count-- > 0) { MockClient client = new MockClient(); listener.addClient(client); - int retries = 200; + int retries = DELAY / SHORT_DELAY; synchronized (client) { while (retries-- > 0 && !client.isRunning()) { - client.wait(10); + client.wait(SHORT_DELAY); } } - assertTrue(client.isRunning()); + assertTrue(runner.awaitRunState(true, DELAY)); } runner.stop(); } @Test public void testRunClientAndVisit() throws Exception { - runner.start(); + executor.execute(runner); MockClient client = new MockClient(); listener.addClient(client); - int retries = 200; + int retries = DELAY / SHORT_DELAY; synchronized (client) { while (retries-- > 0 && !client.isRunning()) { - client.wait(10); + client.wait(SHORT_DELAY); } } - assertTrue(client.isRunning()); + assertTrue(runner.awaitRunState(true, DELAY)); MockClientVisitor visitor = new MockClientVisitor(); runner.accept(visitor); assertSame(client, visitor.getLastVisited()); @@ -124,6 +130,9 @@ public class ConcurrentServerRunnerTest { static class InstrumentedConcurrentServerRunner extends ConcurrentServerRunner { + private final Lock lock = new ReentrantLock(); + private final Condition runningCondition = lock.newCondition(); + public InstrumentedConcurrentServerRunner( ServerListener listener, Executor executor) { super(listener, executor); @@ -134,6 +143,31 @@ public class ConcurrentServerRunnerTest { return true; } + @Override + protected void setRunning(boolean running) { + lock.lock(); + try { + super.setRunning(running); + runningCondition.signalAll(); + } + finally { + lock.unlock(); + } + } + + public boolean awaitRunState(boolean state, + long delay) throws InterruptedException { + lock.lock(); + try { + while (isRunning() != state) { + runningCondition.await(delay, TimeUnit.MILLISECONDS); + } + return isRunning(); + } + finally { + lock.unlock(); + } + } } } diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/InstrumentedServerSocketAppenderBase.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/InstrumentedServerSocketAppenderBase.java index 19ce4124ff24e77476bbde451b14fcc7ed5485de..1c33dedd139fe205075fb3f56ebd5f3f6c8873ed 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/server/InstrumentedServerSocketAppenderBase.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/InstrumentedServerSocketAppenderBase.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.core.net.server; import java.io.IOException; @@ -25,26 +24,26 @@ import javax.net.ServerSocketFactory; import ch.qos.logback.core.spi.PreSerializationTransformer; /** - * A {@link ServerSocketAppenderBase} with instrumentation for unit testing. + * A {@link AbstractServerSocketAppender} with instrumentation for unit testing. * * @author Carl Harris */ public class InstrumentedServerSocketAppenderBase - extends ServerSocketAppenderBase { + extends AbstractServerSocketAppender { private final ServerSocket serverSocket; - private final ServerListener listener; - private final ServerRunner runner; + private final ServerListener listener; + private final ServerRunner runner; private ServerListener lastListener; public InstrumentedServerSocketAppenderBase(ServerSocket serverSocket) { - this(serverSocket, new RemoteLoggerServerListener(serverSocket), null); + this(serverSocket, new RemoteReceiverServerListener(serverSocket), null); } public InstrumentedServerSocketAppenderBase(ServerSocket serverSocket, - ServerListener listener, - ServerRunner runner) { + ServerListener listener, + ServerRunner runner) { this.serverSocket = serverSocket; this.listener = listener; this.runner = runner; @@ -87,14 +86,14 @@ public class InstrumentedServerSocketAppenderBase } @Override - protected ServerRunner createServerRunner( - ServerListener listener, Executor executor) { + protected ServerRunner createServerRunner( + ServerListener listener, Executor executor) { lastListener = listener; return runner != null ? runner : super.createServerRunner(listener, executor); } @Override - protected ServerListener createServerListener( + protected ServerListener createServerListener( ServerSocket socket) { return listener; } diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockClient.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/MockClient.java index 0b9b5c6a1a64c37fe04b4ab966b44876bf50bef6..0611322733090fc14b7776d0a21adaa8ab79995f 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockClient.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/MockClient.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockClientVisitor.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/MockClientVisitor.java index 0c726688907bc8a5d7ac4340b60301c71111a9fb..417258f902744176b079d23307559b4eb3556016 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockClientVisitor.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/MockClientVisitor.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.core.net.server; /** diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockContext.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/MockContext.java deleted file mode 100644 index d058d0a407282b55c572462a6b9c661fa9d48c11..0000000000000000000000000000000000000000 --- a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockContext.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.core.net.server; - -import java.util.List; - -import ch.qos.logback.core.Context; -import ch.qos.logback.core.ContextBase; -import ch.qos.logback.core.status.Status; -import ch.qos.logback.core.status.StatusListener; -import ch.qos.logback.core.status.StatusManager; - -/** - * A mock {@link Context} with instrumentation for unit testing. - * - * @author Carl Harris - */ -public class MockContext extends ContextBase { - - private final MockStatusManager statusManager = new MockStatusManager(); - - private Status lastStatus; - - @Override - public StatusManager getStatusManager() { - return statusManager; - } - - public Status getLastStatus() { - return lastStatus; - } - - public void setLastStatus(Status lastStatus) { - this.lastStatus = lastStatus; - } - - private class MockStatusManager implements StatusManager { - - public void add(Status status) { - lastStatus = status; - } - - public List getCopyOfStatusList() { - throw new UnsupportedOperationException(); - } - - public int getCount() { - throw new UnsupportedOperationException(); - } - - public void add(StatusListener listener) { - throw new UnsupportedOperationException(); - } - - public void remove(StatusListener listener) { - throw new UnsupportedOperationException(); - } - - public void clear() { - throw new UnsupportedOperationException(); - } - - public List getCopyOfStatusListenerList() { - throw new UnsupportedOperationException(); - } - - } - -} diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockEventQueue.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/MockEventQueue.java index 8c2fbe473f56b81a89500449052af3d786642dfd..6a0cda5943a9b44c449ab2b0ef283df52ebac079 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockEventQueue.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/MockEventQueue.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.core.net.server; import java.io.Serializable; diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockServerListener.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/MockServerListener.java index a86dcb586715af6e44c7f6146ea8f4864cf05daa..b9e444acf771acc6d6e62c95c76009afb03b11f6 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockServerListener.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/MockServerListener.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockServerRunner.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/MockServerRunner.java index 50a9b9a6a870f388c23c24a6861238efc7faaf46..dbea0a464a13884faa3f35e3e594637f88055af5 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockServerRunner.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/MockServerRunner.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -26,7 +26,6 @@ import ch.qos.logback.core.spi.ContextAwareBase; public class MockServerRunner extends ContextAwareBase implements ServerRunner { - private IOException startException; private IOException stopException; private int startCount; private boolean contextInjected; @@ -37,10 +36,7 @@ public class MockServerRunner extends ContextAwareBase super.setContext(context); } - public void start() throws IOException { - if (startException != null) { - throw startException; - } + public void run() { startCount++; } @@ -51,10 +47,10 @@ public class MockServerRunner extends ContextAwareBase startCount--; } - public boolean isStarted() { + public boolean isRunning() { return startCount > 0; } - + public void accept(ClientVisitor visitor) { throw new UnsupportedOperationException(); } @@ -67,10 +63,6 @@ public class MockServerRunner extends ContextAwareBase return contextInjected; } - public void setStartException(IOException startException) { - this.startException = startException; - } - public void setStopException(IOException stopException) { this.stopException = stopException; } diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockThreadPoolFactoryBean.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/MockThreadPoolFactoryBean.java deleted file mode 100644 index 15b4f025d2bc9347b471eaaeca3ec603ec8c8564..0000000000000000000000000000000000000000 --- a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockThreadPoolFactoryBean.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.core.net.server; - -import java.util.Collections; -import java.util.List; -import java.util.concurrent.AbstractExecutorService; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.TimeUnit; - -/** - * A mock {@link ThreadPoolFactoryBean} with instrumentation for unit testing. - * - * @author Carl Harris - */ -class MockThreadPoolFactoryBean extends ThreadPoolFactoryBean { - - private final MockExecutorService executorService = - new MockExecutorService(); - - private Runnable lastCommand; - - @Override - public ExecutorService createExecutor() { - return executorService; - } - - public Runnable getLastCommand() { - return lastCommand; - } - - private class MockExecutorService extends AbstractExecutorService { - - public void shutdown() { - } - - public List shutdownNow() { - return Collections.emptyList(); - } - - public boolean isShutdown() { - return true; - } - - public boolean isTerminated() { - return true; - } - - public boolean awaitTermination(long timeout, TimeUnit unit) - throws InterruptedException { - return true; - } - - public void execute(Runnable command) { - lastCommand = command; - } - - } - -} diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/PackageTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ed814a9f078b6a12baf4495c478824f78302f14a --- /dev/null +++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/PackageTest.java @@ -0,0 +1,27 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package ch.qos.logback.core.net.server; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + + +@RunWith(Suite.class) +@Suite.SuiteClasses({ConcurrentServerRunnerTest.class, + RemoteReceiverStreamClientTest.class, + ServerSocketAppenderBaseFunctionalTest.class, + AbstractServerSocketAppenderTest.class, + SSLServerSocketAppenderBaseTest.class}) +public class PackageTest { +} diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/RemoteLoggerStreamClientTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/RemoteReceiverStreamClientTest.java similarity index 86% rename from logback-core/src/test/java/ch/qos/logback/core/net/server/RemoteLoggerStreamClientTest.java rename to logback-core/src/test/java/ch/qos/logback/core/net/server/RemoteReceiverStreamClientTest.java index bfda209001478f7b4da6fdbbc9349f2ba8628acd..31efe07b62677c4ebd6a1231779f896d0afa2ea5 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/server/RemoteLoggerStreamClientTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/RemoteReceiverStreamClientTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.core.net.server; import static org.junit.Assert.assertEquals; @@ -24,13 +23,15 @@ import java.io.ObjectInputStream; import org.junit.Before; import org.junit.Test; +import ch.qos.logback.core.net.mock.MockContext; + /** - * Unit tests for {@link RemoteLoggerStreamClient}. + * Unit tests for {@link RemoteReceiverStreamClient}. * * @author Carl Harris */ -public class RemoteLoggerStreamClientTest { +public class RemoteReceiverStreamClientTest { private static final String TEST_EVENT = "test event"; @@ -41,8 +42,8 @@ public class RemoteLoggerStreamClientTest { private ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - private RemoteLoggerStreamClient client = - new RemoteLoggerStreamClient("someId", outputStream); + private RemoteReceiverStreamClient client = + new RemoteReceiverStreamClient("someId", outputStream); @Before public void setUp() throws Exception { diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/SSLServerSocketAppenderBaseTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/SSLServerSocketAppenderBaseTest.java index 1c810829b37023cf775929acea27415183e8e9f3..f129cee513befe306cacba6a43da543f2dc53f7a 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/server/SSLServerSocketAppenderBaseTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/SSLServerSocketAppenderBaseTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -15,6 +15,8 @@ package ch.qos.logback.core.net.server; import static org.junit.Assert.assertNotNull; +import java.util.concurrent.Executors; + import org.junit.Before; import org.junit.Test; @@ -28,7 +30,8 @@ import ch.qos.logback.core.spi.PreSerializationTransformer; */ public class SSLServerSocketAppenderBaseTest { - private MockContext context = new MockContext(); + private MockContext context = new MockContext(Executors.newCachedThreadPool()); + private SSLServerSocketAppenderBase appender = new InstrumentedSSLServerSocketAppenderBase(); @@ -42,6 +45,7 @@ public class SSLServerSocketAppenderBaseTest { // should be able to start successfully with no SSL configuration at all appender.start(); assertNotNull(appender.getServerSocketFactory()); + appender.stop(); } private static class InstrumentedSSLServerSocketAppenderBase diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketAppenderBaseFunctionalTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketAppenderBaseFunctionalTest.java index 123628916d1d80c004dafc221f03b2167719dbfa..2f240d1d8f8d822b557c9057439ec3de6d02c917 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketAppenderBaseFunctionalTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketAppenderBaseFunctionalTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.core.net.server; import static org.junit.Assert.assertEquals; @@ -29,8 +28,10 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import ch.qos.logback.core.net.mock.MockContext; + /** - * A functional test for {@link ServerSocketAppenderBase}. + * A functional test for {@link AbstractServerSocketAppender}. * * @author Carl Harris */ @@ -40,9 +41,9 @@ public class ServerSocketAppenderBaseFunctionalTest { private static final int EVENT_COUNT = 10; - private MockContext context = new MockContext(); + private ExecutorService executor = Executors.newCachedThreadPool(); + private MockContext context = new MockContext(executor); private ServerSocket serverSocket; - private ExecutorService executor = Executors.newFixedThreadPool(2); private InstrumentedServerSocketAppenderBase appender; @Before @@ -50,21 +51,14 @@ public class ServerSocketAppenderBaseFunctionalTest { serverSocket = ServerSocketUtil.createServerSocket(); - appender = new InstrumentedServerSocketAppenderBase(serverSocket); - - appender.setThreadPool(new ThreadPoolFactoryBean() { - @Override - public ExecutorService createExecutor() { - return executor; - } - }); - + appender = new InstrumentedServerSocketAppenderBase(serverSocket); appender.setContext(context); } @After public void tearDown() throws Exception { - executor.awaitTermination(1000, TimeUnit.MILLISECONDS); + executor.shutdownNow(); + executor.awaitTermination(10000, TimeUnit.MILLISECONDS); assertTrue(executor.isTerminated()); } diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketListenerTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketListenerTest.java index 359484f84a627175aa3c6c4993cda6726420c511..dbcc84396562a28e073d65bbd69bec0144ee3983 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketListenerTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketListenerTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketUtil.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketUtil.java index 0673a62f1094a08085ec31bfee837591d1058237..3dd87f276a9aa8117f0452c02e11e5663d369c45 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketUtil.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/ThreadPoolFactoryBeanTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/ThreadPoolFactoryBeanTest.java deleted file mode 100644 index 583058079596d6ed0c3802782ba0513f9c02c8ac..0000000000000000000000000000000000000000 --- a/logback-core/src/test/java/ch/qos/logback/core/net/server/ThreadPoolFactoryBeanTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * File created on Apr 8, 2013 - * - * Copyright 2008-2011 Virginia Polytechnic Institute and State University - * - * Licensed 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. - * - */ -package ch.qos.logback.core.net.server; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.SynchronousQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import org.junit.Test; - -/** - * Unit tests for {@link ThreadPoolFactoryBean}. - * - * @author Carl Harris - */ -public class ThreadPoolFactoryBeanTest { - - private ThreadPoolFactoryBean factoryBean = new ThreadPoolFactoryBean(); - - @Test - public void testDefaults() throws Exception { - ThreadPoolExecutor executor = (ThreadPoolExecutor) - factoryBean.createExecutor(); - assertTrue(executor.getQueue() instanceof SynchronousQueue); - assertEquals(ThreadPoolFactoryBean.DEFAULT_CORE_POOL_SIZE, - executor.getCorePoolSize()); - assertEquals(ThreadPoolFactoryBean.DEFAULT_MAXIMUM_POOL_SIZE, - executor.getMaximumPoolSize()); - assertEquals(ThreadPoolFactoryBean.DEFAULT_KEEP_ALIVE_TIME, - executor.getKeepAliveTime(TimeUnit.MILLISECONDS)); - } - - @Test - public void testPositiveQueueSize() throws Exception { - factoryBean.setQueueSize(1); - ThreadPoolExecutor executor = (ThreadPoolExecutor) - factoryBean.createExecutor(); - assertTrue(executor.getQueue() instanceof ArrayBlockingQueue); - assertEquals(factoryBean.getQueueSize(), - ((ArrayBlockingQueue) executor.getQueue()).remainingCapacity()); - } - - @Test(expected = IllegalArgumentException.class) - public void testNegativeQueueSize() throws Exception { - factoryBean.setQueueSize(-1); - factoryBean.createExecutor(); - } - - -} diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/KeyManagerFactoryFactoryBeanTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/KeyManagerFactoryFactoryBeanTest.java index a074f6aa13fce6d48c371269be43a718efc9da0c..4f11220525980990fca4c5266158ea86e8c15320 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/KeyManagerFactoryFactoryBeanTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/KeyManagerFactoryFactoryBeanTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/KeyStoreFactoryBeanTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/KeyStoreFactoryBeanTest.java index f9f1454f4c591c98a50c056d8b03fe9596beb425..a6682f9cc0256d438665e97033bcad9fc95fb1bb 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/KeyStoreFactoryBeanTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/KeyStoreFactoryBeanTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/PackageTest.java new file mode 100644 index 0000000000000000000000000000000000000000..75312b2b0476863479d6f1bf0b3d511792d98497 --- /dev/null +++ b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/PackageTest.java @@ -0,0 +1,32 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ + + +package ch.qos.logback.core.net.ssl; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + + +@RunWith(Suite.class) +@Suite.SuiteClasses({KeyManagerFactoryFactoryBeanTest.class, + KeyStoreFactoryBeanTest.class, + SecureRandomFactoryBeanTest.class, + SSLConfigurationTest.class, + SSLContextFactoryBeanTest.class, + SSLParametersConfigurationTest.class, + TrustManagerFactoryFactoryBeanTest.class}) +public class PackageTest { + +} diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SSLConfigurationTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SSLConfigurationTest.java index 9ab64710a50cb2eb2997302b9c9430e7b74624cf..92132c93f13ac2062e9cf65bd56b71882346eb44 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SSLConfigurationTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SSLConfigurationTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SSLContextFactoryBeanTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SSLContextFactoryBeanTest.java index 4083129179530ec0c7fa667f155c32b5bcdd33b0..47b9e1bc2b26fb41a799092064a5c4eceeb847e4 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SSLContextFactoryBeanTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SSLContextFactoryBeanTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SSLParametersConfigurationTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SSLParametersConfigurationTest.java index f7bbd9dc0ce0e2112a46916fbf9fda1bd539c231..d7c0d9bcadd67b3b511f07636d18f913960a8ab5 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SSLParametersConfigurationTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SSLParametersConfigurationTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SSLTestConstants.java b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SSLTestConstants.java index 1023bbde50ea87cce37d4af6e8e2ee37d52ffc11..07be91fd43f891bf72b4a33c9403ae7e111342b7 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SSLTestConstants.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SSLTestConstants.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SecureRandomFactoryBeanTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SecureRandomFactoryBeanTest.java index b1b0fc7174b023909a0197c9b23e5a38d628fba4..8bf676ad05eb99a7d2b48d91f07999d9b855f03c 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SecureRandomFactoryBeanTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/SecureRandomFactoryBeanTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/TrustManagerFactoryFactoryBeanTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/TrustManagerFactoryFactoryBeanTest.java index 716852beb3d4a150c22bf8f8f2935e09b36a74f4..a066c143f5fdcbdb45905740ad763745bf4f3c42 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/TrustManagerFactoryFactoryBeanTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/TrustManagerFactoryFactoryBeanTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockContextAware.java b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockContextAware.java index b35491b605899afe81df423a10a16a7e44bbd443..fa1803496e7891df4f0b9ee5d211699ac957911e 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockContextAware.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockContextAware.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockKeyManagerFactoryFactoryBean.java b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockKeyManagerFactoryFactoryBean.java index fea9607d33521146a293cb72331949110b881db4..336191386b850a34155b428dfe135638263615eb 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockKeyManagerFactoryFactoryBean.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockKeyManagerFactoryFactoryBean.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockKeyStoreFactoryBean.java b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockKeyStoreFactoryBean.java index c315c73fe84ab2b8002c2bec1ffc24715476e0c0..fee2162723ac906590a667c9b8101eb27faa774c 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockKeyStoreFactoryBean.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockKeyStoreFactoryBean.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockSSLConfigurable.java b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockSSLConfigurable.java index 321a546168a055c10536a404cf13743a7ea5ee48..249851ea3d5eef34fa01b5dd75c93f017146482c 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockSSLConfigurable.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockSSLConfigurable.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.net.ssl.mock; import ch.qos.logback.core.net.ssl.SSLConfigurable; diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockSecureRandomFactoryBean.java b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockSecureRandomFactoryBean.java index a99491954a4c2fdb91bd85f84afc1b0a9a596e8c..2547710e3636a169bebfb9537c54615dd353923d 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockSecureRandomFactoryBean.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockSecureRandomFactoryBean.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockTrustManagerFactoryFactoryBean.java b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockTrustManagerFactoryFactoryBean.java index aa3b19c1c03523f0e59690bab438df54ba971de6..4560c1c1258c7316ef56502ec9ca31fbf4128ccb 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockTrustManagerFactoryFactoryBean.java +++ b/logback-core/src/test/java/ch/qos/logback/core/net/ssl/mock/MockTrustManagerFactoryFactoryBean.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/Converter123.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/Converter123.java index b793b6112b2afae07e2717920f1f15a843590c9b..ff6e5b4d93645e8f3eddf44c738edfa744ebbc96 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/pattern/Converter123.java +++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/Converter123.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/ConverterHello.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/ConverterHello.java index 7b0b96e78d0bbe5e8f3a4b4f320d664fd0522e28..47ec579956a65ed17e4897e1f3b62e2b67370c89 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/pattern/ConverterHello.java +++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/ConverterHello.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/ExceptionalConverter.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/ExceptionalConverter.java index dbe91548f91abd275da4f16da1a14cfc807e19af..b3870da0f627c78bf2c61205520582460a9c6f54 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/pattern/ExceptionalConverter.java +++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/ExceptionalConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/PackageTest.java index c2fc9d75b457e4b05d5c99efa990849654475158..726a968e11586e2f27465b68867d7637fcf7a285 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/pattern/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/SpacePadderTest.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/SpacePadderTest.java index 40745463890005e2429f09688951cb377addd60e..d93af0969ca2fa6ecd2b019c8e8cf6050a374f77 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/pattern/SpacePadderTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/SpacePadderTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/AbstractPatternLayoutBaseTest.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/AbstractPatternLayoutBaseTest.java index 0e50e7243b60d7f46aed619c961de4443ee38313..a264d1000830dc23c090d319c1d2bb7ba66e06a3 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/AbstractPatternLayoutBaseTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/AbstractPatternLayoutBaseTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/CompilerTest.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/CompilerTest.java index 0ebe879171576e4744a504bfdaca2bd057cbaf18..db62e369f72ef7aa262a09725b241bcc76c6db28 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/CompilerTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/CompilerTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/FormatInfoTest.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/FormatInfoTest.java index 8ecd235bdd46c649e1ab228e242e4a0f5e01f98e..9d0f0989ec8bec50bdde0869da13f3da1b0edb83 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/FormatInfoTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/FormatInfoTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/OptionTokenizerTest.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/OptionTokenizerTest.java index 58a3ecb62efc317421936717f5ed7f280373df02..181bbffe1ae8d6e852b256620461a1173ef4bb1e 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/OptionTokenizerTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/OptionTokenizerTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/PackageTest.java index d7d72ef342619e14e3092309553a97c9387e0aed..3329693237dae779ebbd81aea98aa9eeb7f52192 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/ParserTest.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/ParserTest.java index 47d9a30a574f5e2cb34a53879435766137f3b4b6..324c7216400cf65b5025ca15aabd397f5765f565 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/ParserTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/ParserTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/SamplePatternLayout.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/SamplePatternLayout.java index d33e8c06cfab8ec8343dc201e12682349c2aef80..c2f5953594e1f8566a752717dcbc19e8cfe4f57c 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/SamplePatternLayout.java +++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/SamplePatternLayout.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/SamplePatternLayoutTest.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/SamplePatternLayoutTest.java index b4d1b7501056522b3f75ccdbc7ee17901a2ed9da..f77b52c909f1fc4c28caaf25940ac7a3416e3880 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/SamplePatternLayoutTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/SamplePatternLayoutTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/TokenStreamTest.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/TokenStreamTest.java index a3ea09412869e274231456606cebb1f080493eb2..bc7d1260bed4a91afbc5ba75d16cd702519c8b1c 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/TokenStreamTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/TokenStreamTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/read/CyclicBufferAppenderTest.java b/logback-core/src/test/java/ch/qos/logback/core/read/CyclicBufferAppenderTest.java index 60cd7018f881541541c05ce4be6036d7f2eebae6..685e7569ec1ec09fdc3ee790ec529a301ab2c49a 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/read/CyclicBufferAppenderTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/read/CyclicBufferAppenderTest.java @@ -1,7 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * - * Copyright 2013 SURFnet bv, The Netherlands + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/recovery/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/recovery/PackageTest.java index 17b5ae2afe4e3a0a64e53336db28caac4abdc7c8..0f35470c72c798c8fcfdb206111ea5500a90820d 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/recovery/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/recovery/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/recovery/RecoveryCoordinatorTest.java b/logback-core/src/test/java/ch/qos/logback/core/recovery/RecoveryCoordinatorTest.java index 5a02b2b53fd463d5ae92a0ac691ddd5cbd54d71b..91aeeb1b3444d8c55e8f1812827b1f11b2f0eed1 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/recovery/RecoveryCoordinatorTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/recovery/RecoveryCoordinatorTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/recovery/ResilientOutputStreamTest.java b/logback-core/src/test/java/ch/qos/logback/core/recovery/ResilientOutputStreamTest.java index c0696431fac705fb5e941bff8a5190576f129314..559271ab9d91412306d0904ecbfd4defc7af8f83 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/recovery/ResilientOutputStreamTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/recovery/ResilientOutputStreamTest.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.recovery; import ch.qos.logback.core.Context; diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/FileMatchFunction.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/FileMatchFunction.java index 558e4edc38a4520410e1efb2ea0fe5ad02f1182b..3bb6efeb376a4bf0c0340d28eb8abb90b8fcd1d6 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/FileMatchFunction.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/FileMatchFunction.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.rolling; import java.io.File; diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/FileOpener.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/FileOpener.java index d8433818a8e588b09bc6ff4f5940f919b7a9d5b4..b51f8afd652a62f26eb2084eae2bd993cb2a810c 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/FileOpener.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/FileOpener.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/MultiThreadedRollingTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/MultiThreadedRollingTest.java index a0423deb966d0eb53a8fe5ac54697ad029c7e0b8..ab8e6b0bc681bd680e4dfaf4e7b282fe575ab4fe 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/MultiThreadedRollingTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/MultiThreadedRollingTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/PackageTest.java index 90ffa0446cbc621ca4ddc91533cc2528f0c4e7ee..d5c99fcf427e0d697c9afa67adcd5c5948077d61 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/RenameUtilTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/RenameUtilTest.java index 2bc9e553c896eb090d749c3a6e5f8addcc288cce..93a48a0314cf191cc466752551153e10c5ee6e7e 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/RenameUtilTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/RenameUtilTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/RollingFileAppenderTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/RollingFileAppenderTest.java index 5c7b6395ed962084f67db5b954e331b8c898619b..e73b215e48e81cb5d4d462452a30f5897ad54b79 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/RollingFileAppenderTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/RollingFileAppenderTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -204,7 +204,6 @@ public class RollingFileAppenderTest extends AbstractAppenderTest { StatusChecker statusChecker = new StatusChecker(context); final String msg = "File property collides with fileNamePattern. Aborting."; boolean containsMatch = statusChecker.containsMatch(Status.ERROR, msg); - StatusPrinter.print(context); assertTrue("Missing error: " + msg, containsMatch); } diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/ScaffoldingForRollingTests.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/ScaffoldingForRollingTests.java index 7ecc5ace729265967727111c13b6265adfe1cf77..a2580cd8dcf948cf28d26c03b10aa0850b4343b4 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/ScaffoldingForRollingTests.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/ScaffoldingForRollingTests.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -30,6 +30,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Enumeration; import java.util.List; +import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -55,15 +56,16 @@ public class ScaffoldingForRollingTests { EchoEncoder encoder = new EchoEncoder(); Context context = new ContextBase(); protected List expectedFilenameList = new ArrayList(); - protected long nextRolloverThreshold; // initialized in setUp() protected long currentTime; // initialized in setUp() - Calendar cal = Calendar.getInstance(); + protected List> futureList = new ArrayList>(); + + Calendar calendar = Calendar.getInstance(); public void setUp() { context.setName("test"); - cal.set(Calendar.MILLISECOND, 333); - currentTime = cal.getTimeInMillis(); + calendar.set(Calendar.MILLISECOND, 333); + currentTime = calendar.getTimeInMillis(); recomputeRolloverThreshold(currentTime); } @@ -158,16 +160,6 @@ public class ScaffoldingForRollingTests { } - void waitForCompression(TimeBasedRollingPolicy tbrp) { - if (tbrp.future != null && !tbrp.future.isDone()) { - try { - tbrp.future.get(400, TimeUnit.MILLISECONDS); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - protected void addExpectedFileName_ByDate(String patternStr, long millis) { FileNamePattern fileNamePattern = new FileNamePattern(patternStr, context); String fn = fileNamePattern.convert(new Date(millis)); @@ -271,4 +263,21 @@ public class ScaffoldingForRollingTests { assertTrue(firstZipEntry.getName().matches(pattern)); } + protected void add(Future future) { + if (future == null) return; + if (!futureList.contains(future)) { + futureList.add(future); + } + } + + protected void waitForJobsToComplete() { + for (Future future : futureList) { + try { + future.get(10, TimeUnit.SECONDS); + } catch (Exception e) { + new RuntimeException("unexpected exception while testing", e); + } + } + + } } diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_Test.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_Test.java index 60c7e3631082b8096411f4321e7ee9654700a9ee..2f4bb67ec3d60f088b99c1ae700f9afee172d2c2 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_Test.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_Test.java @@ -26,9 +26,6 @@ import java.util.Date; import java.util.List; import java.util.concurrent.ExecutionException; - - - public class SizeAndTimeBasedFNATP_Test extends ScaffoldingForRollingTests { private SizeAndTimeBasedFNATP sizeAndTimeBasedFNATP = null; private RollingFileAppender rfa1 = new RollingFileAppender(); @@ -110,6 +107,7 @@ public class SizeAndTimeBasedFNATP_Test extends ScaffoldingForRollingTests { addExpectedFileNamedIfItsTime(randomOutputDir, testId, msg, compressionSuffix); incCurrentTime(20); tbrp1.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime); + add(tbrp1.future); } if (withSecondPhase) { @@ -120,16 +118,16 @@ public class SizeAndTimeBasedFNATP_Test extends ScaffoldingForRollingTests { if (stem != null) massageExpectedFilesToCorresponToCurrentTarget(file, true); - Thread.sleep(20); + Thread.yield(); // wait for compression to finish - if (tbrp1.future != null) - tbrp1.future.get(); + waitForJobsToComplete(); StatusPrinter.print(context); existenceCheck(expectedFilenameList); sortedContentCheck(randomOutputDir, runLength, prefix); } + void secondPhase(String testId, String file, String stem, String compressionSuffix, int runLength, String prefix) { rfa1.stop(); diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicyTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicyTest.java index 687b3a4a0b9a73958fe3f7c99283ff3cd3f037dc..b73d5caa68a540314c6126885ee2e5b42b203153 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicyTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicyTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicyBaseTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicyBaseTest.java index 500a0aefef4ae299ec84191ec49b13f0ce8931a3..d405f5eb512607afa0f178281ad838bf2e79b509 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicyBaseTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicyBaseTest.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.rolling; import ch.qos.logback.core.Context; diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java index a437438dc4acedb788fcd6c28f188bcaab65ace5..f6b39dacaf350b78ff7815980c8a18fac06f5fda 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java @@ -23,6 +23,7 @@ import org.junit.Test; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.util.concurrent.ExecutionException; /** * A rather exhaustive set of tests. Tests include leaving the file option @@ -98,7 +99,6 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests { void genericTest(String testId, String patternPrefix, String compressionSuffix, boolean fileOptionIsSet, int waitDuration) throws IOException { - boolean withCompression = compressionSuffix.length() > 0; String fileName = fileOptionIsSet ? testId2FileName(testId) : null; initRFA(rfa1, fileName); @@ -117,19 +117,18 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests { addExpectedFileNamedIfItsTime_ByDate(fileNamePatternStr); incCurrentTime(500); tbrp1.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime); - if (withCompression) - waitForCompression(tbrp1); + add(tbrp1.future); } rfa1.stop(); + waitForJobsToComplete(); if (waitDuration != NO_RESTART) { doRestart(testId, patternPrefix, fileOptionIsSet, waitDuration); } + waitForJobsToComplete(); massageExpectedFilesToCorresponToCurrentTarget(fileName, fileOptionIsSet); - StatusPrinter.print(context); - rolloverChecker.check(expectedFilenameList); } @@ -156,6 +155,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests { addExpectedFileNamedIfItsTime_ByDate(filePatternStr); incCurrentTime(100); tbrp2.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime); + add(tbrp2.future); } rfa2.stop(); } @@ -196,7 +196,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests { defaultTest("test6", "test6", ".gz", FILE_OPTION_SET, NO_RESTART); } - // LBCORE-169 + // LOGBACK-168 @Test public void withMissingTargetDirWithCompression() throws IOException { defaultTest("test7", "%d{yyyy-MM-dd, aux}/", ".gz", FILE_OPTION_SET, NO_RESTART); @@ -266,20 +266,20 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests { // } // // } - - // ========================================================================= - // utility methods - // ========================================================================= - - void massageExpectedFilesToCorresponToCurrentTarget(String file) { - // we added one too many files by date - expectedFilenameList.remove(expectedFilenameList.size() - 1); - // since file is set, we have to add it - addExpectedFileName_ByFile(file); - } - - void addExpectedFileName_ByFile(String filenameSuffix) { - String fn = randomOutputDir + filenameSuffix; - expectedFilenameList.add(fn); - } +// +// ========================================================================= +// utility methods +// ========================================================================= +// +// void massageExpectedFilesToCorresponToCurrentTarget(String file) { +// // we added one too many files by date +// expectedFilenameList.remove(expectedFilenameList.size() - 1); +// // since file is set, we have to add it +// addExpectedFileName_ByFile(file); +// } +// +// void addExpectedFileName_ByFile(String filenameSuffix) { +// String fn = randomOutputDir + filenameSuffix; +// expectedFilenameList.add(fn); +// } } diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemoval_Test.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemoval_Test.java index 95625df89addfbf1c4b86f7025b371d356d9fe97..f884810cadfc0d45320592060b1ee22f98f937cc 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemoval_Test.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemoval_Test.java @@ -34,13 +34,11 @@ import static ch.qos.logback.core.CoreConstants.DAILY_DATE_PATTERN; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -public class TimeBasedRollingWithArchiveRemoval_Test { +public class TimeBasedRollingWithArchiveRemoval_Test extends ScaffoldingForRollingTests { String MONTHLY_DATE_PATTERN = "yyyy-MM"; String MONTHLY_CRONOLOG_DATE_PATTERN = "yyyy/MM"; final String DAILY_CRONOLOG_DATE_PATTERN = "yyyy/MM/dd"; - Context context = new ContextBase(); - EchoEncoder encoder = new EchoEncoder(); RollingFileAppender rfa = new RollingFileAppender(); TimeBasedRollingPolicy tbrp = new TimeBasedRollingPolicy(); @@ -48,28 +46,21 @@ public class TimeBasedRollingWithArchiveRemoval_Test { // by default tbfnatp is an instance of DefaultTimeBasedFileNamingAndTriggeringPolicy TimeBasedFileNamingAndTriggeringPolicy tbfnatp = new DefaultTimeBasedFileNamingAndTriggeringPolicy(); - long MILLIS_IN_MINUTE = 60 * 1000; long MILLIS_IN_HOUR = 60 * MILLIS_IN_MINUTE; long MILLIS_IN_DAY = 24 * MILLIS_IN_HOUR; long MILLIS_IN_MONTH = (long) ((365.242199 / 12) * MILLIS_IN_DAY); int MONTHS_IN_YEAR = 12; - int diff; - String randomOutputDir; int slashCount = 0; - long now = System.currentTimeMillis(); - @Before public void setUp() { - context.setName("test"); - diff = RandomUtil.getPositiveInt(); - randomOutputDir = CoreTestConstants.OUTPUT_DIR_PREFIX + diff + "/"; + super.setUp(); } - int computeSlashCount(String datePattern) { + private int computeSlashCount(String datePattern) { if (datePattern == null) return 0; else { @@ -95,10 +86,13 @@ public class TimeBasedRollingWithArchiveRemoval_Test { int maxHistory = 2; String fileNamePattern = randomOutputDir + "/%d{" + MONTHLY_CRONOLOG_DATE_PATTERN + "}/clean.txt.zip"; - long startTime = now; - long endTime = logOverMultiplePeriods(now, fileNamePattern, MILLIS_IN_MONTH, maxHistory, numPeriods, 0, 0); + long startTime = currentTime; + long endTime = logOverMultiplePeriodsContinuously(currentTime, fileNamePattern, MILLIS_IN_MONTH, maxHistory, + numPeriods); + System.out.println("randomOutputDir:" + randomOutputDir); System.out.println("start:" + startTime + ", end=" + endTime); int differenceInMonths = RollingCalendar.diffInMonths(startTime, endTime); + System.out.println("differenceInMonths:" + differenceInMonths); Calendar startTimeAsCalendar = Calendar.getInstance(); startTimeAsCalendar.setTimeInMillis(startTime); int indexOfStartPeriod = startTimeAsCalendar.get(Calendar.MONTH); @@ -111,18 +105,16 @@ public class TimeBasedRollingWithArchiveRemoval_Test { int numInactivityPeriods) { slashCount = computeSlashCount(DAILY_DATE_PATTERN); logOverMultiplePeriods(now, randomOutputDir + "clean-%d{" + DAILY_DATE_PATTERN + "}.txt", MILLIS_IN_DAY, maxHistory, simulatedNumberOfPeriods, startInactivity, numInactivityPeriods); - //StatusPrinter.print(context) check(expectedCountWithoutFoldersWithInactivity(maxHistory, simulatedNumberOfPeriods, startInactivity + numInactivityPeriods)); } - @Test public void basicDailyRollover() { int maxHistory = 20; int simulatedNumberOfPeriods = 20 * 3; int startInactivity = 0; int numInactivityPeriods = 0; - generateDailyRollover(now, maxHistory, simulatedNumberOfPeriods, startInactivity, numInactivityPeriods); + generateDailyRollover(currentTime, maxHistory, simulatedNumberOfPeriods, startInactivity, numInactivityPeriods); } // Since the duration of a month (in seconds) varies from month to month, tests with inactivity period must @@ -133,7 +125,7 @@ public class TimeBasedRollingWithArchiveRemoval_Test { int simulatedNumberOfPeriods = 15; int startInactivity = 6; int numInactivityPeriods = 3; - generateDailyRollover(now, maxHistory, simulatedNumberOfPeriods, startInactivity, numInactivityPeriods); + generateDailyRollover(currentTime, maxHistory, simulatedNumberOfPeriods, startInactivity, numInactivityPeriods); } @Test @@ -142,7 +134,7 @@ public class TimeBasedRollingWithArchiveRemoval_Test { int simulatedNumberOfPeriods = 70; int startInactivity = 30; int numInactivityPeriods = 1; - generateDailyRollover(now, maxHistory, simulatedNumberOfPeriods, startInactivity, numInactivityPeriods); + generateDailyRollover(currentTime, maxHistory, simulatedNumberOfPeriods, startInactivity, numInactivityPeriods); } @Test @@ -151,25 +143,25 @@ public class TimeBasedRollingWithArchiveRemoval_Test { int simulatedNumberOfPeriods = 10; int startInactivity = 3; int numInactivityPeriods = 4; - generateDailyRollover(now, maxHistory, simulatedNumberOfPeriods, startInactivity, numInactivityPeriods); + generateDailyRollover(currentTime, maxHistory, simulatedNumberOfPeriods, startInactivity, numInactivityPeriods); } @Test public void dailyRolloverWithSecondPhase() { slashCount = computeSlashCount(DAILY_DATE_PATTERN); int maxHistory = 5; - long endTime = logOverMultiplePeriods(now, randomOutputDir + "clean-%d{" + DAILY_DATE_PATTERN + "}.txt", - MILLIS_IN_DAY, maxHistory, maxHistory * 2, 0, 0); - logOverMultiplePeriods(endTime + MILLIS_IN_DAY * 10, randomOutputDir + "clean-%d{" + DAILY_DATE_PATTERN + "}.txt", - MILLIS_IN_DAY, maxHistory, maxHistory, 0, 0); + long endTime = logOverMultiplePeriodsContinuously(currentTime, randomOutputDir + "clean-%d{" + DAILY_DATE_PATTERN + "}.txt", + MILLIS_IN_DAY, maxHistory, maxHistory * 2); + logOverMultiplePeriodsContinuously(endTime + MILLIS_IN_DAY * 10, randomOutputDir + "clean-%d{" + DAILY_DATE_PATTERN + "}.txt", + MILLIS_IN_DAY, maxHistory, maxHistory); check(expectedCountWithoutFolders(maxHistory)); } @Test public void dailyCronologRollover() { slashCount = computeSlashCount(DAILY_CRONOLOG_DATE_PATTERN); - logOverMultiplePeriods(now, randomOutputDir + "/%d{" + DAILY_CRONOLOG_DATE_PATTERN + "}/clean.txt.zip", - MILLIS_IN_DAY, 8, 8 * 3, 0, 0); + logOverMultiplePeriodsContinuously(currentTime, randomOutputDir + "/%d{" + DAILY_CRONOLOG_DATE_PATTERN + "}/clean.txt.zip", + MILLIS_IN_DAY, 8, 8 * 3); int expectedDirMin = 9 + slashCount; int expectDirMax = expectedDirMin + 1 + 1; expectedFileAndDirCount(9, expectedDirMin, expectDirMax); @@ -181,8 +173,8 @@ public class TimeBasedRollingWithArchiveRemoval_Test { sizeAndTimeBasedFNATP.setMaxFileSize("10000"); tbfnatp = sizeAndTimeBasedFNATP; slashCount = computeSlashCount(DAILY_DATE_PATTERN); - logOverMultiplePeriods(now, randomOutputDir + "/%d{" + DAILY_DATE_PATTERN + "}-clean.%i.zip", MILLIS_IN_DAY, - 5, 5 * 4, 0, 0); + logOverMultiplePeriodsContinuously(currentTime, randomOutputDir + "/%d{" + DAILY_DATE_PATTERN + "}-clean.%i.zip", MILLIS_IN_DAY, + 5, 5 * 4); checkPatternCompliance(5 + 1 + slashCount, "\\d{4}-\\d{2}-\\d{2}-clean(\\.\\d)(.zip)?"); } @@ -192,8 +184,8 @@ public class TimeBasedRollingWithArchiveRemoval_Test { sizeAndTimeBasedFNATP.setMaxFileSize("10000"); tbfnatp = sizeAndTimeBasedFNATP; slashCount = 1; - logOverMultiplePeriods(now, randomOutputDir + "/%d{" + DAILY_DATE_PATTERN + "}/clean.%i.zip", MILLIS_IN_DAY, - 5, 5 * 4, 0, 0); + logOverMultiplePeriodsContinuously(currentTime, randomOutputDir + "/%d{" + DAILY_DATE_PATTERN + "}/clean.%i.zip", MILLIS_IN_DAY, + 5, 5 * 4); checkDirPatternCompliance(6); } @@ -205,25 +197,25 @@ public class TimeBasedRollingWithArchiveRemoval_Test { slashCount = 1; int maxHistory = 5; int simulatedNumberOfPeriods = maxHistory * 4; - long endTime = logOverMultiplePeriods(now, randomOutputDir + "/%d{" + DAILY_DATE_PATTERN + "}/clean.%i", MILLIS_IN_DAY, - maxHistory, 3, 0, 0); - logOverMultiplePeriods(endTime + MILLIS_IN_DAY * 7, randomOutputDir + "/%d{" + DAILY_DATE_PATTERN + "}/clean.%i", - MILLIS_IN_DAY, maxHistory, simulatedNumberOfPeriods, 0, 0); + long endTime = logOverMultiplePeriodsContinuously(currentTime, randomOutputDir + "/%d{" + DAILY_DATE_PATTERN + "}/clean.%i", MILLIS_IN_DAY, + maxHistory, 3); + logOverMultiplePeriodsContinuously(endTime + MILLIS_IN_DAY * 7, randomOutputDir + "/%d{" + DAILY_DATE_PATTERN + "}/clean.%i", + MILLIS_IN_DAY, maxHistory, simulatedNumberOfPeriods); checkDirPatternCompliance(maxHistory + 1); } - void logOncePeriod(long currentTime, String fileNamePattern, int maxHistory) { - buildRollingFileAppender(currentTime, fileNamePattern, maxHistory, true); + void logOncePeriod(long currentTime, String fileNamePattern, int maxHistory) { + buildRollingFileAppender(currentTime, fileNamePattern, maxHistory, DO_CLEAN_HISTORY_ON_START); rfa.doAppend("Hello ----------------------------------------------------------" + new Date(currentTime)); rfa.stop(); } @Test public void cleanHistoryOnStart() { - long now = this.now; - String fileNamePattern = randomOutputDir + "clean-%d{" + DAILY_DATE_PATTERN + "}.txt" ; - int maxHistory = 3 ; + long now = this.currentTime; + String fileNamePattern = randomOutputDir + "clean-%d{" + DAILY_DATE_PATTERN + "}.txt"; + int maxHistory = 3; for (int i = 0; i <= 5; i++) { logOncePeriod(now, fileNamePattern, maxHistory); now = now + MILLIS_IN_DAY; @@ -233,7 +225,6 @@ public class TimeBasedRollingWithArchiveRemoval_Test { } - int expectedCountWithoutFolders(int maxHistory) { return maxHistory + 1; } @@ -268,10 +259,16 @@ public class TimeBasedRollingWithArchiveRemoval_Test { boolean DO_NOT_CLEAN_HISTORY_ON_START = false; - long logOverMultiplePeriods(long currentTime, String fileNamePattern, long periodDurationInMillis, int maxHistory, + long logOverMultiplePeriodsContinuously(long simulatedTime, String fileNamePattern, long periodDurationInMillis, int maxHistory, + int simulatedNumberOfPeriods) { + return logOverMultiplePeriods(simulatedTime, fileNamePattern, periodDurationInMillis, maxHistory, + simulatedNumberOfPeriods, 0, 0); + } + + long logOverMultiplePeriods(long simulatedTime, String fileNamePattern, long periodDurationInMillis, int maxHistory, int simulatedNumberOfPeriods, int startInactivity, int numInactivityPeriods) { - buildRollingFileAppender(currentTime, fileNamePattern, maxHistory, DO_NOT_CLEAN_HISTORY_ON_START); + buildRollingFileAppender(simulatedTime, fileNamePattern, maxHistory, DO_NOT_CLEAN_HISTORY_ON_START); int ticksPerPeriod = 512; int runLength = simulatedNumberOfPeriods * ticksPerPeriod; int startInactivityIndex = 1 + startInactivity * ticksPerPeriod; @@ -282,36 +279,22 @@ public class TimeBasedRollingWithArchiveRemoval_Test { if (i < startInactivityIndex || i > endInactivityIndex) { rfa.doAppend("Hello ----------------------------------------------------------" + i); } - tbrp.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(addTime(tbrp.timeBasedFileNamingAndTriggeringPolicy.getCurrentTime(), tickDuration)); - if (i % (ticksPerPeriod / 2) == 0) { - waitForCompression(tbrp); - } + tbrp.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(addTime(tbrp.timeBasedFileNamingAndTriggeringPolicy.getCurrentTime(), + tickDuration)); + add(tbrp.future); + waitForJobsToComplete(); } - - //println("Last date" + new Date(tbrp.timeBasedFileNamingAndTriggeringPolicy.getCurrentTime())); - waitForCompression(tbrp); rfa.stop(); return tbrp.timeBasedFileNamingAndTriggeringPolicy.getCurrentTime(); } boolean extraFolder(int numPeriods, int periodsPerEra, int beginPeriod, int maxHistory) { - //println("numPeriods=" + numPeriods + ", beginPeriod=" + beginPeriod + ", maxHistory=" + maxHistory) int valueOfLastMonth = ((beginPeriod) + numPeriods) % periodsPerEra; return (valueOfLastMonth < maxHistory); } - long addTime(long currentTime, long timeToWait) { - return currentTime + timeToWait; - } - - void waitForCompression(TimeBasedRollingPolicy tbrp) { - if (tbrp.future != null && !tbrp.future.isDone()) { - try { - tbrp.future.get(1000, TimeUnit.MILLISECONDS); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + long addTime(long time, long timeToWait) { + return time + timeToWait; } diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/ZRolloverChecker.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/ZRolloverChecker.java index 29dd24d74b55f681e67a5acf37a8818411f5bce9..c8d4070a1bb83eb40a796c124d23c38b110dccfb 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/ZRolloverChecker.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/ZRolloverChecker.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.rolling; diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java index 0704a25b93c6a025d2d31464d3414b27237b4bd8..bce93f77b893165b86925f58fbfc50151790bff9 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileNamePatternTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileNamePatternTest.java index da2390dad098520bc3bb7527086040a00729b0db..f38dae10392e2a99294f3724dbc67cedae2ec5f0 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileNamePatternTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileNamePatternTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileStoreUtilTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileStoreUtilTest.java index 0df5e7aa5f8b63947870f6b11649cfab5850ca6b..dceab740f1ba97f155395652faef6ac5e8e6c54b 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileStoreUtilTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileStoreUtilTest.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.rolling.helper; import ch.qos.logback.core.rolling.RolloverFailure; diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/PackageTest.java index adb683345659b7ae16a175bd8887173e0436b813..d9b1d7a3a77ebdb3cc3b0fa88650360c2a88e9e2 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/RollingCalendarTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/RollingCalendarTest.java index 8b44ac1e15dc3f8fb8c5a2e9ad07d72b604cc3cf..b840f43bff2b4684b069808e120cc258cf11ffc8 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/RollingCalendarTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/RollingCalendarTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/sift/AppenderTrackerTest.java b/logback-core/src/test/java/ch/qos/logback/core/sift/AppenderTrackerTest.java index 59ac610e591219d8073ab0139d88a7ddac318833..88b56d104ad76d91da05e9cf7df6274b732b6fec 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/sift/AppenderTrackerTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/sift/AppenderTrackerTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,68 +13,141 @@ */ package ch.qos.logback.core.sift; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Before; -import org.junit.Test; - +import ch.qos.logback.core.Appender; import ch.qos.logback.core.Context; import ch.qos.logback.core.ContextBase; +import ch.qos.logback.core.joran.spi.JoranException; import ch.qos.logback.core.read.ListAppender; +import ch.qos.logback.core.testUtil.RandomUtil; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; +/** + * Relatively straightforward unit tests for AppenderTracker. + */ public class AppenderTrackerTest { - Context context = new ContextBase(); - AppenderTracker appenderTracker = new AppenderTrackerImpl(); - ListAppender la = new ListAppender(); - String key = "a"; - + ListAppenderFactory listAppenderFactory = new ListAppenderFactory(); + int diff = RandomUtil.getPositiveInt(); + AppenderTracker appenderTracker = new AppenderTracker(context, listAppenderFactory); + String key = "k-" + diff; + long now = 3000; + @Before public void setUp() { - la.setContext(context); - la.start(); } - @Test - public void empty0() { - long now = 3000; - appenderTracker.stopStaleAppenders(now); - assertEquals(0, appenderTracker.keyList().size()); + public void removeStaleComponentsShouldNotBomb() { + appenderTracker.removeStaleComponents(now); + assertEquals(0, appenderTracker.getComponentCount()); } - + @Test - public void empty1() { - long now = 3000; - assertNull(appenderTracker.get(key, now++)); - now += AppenderTrackerImpl.THRESHOLD+1000; - appenderTracker.stopStaleAppenders(now); - assertNull(appenderTracker.get(key, now++)); + public void findingTheInexistentShouldNotBomb() { + assertNull(appenderTracker.find(key)); + now += AppenderTracker.DEFAULT_TIMEOUT + 1; + appenderTracker.removeStaleComponents(now); + assertNull(appenderTracker.find(key)); } - + @Test public void smoke() { - assertTrue(la.isStarted()); - long now = 3000; - appenderTracker.put(key, la, now); - assertEquals(la, appenderTracker.get(key, now++)); - now += AppenderTrackerImpl.THRESHOLD+1000; - appenderTracker.stopStaleAppenders(now); - assertFalse(la.isStarted()); - assertNull(appenderTracker.get(key, now++)); + Appender a = appenderTracker.getOrCreate(key, now); + assertTrue(a.isStarted()); + now += AppenderTracker.DEFAULT_TIMEOUT + 1; + appenderTracker.removeStaleComponents(now); + assertFalse(a.isStarted()); + assertNull(appenderTracker.find(key)); + } + + @Test + public void endOfLivedAppendersShouldBeRemovedAfterLingeringTimeout() { + Appender a = appenderTracker.getOrCreate(key, now); + appenderTracker.endOfLife(key); + now += AppenderTracker.LINGERING_TIMEOUT + 1; + appenderTracker.removeStaleComponents(now); + assertFalse(a.isStarted()); + a = appenderTracker.find(key); + assertNull(a); } - + + @Test + public void endOfLivedAppenderShouldBeAvailableDuringLingeringPeriod() { + Appender a = appenderTracker.getOrCreate(key, now); + appenderTracker.endOfLife(key); + // clean + appenderTracker.removeStaleComponents(now); + Appender lingering = appenderTracker.getOrCreate(key, now); + assertTrue(lingering.isStarted()); + assertTrue(a == lingering); + now += AppenderTracker.LINGERING_TIMEOUT + 1; + appenderTracker.removeStaleComponents(now); + assertFalse(a.isStarted()); + a = appenderTracker.find(key); + assertNull(a); + } + + + @Test + public void trackerShouldHonorMaxComponentsParameter() { + List> appenderList = new ArrayList>(); + int max = 10; + appenderTracker.setMaxComponents(max); + for (int i = 0; i < (max + 1); i++) { + Appender a = appenderTracker.getOrCreate(key + "-" + i, now++); + appenderList.add(a); + } + // cleaning only happens in removeStaleComponents + appenderTracker.removeStaleComponents(now++); + assertEquals(max, appenderTracker.allKeys().size()); + assertNull(appenderTracker.find(key + "-" + 0)); + assertFalse(appenderList.get(0).isStarted()); + } + @Test - public void removeNow() { - long now = 3000; - appenderTracker.put(key, la, now); - appenderTracker.stopAndRemoveNow(key); - assertFalse(la.isStarted()); - appenderTracker.get(key, now++); - assertNull(appenderTracker.get(key, now++)); - } + public void trackerShouldHonorTimeoutParameter() { + List> appenderList = new ArrayList>(); + int timeout = 2; + appenderTracker.setTimeout(timeout); + for (int i = 0; i <= timeout; i++) { + Appender a = appenderTracker.getOrCreate(key + "-" + i, now++); + appenderList.add(a); + } + + long numComponentsCreated = timeout + 1; + assertEquals(numComponentsCreated, appenderTracker.allKeys().size()); + + // cleaning only happens in removeStaleComponents. The first appender should timeout + appenderTracker.removeStaleComponents(now++); + + // the first appender should have been removed + assertEquals(numComponentsCreated - 1, appenderTracker.allKeys().size()); + assertNull(appenderTracker.find(key + "-" + 0)); + assertFalse(appenderList.get(0).isStarted()); + + // the other appenders should be in the tracker + for (int i = 1; i <= timeout; i++) { + assertNotNull(appenderTracker.find(key + "-" + i)); + assertTrue(appenderList.get(i).isStarted()); + } + } + + // ====================================================================== + static class ListAppenderFactory implements AppenderFactory { + + public Appender buildAppender(Context context, String discriminatingValue) throws JoranException { + ListAppender la = new ListAppender(); + la.setContext(context); + la.setName(discriminatingValue); + la.start(); + return la; + } + } } diff --git a/logback-core/src/test/java/ch/qos/logback/core/sift/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/sift/PackageTest.java index b68877e53693b2551a5a732c1eaf7f87cb7cdf1b..f604c4c19e00bae328d0bbb0e4ee88decce66f40 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/sift/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/sift/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -18,6 +18,6 @@ import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) -@SuiteClasses({AppenderTrackerTest.class, ScenarioBasedAppenderTrackerTest.class}) +@SuiteClasses({AppenderTrackerTest.class}) public class PackageTest { } \ No newline at end of file diff --git a/logback-core/src/test/java/ch/qos/logback/core/sift/ScenarioBasedAppenderTrackerTest.java b/logback-core/src/test/java/ch/qos/logback/core/sift/ScenarioBasedAppenderTrackerTest.java deleted file mode 100644 index a6ee9d0f87b9e5088eca8ddcb0a2c89cc19bb441..0000000000000000000000000000000000000000 --- a/logback-core/src/test/java/ch/qos/logback/core/sift/ScenarioBasedAppenderTrackerTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.core.sift; - -import static org.junit.Assert.assertEquals; - -import org.junit.Ignore; -import org.junit.Test; - -public class ScenarioBasedAppenderTrackerTest { - - Simulator simulator; - - int INVERSE_OF_NO_REMOVE = Integer.MAX_VALUE; - - - void verify() { - AppenderTracker at = simulator.realAppenderTracker; - AppenderTracker t_at = simulator.t_appenderTracker; - assertEquals(t_at.keyList(), at.keyList()); - } - - @Test - public void shortTest() { - simulator = new Simulator(20, AppenderTracker.THRESHOLD / 2, INVERSE_OF_NO_REMOVE); - simulator.buildScenario(200); - simulator.simulate(); - verify(); - } - - - @Test - public void shortTestWithRemovals() { - simulator = new Simulator(10, AppenderTracker.THRESHOLD / 10, 2); - simulator.buildScenario(200); - simulator.simulate(); - verify(); - } - - @Test - public void mediumTest() { - simulator = new Simulator(100, AppenderTracker.THRESHOLD / 2, INVERSE_OF_NO_REMOVE); - simulator.buildScenario(20000); - simulator.simulate(); - verify(); - } - - @Test - public void mediumTestWithRemovals() { - simulator = new Simulator(10, AppenderTracker.THRESHOLD / 100, 2); - simulator.buildScenario(20000); - simulator.simulate(); - verify(); - } - - @Test - @Ignore - public void longTest() { - simulator = new Simulator(100, AppenderTracker.THRESHOLD / 200, 10); - simulator.buildScenario(2000000); - simulator.simulate(); - verify(); - } -} diff --git a/logback-core/src/test/java/ch/qos/logback/core/sift/Simulator.java b/logback-core/src/test/java/ch/qos/logback/core/sift/Simulator.java deleted file mode 100644 index b9168cb2414dd305a6d5faa55ff340b126248df0..0000000000000000000000000000000000000000 --- a/logback-core/src/test/java/ch/qos/logback/core/sift/Simulator.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.core.sift; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; - -import ch.qos.logback.core.Appender; -import ch.qos.logback.core.helpers.NOPAppender; -import ch.qos.logback.core.sift.tracker.AppenderTrackerTImpl; -import ch.qos.logback.core.sift.tracker.SimulationEvent; -import ch.qos.logback.core.sift.tracker.SimulationEvent.SimEventType; - -/** - * Simulate use of AppenderTracker by SiftingAppender. - * - * @author ceki - * - */ -public class Simulator { - - AppenderTrackerImpl realAppenderTracker = new AppenderTrackerImpl(); - AppenderTrackerTImpl t_appenderTracker = new AppenderTrackerTImpl(); - - List keySpace = new ArrayList(); - List scenario = new ArrayList(); - Random randomKeyGen = new Random(100); - - Random random = new Random(11234); - - final int maxTimestampInc; - final int inverseOfRemoveProbability; - - Simulator(int keySpaceLen, int maxTimestampInc, int inverseOfRemoveProbability) { - this.maxTimestampInc = maxTimestampInc; - this.inverseOfRemoveProbability = inverseOfRemoveProbability; - Map checkMap = new HashMap(); - for (int i = 0; i < keySpaceLen; i++) { - String k = getRandomKeyStr(); - if (checkMap.containsKey(k)) { - System.out.println("random key collision occured"); - k += "" + i; - } - keySpace.add(k); - checkMap.put(k, k); - } - - } - - private String getRandomKeyStr() { - int ri = randomKeyGen.nextInt(); - return String.format("%X", ri); - } - - void buildScenario(int simLen) { - long timestamp = 30000; - int keySpaceLen = keySpace.size(); - for (int i = 0; i < simLen; i++) { - int index = random.nextInt(keySpaceLen); - timestamp += random.nextInt(maxTimestampInc); - String key = keySpace.get(index); - SimEventType eventType = SimEventType.PUT; - - int removeNow = random.nextInt(inverseOfRemoveProbability); - if (removeNow == 0) { - eventType = SimEventType.REMOVE_NOW; - } - scenario.add(new SimulationEvent(eventType, key, timestamp)); - } - } - - void dump() { - for (SimulationEvent simeEvent : scenario) { - System.out.println(simeEvent); - } - } - - public void simulate() { - for (SimulationEvent simeEvent : scenario) { - play(simeEvent, realAppenderTracker); - play(simeEvent, t_appenderTracker); - } - } - - void play(SimulationEvent simulationEvent, - AppenderTracker appenderTracker) { - String key = simulationEvent.key; - long timestamp = simulationEvent.timestamp; - - switch (simulationEvent.simEventType) { - case PUT: - doPut(appenderTracker, key, timestamp); - break; - case REMOVE_NOW: - doRemoveNow(appenderTracker, key); - break; - } - - } - - void doPut(AppenderTracker appenderTracker, String key, long timestamp) { - Appender appender = appenderTracker.get(key, timestamp); - if (appender == null) { - appender = new NOPAppender(); - appender.start(); - appenderTracker.put(key, appender, timestamp); - } - appenderTracker.stopStaleAppenders(timestamp); - } - - int i = 0; - - void doRemoveNow(AppenderTracker appenderTracker, String key) { - // System.out.println("doRemoveNow "+(i++)); - appenderTracker.stopAndRemoveNow(key); - } - -} diff --git a/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/AppenderTrackerTImpl.java b/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/AppenderTrackerTImpl.java deleted file mode 100644 index 4e118d3534a7220eb512f930e42f9a33241fc21c..0000000000000000000000000000000000000000 --- a/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/AppenderTrackerTImpl.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.core.sift.tracker; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -import ch.qos.logback.core.Appender; -import ch.qos.logback.core.CoreConstants; -import ch.qos.logback.core.sift.AppenderTracker; - -/** - * This is an alternative (slower) implementation of AppenderTracker for testing - * purposes. - * - * @author Ceki Gulcu - */ -public class AppenderTrackerTImpl implements AppenderTracker { - - List entryList = new LinkedList(); - long lastCheck = 0; - - @SuppressWarnings("unchecked") - synchronized public void put(String k, Appender appender, - long timestamp) { - TEntry te = getEntry(k); - if (te != null) { - te.timestamp = timestamp; - } else { - te = new TEntry(k, appender, timestamp); - entryList.add(te); - } - Collections.sort(entryList); - } - - @SuppressWarnings("unchecked") - synchronized public Appender get(String k, long timestamp) { - TEntry te = getEntry(k); - if (te == null) { - return null; - } else { - te.timestamp = timestamp; - Collections.sort(entryList); - return te.appender; - } - } - - synchronized public void stopStaleAppenders(long timestamp) { - if (lastCheck + CoreConstants.MILLIS_IN_ONE_SECOND > timestamp) { - return; - } - lastCheck = timestamp; - while (entryList.size() != 0 && isEntryStale(entryList.get(0), timestamp)) { - entryList.remove(0); - } - } - - synchronized public void stopAndRemoveNow(String key) { - TEntry found = null; - for (TEntry te : entryList) { - if (key.equals(te.key)) { - found = te; - break; - } - } - if (found != null) { - entryList.remove(found); - } - - } - - private boolean isEntryStale(TEntry entry, long now) { - return ((entry.timestamp + THRESHOLD) < now); - } - - synchronized public List keyList() { - List keyList = new ArrayList(); - for (TEntry e : entryList) { - keyList.add(e.key); - } - return keyList; - } - - synchronized public List> valueList() { - List> appenderList = new ArrayList>(); - for (TEntry e : entryList) { - appenderList.add(e.appender); - } - return appenderList; - } - - private TEntry getEntry(String k) { - for (int i = 0; i < entryList.size(); i++) { - TEntry te = entryList.get(i); - if (te.key.equals(k)) { - return te; - } - } - return null; - } -} diff --git a/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/SimulationEvent.java b/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/SimulationEvent.java deleted file mode 100644 index 2e786732ce7761646639e95057050c4ab32835cf..0000000000000000000000000000000000000000 --- a/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/SimulationEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.core.sift.tracker; - - -public class SimulationEvent { - - public enum SimEventType { - PUT, REMOVE_NOW; - } - - final public String key; - final public long timestamp; - final public SimEventType simEventType; - - public SimulationEvent(SimEventType simEventType, String key, long timestamp) { - this.simEventType = simEventType; - this.key = key; - this.timestamp = timestamp; - } - - public String toString() { - return "Type: "+simEventType+", Event: k=" + key +", timestamp=" + timestamp; - } -} diff --git a/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/TEntry.java b/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/TEntry.java deleted file mode 100644 index f470d4ed9c7209b451d64985fd7a8d346e2fef60..0000000000000000000000000000000000000000 --- a/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/TEntry.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.core.sift.tracker; - -import ch.qos.logback.core.Appender; - -public class TEntry implements Comparable { - - String key; - long timestamp; - Appender appender; - - TEntry(String key, Appender appender, long timestamp) { - this.key = key; - this.appender = appender; - this.timestamp = timestamp; - } - - public int compareTo(Object o) { - if(!(o instanceof TEntry)) { - throw new IllegalArgumentException("arguments must be of type "+TEntry.class); - } - - TEntry other = (TEntry) o; - if(timestamp > other.timestamp) { - return 1; - } - if(timestamp == other.timestamp) { - return 0; - } - return -1; - } - - @Override - public String toString() { - return "("+key+","+timestamp+")"; - } -} diff --git a/logback-core/src/test/java/ch/qos/logback/core/spi/AppenderAttachableImplLockTest.java b/logback-core/src/test/java/ch/qos/logback/core/spi/AppenderAttachableImplLockTest.java index 0f8ac13848472533fa924a544766ca1d3cd3fab9..44cba533e38ebf2451d157eb3ac8882f9f50203e 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/spi/AppenderAttachableImplLockTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/spi/AppenderAttachableImplLockTest.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.spi; import ch.qos.logback.core.Appender; diff --git a/logback-core/src/test/java/ch/qos/logback/core/spi/AppenderAttachableImplTest.java b/logback-core/src/test/java/ch/qos/logback/core/spi/AppenderAttachableImplTest.java index b070382d9f082b86f1e1150fb7ac26cb54fd185e..3fa46cd3d1dea593512b040be87c20f001d0e36b 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/spi/AppenderAttachableImplTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/spi/AppenderAttachableImplTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerSimulator.java b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerSimulator.java old mode 100644 new mode 100755 index e52129518f105df5a2c140b5d29e21b8941a83e6..c62187ad7b122bc51ff67f394a36f2a60d9fdcd9 --- a/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerSimulator.java +++ b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerSimulator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,6 +13,8 @@ */ package ch.qos.logback.core.spi; +import ch.qos.logback.core.helpers.CyclicBuffer; + import java.util.*; /** @@ -20,21 +22,27 @@ import java.util.*; */ public class CyclicBufferTrackerSimulator { - CyclicBufferTrackerImpl realCBTracker = new CyclicBufferTrackerImpl(); - CyclicBufferTracker_TImpl t_CBTracker = new CyclicBufferTracker_TImpl(); + static class Parameters { + public int keySpaceLen; + public int maxTimestampInc; + public int simulationLength; + } + + CyclicBufferTracker realCBTracker = new CyclicBufferTracker(); + CyclicBufferTrackerT t_CBTracker = new CyclicBufferTrackerT(); List scenario = new ArrayList(); List keySpace = new ArrayList(); - int maxTimestampInc; Random randomKeyGen = new Random(100); Random simulatorRandom = new Random(11234); + Parameters params; - int deleteToInsertRatio = 10; + int getToEndOfLifeRatio = 10; - CyclicBufferTrackerSimulator(int keySpaceLen, int maxTimestampInc) { - this.maxTimestampInc = maxTimestampInc; + CyclicBufferTrackerSimulator(Parameters params) { + this.params = params; Map checkMap = new HashMap(); - for (int i = 0; i < keySpaceLen; i++) { + for (int i = 0; i < params.keySpaceLen; i++) { String k = getRandomKeyStr(); if (checkMap.containsKey(k)) { System.out.println("random key collision occurred"); @@ -51,19 +59,18 @@ public class CyclicBufferTrackerSimulator { return String.format("%X", ri); } - void buildScenario(int simLen) { + void buildScenario() { long timestamp = 30000; int keySpaceLen = keySpace.size(); - for (int i = 0; i < simLen; i++) { - int index = simulatorRandom.nextInt(keySpaceLen); - timestamp += simulatorRandom.nextInt(maxTimestampInc); - EventType eventType = EventType.INSERT; - if (simulatorRandom.nextInt(deleteToInsertRatio) == 0) { - eventType = EventType.DELETE; + for (int i = 0; i < params.simulationLength; i++) { + int keyIndex = simulatorRandom.nextInt(keySpaceLen); + timestamp += simulatorRandom.nextInt(params.maxTimestampInc); + String key = keySpace.get(keyIndex); + scenario.add(new SimulationEvent(EventType.INSERT, key, timestamp)); + if (simulatorRandom.nextInt(getToEndOfLifeRatio) == 0) { + scenario.add(new SimulationEvent(EventType.END_OF_LIFE, key, timestamp)); } - - String key = keySpace.get(index); - scenario.add(new SimulationEvent(eventType, key, timestamp)); + scenario.add(new SimulationEvent(EventType.REMOVE_STALE, key, timestamp)); } } @@ -75,7 +82,7 @@ public class CyclicBufferTrackerSimulator { void play(SimulationEvent simulationEvent, - CyclicBufferTracker tracker) { + ComponentTracker> tracker) { String key = simulationEvent.key; long timestamp = simulationEvent.timestamp; EventType eventType = simulationEvent.eventType; @@ -83,8 +90,11 @@ public class CyclicBufferTrackerSimulator { case INSERT: tracker.getOrCreate(key, timestamp); break; - case DELETE: - tracker.removeBuffer(key); + case END_OF_LIFE: + tracker.endOfLife(key); + break; + case REMOVE_STALE: + tracker.removeStaleComponents(timestamp); break; } } @@ -98,7 +108,7 @@ public class CyclicBufferTrackerSimulator { // ========================================================================= enum EventType { - INSERT, DELETE; + INSERT, END_OF_LIFE, REMOVE_STALE; } class SimulationEvent { @@ -112,8 +122,13 @@ public class CyclicBufferTrackerSimulator { this.timestamp = timestamp; } + @Override public String toString() { - return "Event: k=" + key + ", timestamp=" + timestamp; + return "SimulationEvent{" + + "eventType=" + eventType + + ", key='" + key + '\'' + + ", timestamp=" + timestamp + + '}'; } } } diff --git a/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerT.java b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerT.java new file mode 100644 index 0000000000000000000000000000000000000000..c705b44f26d7b8686eb7372223d4d82bbaa5c6df --- /dev/null +++ b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerT.java @@ -0,0 +1,246 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package ch.qos.logback.core.spi; + +import ch.qos.logback.core.CoreConstants; +import ch.qos.logback.core.helpers.CyclicBuffer; + +import java.util.*; + +/** + * Another tracker implementtion for testing purposes only. + * + * @author Ceki Gücü + */ +public class CyclicBufferTrackerT implements ComponentTracker> { + + int bufferSize = CyclicBufferTracker.DEFAULT_BUFFER_SIZE; + int maxComponents = CyclicBufferTracker.DEFAULT_NUMBER_OF_BUFFERS; + + List> liveList = new LinkedList>(); + List> lingererList = new LinkedList>(); + + long lastCheck = 0; + + + private TEntry getEntry(List> list,String k) { + for (int i = 0; i < list.size(); i++) { + TEntry te = list.get(i); + if (te.key.equals(k)) { + return te; + } + } + return null; + } + + private TEntry getFromEitherList(String key) { + TEntry entry = getEntry(liveList, key); + if(entry != null) + return entry; + else { + return getEntry(lingererList, key); + } + } + + private List keysAsOrderedList(List> list) { + Collections.sort(list); + List result = new LinkedList(); + for (int i = 0; i < list.size(); i++) { + TEntry te = list.get(i); + result.add(te.key); + } + return result; + } + + List liveKeysAsOrderedList() { + return keysAsOrderedList(liveList); + } + List lingererKeysAsOrderedList() { + return keysAsOrderedList(lingererList); + } + + + public Set allKeys() { + HashSet allKeys = new HashSet(); + for (TEntry e : liveList) + allKeys.add(e.key); + for (TEntry e : lingererList) + allKeys.add(e.key); + return allKeys; + } + + + public Collection> allComponents() { + List> allComponents = new ArrayList>(); + for (TEntry e : liveList) + allComponents.add(e.value); + for (TEntry e : lingererList) + allComponents.add(e.value); + + return allComponents; + } + + public CyclicBuffer find(String key) { + TEntry te = getFromEitherList(key); + if(te == null) return null; + else return te.value; + } + + public CyclicBuffer getOrCreate(String key, long timestamp) { + TEntry te = getFromEitherList(key); + if (te == null) { + CyclicBuffer cb = new CyclicBuffer(bufferSize); + te = new TEntry(key, cb, timestamp); + liveList.add(te); + if (liveList.size() > maxComponents) { + Collections.sort(liveList); + liveList.remove(0); + } + } else { + te.timestamp = timestamp; + Collections.sort(liveList); + } + return te.value; + } + + public void endOfLife(String k) { + TEntry te = null; + boolean found = false; + for (int i = 0; i < liveList.size(); i++) { + te = liveList.get(i); + if (te.key.equals(k)) { + liveList.remove(i); + found = true; + break; + } + } + if(found) { + lingererList.add(te); + } + } + + private boolean isEntryStale(TEntry entry, long now) { + return ((entry.timestamp + DEFAULT_TIMEOUT) < now); + } + private boolean isEntryDoneLingering(TEntry tEntry, long now) { + return ((tEntry.timestamp + AbstractComponentTracker.LINGERING_TIMEOUT) < now); + } + + public void removeStaleComponents(long now) { + if (isTooSoonForRemovalIteration(now)) return; + // both list should be sorted before removal attempts + Collections.sort(liveList); + Collections.sort(lingererList); + removeComponentsInExcessFromMainList(); + removeStaleComponentsFromMainList(now); + removeStaleComponentsFromLingerersList(now); + } + + private void removeComponentsInExcessFromMainList() { + while (liveList.size() > maxComponents) { + liveList.remove(0); + } + } + + private void removeStaleComponentsFromMainList(long now) { + while (liveList.size() != 0 && isEntryStale(liveList.get(0), now)) { + liveList.remove(0); + } + } + + private void removeStaleComponentsFromLingerersList(long now) { + while (lingererList.size() != 0 && isEntryDoneLingering(lingererList.get(0), now)) { + lingererList.remove(0); + } + } + + private boolean isTooSoonForRemovalIteration(long now) { + if (lastCheck + CoreConstants.MILLIS_IN_ONE_SECOND > now) { + return true; + } + lastCheck = now; + return false; + } + + public int getComponentCount() { + return liveList.size() + lingererList.size(); + } + + + // ================================================================== + + private class TEntry implements Comparable> { + + String key; + CyclicBuffer value; + long timestamp; + + TEntry(String k, CyclicBuffer v, long timestamp) { + this.key = k; + this.value = v; + this.timestamp = timestamp; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((key == null) ? 0 : key.hashCode()); + return result; + } + + public int compareTo(TEntry o) { + if (!(o instanceof TEntry)) { + throw new IllegalArgumentException("arguments must be of type " + TEntry.class); + } + + TEntry other = (TEntry) o; + if (timestamp > other.timestamp) { + return 1; + } + if (timestamp == other.timestamp) { + return 0; + } + return -1; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + @SuppressWarnings("unchecked") + final TEntry other = (TEntry) obj; + if (key == null) { + if (other.key != null) + return false; + } else if (!key.equals(other.key)) + return false; + if (value == null) { + if (other.value != null) + return false; + } else if (!value.equals(other.value)) + return false; + return true; + } + + @Override + public String toString() { + return "(" + key + ", " + value + ")"; + } + } +} diff --git a/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerImplTest.java b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerTest.java similarity index 57% rename from logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerImplTest.java rename to logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerTest.java index fd83798ac73d21b1a2b5ad638e8e6097779746b6..191f4876f8c6a898bb9e7628254ae9816920a09f 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerImplTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -14,7 +14,6 @@ package ch.qos.logback.core.spi; import ch.qos.logback.core.helpers.CyclicBuffer; -import ch.qos.logback.core.sift.AppenderTrackerImpl; import org.junit.Test; import static junit.framework.Assert.assertEquals; @@ -23,28 +22,28 @@ import static junit.framework.Assert.assertNotNull; /** * @author Ceki Gücü */ -public class CyclicBufferTrackerImplTest { +public class CyclicBufferTrackerTest { - CyclicBufferTrackerImpl tracker = new CyclicBufferTrackerImpl(); + CyclicBufferTracker tracker = new CyclicBufferTracker(); String key = "a"; @Test public void empty0() { long now = 3000; - tracker.clearStaleBuffers(now); - assertEquals(0, tracker.keyList().size()); - assertEquals(0, tracker.bufferCount); + tracker.removeStaleComponents(now); + assertEquals(0, tracker.liveKeysAsOrderedList().size()); + assertEquals(0, tracker.getComponentCount()); } @Test public void empty1() { long now = 3000; assertNotNull(tracker.getOrCreate(key, now++)); - now += CyclicBufferTracker.THRESHOLD + 1000; - tracker.clearStaleBuffers(now); - assertEquals(0, tracker.keyList().size()); - assertEquals(0, tracker.bufferCount); + now += ComponentTracker.DEFAULT_TIMEOUT + 1000; + tracker.removeStaleComponents(now); + assertEquals(0, tracker.liveKeysAsOrderedList().size()); + assertEquals(0, tracker.getComponentCount()); assertNotNull(tracker.getOrCreate(key, now++)); } @@ -54,10 +53,10 @@ public class CyclicBufferTrackerImplTest { long now = 3000; CyclicBuffer cb = tracker.getOrCreate(key, now); assertEquals(cb, tracker.getOrCreate(key, now++)); - now += AppenderTrackerImpl.THRESHOLD + 1000; - tracker.clearStaleBuffers(now); - assertEquals(0, tracker.keyList().size()); - assertEquals(0, tracker.bufferCount); + now += CyclicBufferTracker.DEFAULT_TIMEOUT + 1000; + tracker.removeStaleComponents(now); + assertEquals(0, tracker.liveKeysAsOrderedList().size()); + assertEquals(0, tracker.getComponentCount()); } @Test @@ -66,9 +65,11 @@ public class CyclicBufferTrackerImplTest { CyclicBuffer cb = tracker.getOrCreate(key, now); cb.add(new Object()); assertEquals(1, cb.length()); - tracker.removeBuffer(key); - assertEquals(0, tracker.keyList().size()); - assertEquals(0, tracker.bufferCount); + tracker.endOfLife(key); + now += CyclicBufferTracker.LINGERING_TIMEOUT + 10; + tracker.removeStaleComponents(now); + assertEquals(0, tracker.liveKeysAsOrderedList().size()); + assertEquals(0, tracker.getComponentCount()); assertEquals(0, cb.length()); } diff --git a/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTracker_TImpl.java b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTracker_TImpl.java deleted file mode 100644 index 910dba568fedc6e0ba270e7d5856889f03dfb6fa..0000000000000000000000000000000000000000 --- a/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTracker_TImpl.java +++ /dev/null @@ -1,184 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. - * - * This program and the accompanying materials are dual-licensed under - * either the terms of the Eclipse Public License v1.0 as published by - * the Eclipse Foundation - * - * or (per the licensee's choosing) - * - * under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation. - */ -package ch.qos.logback.core.spi; - -import ch.qos.logback.core.CoreConstants; -import ch.qos.logback.core.helpers.CyclicBuffer; - -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -/** - * @author Ceki Gücü - */ -public class CyclicBufferTracker_TImpl implements CyclicBufferTracker { - - int bufferSize = DEFAULT_BUFFER_SIZE; - int maxNumBuffers = DEFAULT_NUMBER_OF_BUFFERS; - - List> entryList = new LinkedList>(); - long lastCheck = 0; - - public int getBufferSize() { - return bufferSize; - } - - public void setBufferSize(int size) { - } - - public int getMaxNumberOfBuffers() { - return maxNumBuffers; - } - - public void setMaxNumberOfBuffers(int maxNumBuffers) { - this.maxNumBuffers = maxNumBuffers; - } - - private TEntry getEntry(String k) { - for (int i = 0; i < entryList.size(); i++) { - TEntry te = entryList.get(i); - if (te.key.equals(k)) { - return te; - } - } - return null; - } - - List keyList() { - Collections.sort(entryList); - - List result = new LinkedList(); - for (int i = 0; i < entryList.size(); i++) { - TEntry te = entryList.get(i); - result.add(te.key); - } - return result; - } - - - public CyclicBuffer getOrCreate(String key, long timestamp) { - TEntry te = getEntry(key); - if (te == null) { - CyclicBuffer cb = new CyclicBuffer(bufferSize); - te = new TEntry(key, cb, timestamp); - entryList.add(te); - if (entryList.size() >= maxNumBuffers) { - entryList.remove(0); - } - return cb; - } else { - te.timestamp = timestamp; - Collections.sort(entryList); - return te.value; - } - - } - - public void removeBuffer(String k) { - for (int i = 0; i < entryList.size(); i++) { - TEntry te = entryList.get(i); - if (te.key.equals(k)) { - entryList.remove(i); - return; - } - } - } - - private boolean isEntryStale(TEntry entry, long now) { - return ((entry.timestamp + THRESHOLD) < now); - } - - public void clearStaleBuffers(long now) { - if (lastCheck + CoreConstants.MILLIS_IN_ONE_SECOND > now) { - return; - } - lastCheck = now; - Collections.sort(entryList); - while (entryList.size() != 0 && isEntryStale(entryList.get(0), now)) { - entryList.remove(0); - } - } - - public int size() { - return entryList.size(); - } - - - // ================================================================== - - private class TEntry implements Comparable> { - - String key; - CyclicBuffer value; - long timestamp; - - TEntry(String k, CyclicBuffer v, long timestamp) { - this.key = k; - this.value = v; - this.timestamp = timestamp; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((key == null) ? 0 : key.hashCode()); - return result; - } - - public int compareTo(TEntry o) { - if (!(o instanceof TEntry)) { - throw new IllegalArgumentException("arguments must be of type " + TEntry.class); - } - - TEntry other = (TEntry) o; - if (timestamp > other.timestamp) { - return 1; - } - if (timestamp == other.timestamp) { - return 0; - } - return -1; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - @SuppressWarnings("unchecked") - final TEntry other = (TEntry) obj; - if (key == null) { - if (other.key != null) - return false; - } else if (!key.equals(other.key)) - return false; - if (value == null) { - if (other.value != null) - return false; - } else if (!value.equals(other.value)) - return false; - return true; - } - - @Override - public String toString() { - return "(" + key + ", " + value + ")"; - } - } -} diff --git a/logback-core/src/test/java/ch/qos/logback/core/spi/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/spi/PackageTest.java index 4bc2c396ea93b1258e17314d583500873268dfdf..a44be511aeea2db3268e58203f1fdd1f097462d0 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/spi/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/spi/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -19,7 +19,7 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({AppenderAttachableImplTest.class, AppenderAttachableImplLockTest.class, - CyclicBufferTrackerImplTest.class, ScenarioBasedCyclicBufferTrackerTest.class}) + CyclicBufferTrackerTest.class, ScenarioBasedCyclicBufferTrackerTest.class}) public class PackageTest { } diff --git a/logback-core/src/test/java/ch/qos/logback/core/spi/ScenarioBasedCyclicBufferTrackerTest.java b/logback-core/src/test/java/ch/qos/logback/core/spi/ScenarioBasedCyclicBufferTrackerTest.java index b44e5debbf1315d3d24c57a05c19088fa149fd8c..b7c11ca46eed21cd25d31a8b4b8caf78e1888edb 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/spi/ScenarioBasedCyclicBufferTrackerTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/spi/ScenarioBasedCyclicBufferTrackerTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,43 +13,60 @@ */ package ch.qos.logback.core.spi; +import org.junit.Before; import org.junit.Test; import static junit.framework.Assert.assertEquals; /** + * A + * * @author Ceki Gücü */ public class ScenarioBasedCyclicBufferTrackerTest { CyclicBufferTrackerSimulator simulator; + CyclicBufferTrackerSimulator.Parameters parameters = new CyclicBufferTrackerSimulator.Parameters(); void verify() { - CyclicBufferTrackerImpl at = simulator.realCBTracker; - CyclicBufferTracker_TImpl t_at = simulator.t_CBTracker; - assertEquals(t_at.keyList(), at.keyList()); + CyclicBufferTracker at = simulator.realCBTracker; + CyclicBufferTrackerT t_at = simulator.t_CBTracker; + assertEquals(t_at.liveKeysAsOrderedList(), at.liveKeysAsOrderedList()); + assertEquals(t_at.lingererKeysAsOrderedList(), at.lingererKeysAsOrderedList()); + } + + @Before public void setUp() { + parameters.keySpaceLen = 128; + parameters.maxTimestampInc = ComponentTracker.DEFAULT_TIMEOUT / 2; } @Test public void shortTest() { - simulator = new CyclicBufferTrackerSimulator(64, 500); - simulator.buildScenario(200); + parameters.keySpaceLen = 64; + parameters.maxTimestampInc = 500; + parameters.simulationLength = 70; + + simulator = new CyclicBufferTrackerSimulator(parameters); + simulator.buildScenario(); simulator.simulate(); verify(); } @Test public void mediumTest() { - simulator = new CyclicBufferTrackerSimulator(128, CyclicBufferTracker.THRESHOLD / 2); - simulator.buildScenario(20000); + parameters.simulationLength = 20000; + + simulator = new CyclicBufferTrackerSimulator(parameters); + simulator.buildScenario(); simulator.simulate(); verify(); } @Test public void longTest() { - simulator = new CyclicBufferTrackerSimulator(128, CyclicBufferTracker.THRESHOLD / 2); - simulator.buildScenario(200000); + parameters.simulationLength = 100*1000; + simulator = new CyclicBufferTrackerSimulator(parameters); + simulator.buildScenario(); simulator.simulate(); verify(); } diff --git a/logback-core/src/test/java/ch/qos/logback/core/status/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/status/PackageTest.java index 12fcd07ed9e76cf72b1b4ea1bf0fc9c0b00018e3..2bf2b921e26239aa9322810e37abed9955de046b 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/status/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/status/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/status/StatusBaseTest.java b/logback-core/src/test/java/ch/qos/logback/core/status/StatusBaseTest.java index 23076d0c3d3bcb20ab91a6732125f3dd3011e66f..26e4f318a1eb25e463a43ee6c98297cd1b4ff1d5 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/status/StatusBaseTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/status/StatusBaseTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/status/StatusUtilTest.java b/logback-core/src/test/java/ch/qos/logback/core/status/StatusUtilTest.java index c59c21e67cbfe1a1444689ba32f2ec2ec21ce55d..e7a0e82c7411a191f84f2cb30fc9c67e2b89e889 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/status/StatusUtilTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/status/StatusUtilTest.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.status; import ch.qos.logback.core.Context; diff --git a/logback-core/src/test/java/ch/qos/logback/core/status/TrivialStatusListener.java b/logback-core/src/test/java/ch/qos/logback/core/status/TrivialStatusListener.java index cace58c0a4e6b2923735be0c85104b751019057e..bb9eb57e54c80086d5bc023f9e58e8e806760e60 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/status/TrivialStatusListener.java +++ b/logback-core/src/test/java/ch/qos/logback/core/status/TrivialStatusListener.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/subst/NodeToStringTransformerTest.java b/logback-core/src/test/java/ch/qos/logback/core/subst/NodeToStringTransformerTest.java index 04d82795aa209ca85064c351c85bde9ee20c171d..c02ed1c46ee3024c64e062d9a9cd2ba0003cb7f0 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/subst/NodeToStringTransformerTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/subst/NodeToStringTransformerTest.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.subst; import ch.qos.logback.core.ContextBase; @@ -95,6 +108,13 @@ public class NodeToStringTransformerTest { assertEquals("%d{HH:mm:ss.SSS} host:local %logger{36} - %msg%n", nodeToStringTransformer.transform()); } + @Test + public void loneColonShouldReadLikeAnyOtherCharacter() throws ScanException { + String input = "java:comp/env/jdbc/datasource"; + Node node = makeNode(input); + NodeToStringTransformer nodeToStringTransformer = new NodeToStringTransformer(node, propertyContainer0); + assertEquals(input, nodeToStringTransformer.transform()); + } @Test public void withDefaultValue() throws ScanException { diff --git a/logback-core/src/test/java/ch/qos/logback/core/subst/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/subst/PackageTest.java index d54c0b47b56c33edc0c2d642baabf40aa372bba3..26c58d95c7acdee09491535944545aac43793a7b 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/subst/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/subst/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/subst/ParserTest.java b/logback-core/src/test/java/ch/qos/logback/core/subst/ParserTest.java index 8d00e9820a1dcb523d2917bb1bd0a71f01f591e6..c61567af8ee9daf3f9a2284f1cbe86be308c772f 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/subst/ParserTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/subst/ParserTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -53,10 +53,10 @@ public class ParserTest { Parser parser = new Parser(tokenizer.tokenize()); Node node = parser.parse(); Node witness = new Node(Node.Type.LITERAL, "%x"); - Node t = witness.next = new Node(Node.Type.LITERAL, "{"); + Node t = witness.next = new Node(Node.Type.LITERAL, "{"); t.next = new Node(Node.Type.LITERAL, "a"); t = t.next; - t.next = new Node(Node.Type.LITERAL, "}"); + t.next = new Node(Node.Type.LITERAL, "}"); assertEquals(witness, node); } @@ -68,11 +68,11 @@ public class ParserTest { Node node = parser.parse(); Node witness = new Node(Node.Type.LITERAL, "%x"); - Node t = witness.next = new Node(Node.Type.LITERAL, "{"); + Node t = witness.next = new Node(Node.Type.LITERAL, "{"); t.next = new Node(Node.Type.LITERAL, "y"); t = t.next; - t.next = new Node(Node.Type.LITERAL, "}"); + t.next = new Node(Node.Type.LITERAL, "}"); t = t.next; t.next = new Node(Node.Type.LITERAL, " %a"); @@ -84,10 +84,10 @@ public class ParserTest { t.next = new Node(Node.Type.LITERAL, "b"); t = t.next; - t.next = new Node(Node.Type.LITERAL, "}"); + t.next = new Node(Node.Type.LITERAL, "}"); t = t.next; - t.next = new Node(Node.Type.LITERAL, " c"); + t.next = new Node(Node.Type.LITERAL, " c"); node.dump(); System.out.println(""); @@ -133,10 +133,15 @@ public class ParserTest { Parser parser = new Parser(tokenizer.tokenize()); Node node = parser.parse(); Node witness = new Node(Node.Type.LITERAL, "a"); - Node nestedWitness = new Node(Node.Type.VARIABLE, new Node(Node.Type.LITERAL, "b")); - nestedWitness.next = new Node(Node.Type.VARIABLE, new Node(Node.Type.LITERAL, "c")); - witness.next = nestedWitness; - witness.next.next = new Node(Node.Type.LITERAL, "c"); + Node bLiteralNode = new Node(Node.Type.LITERAL, "b"); + Node cLiteralNode = new Node(Node.Type.LITERAL, "c"); + Node bVariableNode = new Node(Node.Type.VARIABLE, bLiteralNode); + Node cVariableNode = new Node(Node.Type.VARIABLE, cLiteralNode); + bLiteralNode.next = cVariableNode; + + witness.next = bVariableNode; + witness.next.next = new Node(Node.Type.LITERAL, "d"); + assertEquals(witness, node); } @Test @@ -145,10 +150,31 @@ public class ParserTest { Parser parser = new Parser(tokenizer.tokenize()); Node node = parser.parse(); Node witness = new Node(Node.Type.VARIABLE, new Node(Node.Type.LITERAL, "b")); - witness.defaultPart = new Node(Node.Type.LITERAL, "c"); - //dump(node); + witness.defaultPart = new Node(Node.Type.LITERAL, "c"); + assertEquals(witness, node); } + @Test + public void defaultSeparatorOutsideOfAVariable() throws ScanException { + Tokenizer tokenizer = new Tokenizer("{a:-b}"); + Parser parser = new Parser(tokenizer.tokenize()); + Node node = parser.parse(); + + dump(node); + Node witness = new Node(Node.Type.LITERAL, "{"); + Node t = witness.next = new Node(Node.Type.LITERAL, "a"); + + + t.next = new Node(Node.Type.LITERAL, ":-"); + t = t.next; + + t.next = new Node(Node.Type.LITERAL, "b"); + t = t.next; + + t.next = new Node(Node.Type.LITERAL, "}"); + + assertEquals(witness, node); + } private void dump(Node node) { while (node != null) { diff --git a/logback-core/src/test/java/ch/qos/logback/core/subst/TokenizerTest.java b/logback-core/src/test/java/ch/qos/logback/core/subst/TokenizerTest.java index 9f09ba203a4bde20fa12b7b20ad01fd39cec85c8..86fc3643b1ce6132227861c4687c59c74ea69675 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/subst/TokenizerTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/subst/TokenizerTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -130,4 +130,19 @@ public class TokenizerTest { assertEquals(witnessList, tokenList); } -} + @Test + public void defaultSeparatorOutsideVariable() throws ScanException { + + String input = "{a:-b}"; + Tokenizer tokenizer = new Tokenizer(input); + List tokenList = tokenizer.tokenize(); + witnessList.add(Token.CURLY_LEFT_TOKEN); + witnessList.add(new Token(Token.Type.LITERAL, "a")); + witnessList.add(Token.DEFAULT_SEP_TOKEN); + witnessList.add(new Token(Token.Type.LITERAL, "b")); + witnessList.add(Token.CURLY_RIGHT_TOKEN); + assertEquals(witnessList, tokenList); + } + + + } diff --git a/logback-core/src/test/java/ch/qos/logback/core/testUtil/DelayingListAppender.java b/logback-core/src/test/java/ch/qos/logback/core/testUtil/DelayingListAppender.java index efa00935218add29ebffac6f8e17142bb7fbe478..f180070c8d8908dbb471cced6777022aee04db4a 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/testUtil/DelayingListAppender.java +++ b/logback-core/src/test/java/ch/qos/logback/core/testUtil/DelayingListAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2012, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,7 +11,6 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ - package ch.qos.logback.core.testUtil; import ch.qos.logback.core.read.ListAppender; @@ -24,7 +23,9 @@ public class DelayingListAppender extends ListAppender { @Override public void append(E e) { try { + Thread.yield(); Thread.sleep(delay); + Thread.yield(); } catch (InterruptedException ie) { interrupted = true; } diff --git a/logback-core/src/test/java/ch/qos/logback/core/testUtil/EnvUtilForTests.java b/logback-core/src/test/java/ch/qos/logback/core/testUtil/EnvUtilForTests.java index d1f004884cd617d9679c35d8b8fbec2291bb00d8..2486e6dd7a95289ab69f582b6b108fa66f53145f 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/testUtil/EnvUtilForTests.java +++ b/logback-core/src/test/java/ch/qos/logback/core/testUtil/EnvUtilForTests.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -35,6 +35,10 @@ public class EnvUtilForTests { } + static public boolean isRunningOnSlowJenkins() { + return System.getProperty(CoreTestConstants.SLOW_JENKINS) != null; + } + static public String getLocalHostName() { InetAddress localhostIA; diff --git a/logback-core/src/test/java/ch/qos/logback/core/testUtil/FileTestUtil.java b/logback-core/src/test/java/ch/qos/logback/core/testUtil/FileTestUtil.java index e4d66f51588b6def73c5ca2a74d1f84d72d3a7d2..aec647299510ca91b8e652dc9afcb9f939f7e46a 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/testUtil/FileTestUtil.java +++ b/logback-core/src/test/java/ch/qos/logback/core/testUtil/FileTestUtil.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package ch.qos.logback.core.testUtil; import ch.qos.logback.core.util.CoreTestConstants; diff --git a/logback-core/src/test/java/ch/qos/logback/core/testUtil/FileToBufferUtil.java b/logback-core/src/test/java/ch/qos/logback/core/testUtil/FileToBufferUtil.java index fdc9fea699d38f29162b635690aa08a3a656383f..707eeda945e16de4de7c43194d73b2f6a6820c75 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/testUtil/FileToBufferUtil.java +++ b/logback-core/src/test/java/ch/qos/logback/core/testUtil/FileToBufferUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/testUtil/NPEAppender.java b/logback-core/src/test/java/ch/qos/logback/core/testUtil/NPEAppender.java index b35c3af99896de3032e646687d856964b9427bb5..97521f1644eceebc2e86921a1aa05f0634e60d52 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/testUtil/NPEAppender.java +++ b/logback-core/src/test/java/ch/qos/logback/core/testUtil/NPEAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/testUtil/RandomUtil.java b/logback-core/src/test/java/ch/qos/logback/core/testUtil/RandomUtil.java index ada14a50fda773c409a35c3576c610cc41d0e080..0cf1a6dcf404a2575daf7cfdbce655ca2af279b6 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/testUtil/RandomUtil.java +++ b/logback-core/src/test/java/ch/qos/logback/core/testUtil/RandomUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/testUtil/StringListAppender.java b/logback-core/src/test/java/ch/qos/logback/core/testUtil/StringListAppender.java index a0487fbd071cd9d2cb44087be65fded577a41ab4..ebbe9b95ac4eb5a4d8a36f19e2cdb0ce3dc7e395 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/testUtil/StringListAppender.java +++ b/logback-core/src/test/java/ch/qos/logback/core/testUtil/StringListAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/Compare.java b/logback-core/src/test/java/ch/qos/logback/core/util/Compare.java index 1f21128a84cf6cc7524e5356115289dcdfa6c7b4..e6459a7fb4279e83c990124262e4b14e51031c34 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/util/Compare.java +++ b/logback-core/src/test/java/ch/qos/logback/core/util/Compare.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/ContentTypeUtilTest.java b/logback-core/src/test/java/ch/qos/logback/core/util/ContentTypeUtilTest.java index 91ecc4ac4530f3f14c72b23cbd3446416365c68a..bf6b633cc0c122cdecd9d7c62df4d97be00a529c 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/util/ContentTypeUtilTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/util/ContentTypeUtilTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/CoreTestConstants.java b/logback-core/src/test/java/ch/qos/logback/core/util/CoreTestConstants.java index caa3d76dd08f5dbb1dc11906ff4ec91c95ab022a..507c2e6f6021869362bfa01f6cab057d1ee52711 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/util/CoreTestConstants.java +++ b/logback-core/src/test/java/ch/qos/logback/core/util/CoreTestConstants.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -28,4 +28,7 @@ public class CoreTestConstants { public static final String BASH_PATH_ON_CYGWIN = "c:/cygwin/bin/bash"; public static final String BASH_PATH_ON_LINUX = "bash"; + + + public static final String SLOW_JENKINS = "slowJenkins"; } diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/DatePatternToRegexTest.java b/logback-core/src/test/java/ch/qos/logback/core/util/DatePatternToRegexTest.java index 8281b8f2e71198e42edb1434c886362e64f44c5c..04406c022e894e5b541702bfce0d566a2193e492 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/util/DatePatternToRegexTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/util/DatePatternToRegexTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/DurationTest.java b/logback-core/src/test/java/ch/qos/logback/core/util/DurationTest.java index 86c93c504128b0fdf918a2e2cc84e8bab0bfbe83..9a4e9ba571d4393f935ab5741282ecee7159234b 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/util/DurationTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/util/DurationTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/FileSizeTest.java b/logback-core/src/test/java/ch/qos/logback/core/util/FileSizeTest.java index f1721b94fbdac25ee80122f3ca55ed71a4972274..bf5af3552bd325befc675861359cb0b0b5d330b8 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/util/FileSizeTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/util/FileSizeTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/FileUtilTest.java b/logback-core/src/test/java/ch/qos/logback/core/util/FileUtilTest.java index 71ec4cf4271c86d6cabc48693529e5bc6c0dda82..581f63b10730c27a95e9abbf73788aca3cf398f6 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/util/FileUtilTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/util/FileUtilTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -35,7 +35,8 @@ public class FileUtilTest { Context context = new ContextBase(); FileUtil fileUtil = new FileUtil(context); List cleanupList = new ArrayList(); - int diff = new Random().nextInt(100); + // test-output folder is not always clean + int diff = new Random().nextInt(10000); @Before public void setUp() throws Exception { diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/LocationUtilTest.java b/logback-core/src/test/java/ch/qos/logback/core/util/LocationUtilTest.java index 65f4528ecc4004ac8e78cd682b27d504cc96065e..29410014c00343a0ccdce9c206d1824139fd79db 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/util/LocationUtilTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/util/LocationUtilTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/OptionHelperTest.java b/logback-core/src/test/java/ch/qos/logback/core/util/OptionHelperTest.java index d072e8d5b861c1b053c51329bd821cde87b20c09..81f8aad8763a2c1002f9073923d71946c10d2a2e 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/util/OptionHelperTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/util/OptionHelperTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/util/PackageTest.java index aa03868135663cb007027fbc8d07647768bee2e7..9abe592eba8d05bc5ee3e2c85cf8d6b7afe1f2bd 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/util/PackageTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/util/PackageTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/ResilienceUtil.java b/logback-core/src/test/java/ch/qos/logback/core/util/ResilienceUtil.java index c0510654de9a6b9b4b0940f2a1c5ab7eadf0d03a..ccec59259840ea276c61a5afaef93a7e8b088e62 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/util/ResilienceUtil.java +++ b/logback-core/src/test/java/ch/qos/logback/core/util/ResilienceUtil.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/StatusPrinterTest.java b/logback-core/src/test/java/ch/qos/logback/core/util/StatusPrinterTest.java index 611990e31ddbcbc2983a02aeda5afb41aab88ba5..ceb9fe2fdeb186890d93b8f9965bb599fe91eee5 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/util/StatusPrinterTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/util/StatusPrinterTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/StringCollectionUtilTest.java b/logback-core/src/test/java/ch/qos/logback/core/util/StringCollectionUtilTest.java index e07bee5eaeb84445384ba143c10a4cb5c7d11eb2..2d4b6f93d7694d2ce1f0d7486f1ebf17aed4d38d 100755 --- a/logback-core/src/test/java/ch/qos/logback/core/util/StringCollectionUtilTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/util/StringCollectionUtilTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/TeeOutputStream.java b/logback-core/src/test/java/ch/qos/logback/core/util/TeeOutputStream.java index c47827fcf77afdead156a3c7dd9955a96418ea33..d45879c0153b775979ee42de87f9aa339881e9ad 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/util/TeeOutputStream.java +++ b/logback-core/src/test/java/ch/qos/logback/core/util/TeeOutputStream.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/TimeUtilTest.java b/logback-core/src/test/java/ch/qos/logback/core/util/TimeUtilTest.java index d09e107a180eb29629f19b9e27edb019d71873c1..f661e9767a4acea80c3eab189c111ba3a717479d 100644 --- a/logback-core/src/test/java/ch/qos/logback/core/util/TimeUtilTest.java +++ b/logback-core/src/test/java/ch/qos/logback/core/util/TimeUtilTest.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/pom.xml b/logback-examples/pom.xml index b72090999bdfd415d535e419563114541e24878b..a2f5ace2272b07404cd4ba3fdae0955ff65263db 100644 --- a/logback-examples/pom.xml +++ b/logback-examples/pom.xml @@ -5,7 +5,7 @@ ch.qos.logback logback-parent - 1.0.12-SNAPSHOT + 2.0.0-SNAPSHOT 4.0.0 diff --git a/logback-examples/src/main/java/chapters/appenders/ConfigurationTester.java b/logback-examples/src/main/java/chapters/appenders/ConfigurationTester.java index 1f72959c0968e8f7852a301735c928fa210f673d..f4a169d2192401a55904ecb63092b5bf2d0c4b28 100644 --- a/logback-examples/src/main/java/chapters/appenders/ConfigurationTester.java +++ b/logback-examples/src/main/java/chapters/appenders/ConfigurationTester.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/appenders/CountingConsoleAppender.java b/logback-examples/src/main/java/chapters/appenders/CountingConsoleAppender.java index 8610a0b110b1137fdff1dcbabcbbfc4c1b1402c5..8e6e586d79e794aaa3493b2ab39e3d4a722f3e5d 100755 --- a/logback-examples/src/main/java/chapters/appenders/CountingConsoleAppender.java +++ b/logback-examples/src/main/java/chapters/appenders/CountingConsoleAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/appenders/IO.java b/logback-examples/src/main/java/chapters/appenders/IO.java index 00273ddb32448fbd1846ccec553f1c819dde7df5..ef44533e4b7889482fef6b2c7e358648adff337f 100644 --- a/logback-examples/src/main/java/chapters/appenders/IO.java +++ b/logback-examples/src/main/java/chapters/appenders/IO.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -120,7 +120,7 @@ public class IO extends Thread { threads[i].start(); } - // wait for them to stop, compute the average throughput + // wait for them to processPriorToRemoval, compute the average throughput double sum = 0; for (int i = 0; i < numThreads; i++) { @@ -129,7 +129,7 @@ public class IO extends Thread { } if (scarceCPU) { - // setting the interrupted field will cause counterThread to stop + // setting the interrupted field will cause counterThread to processPriorToRemoval counterThread.interrupted = true; counterThread.join(); } diff --git a/logback-examples/src/main/java/chapters/appenders/IOPerformance.java b/logback-examples/src/main/java/chapters/appenders/IOPerformance.java index 5f3674c408292578948523cb91092b6831117997..b84a33aaf485aa8776b2c4bf881c611bcd0052e8 100644 --- a/logback-examples/src/main/java/chapters/appenders/IOPerformance.java +++ b/logback-examples/src/main/java/chapters/appenders/IOPerformance.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -109,7 +109,7 @@ public class IOPerformance extends Thread { threads[i].start(); } - // wait for them to stop, compute the average throughput + // wait for them to processPriorToRemoval, compute the average throughput double sum = 0; for (int i = 0; i < NUM_THREADS; i++) { @@ -117,7 +117,7 @@ public class IOPerformance extends Thread { sum += threads[i].throughput; } - // setting the interrupted field will cause counterThread to stop + // setting the interrupted field will cause counterThread to processPriorToRemoval otherIOThread.interrupted = true; otherIOThread.join(); diff --git a/logback-examples/src/main/java/chapters/appenders/mail/CounterBasedEvaluator.java b/logback-examples/src/main/java/chapters/appenders/mail/CounterBasedEvaluator.java index 86d77198ecab8f940d95f8bfd47129942cb47762..3db5d505cd16e293fad5762ff86026b4bc349bbe 100644 --- a/logback-examples/src/main/java/chapters/appenders/mail/CounterBasedEvaluator.java +++ b/logback-examples/src/main/java/chapters/appenders/mail/CounterBasedEvaluator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/appenders/mail/EMail.java b/logback-examples/src/main/java/chapters/appenders/mail/EMail.java index 25694346e56753b43334c1bc139564ea6efabdb7..c061fa509f67ed770b5d54527f37e26e143459dc 100644 --- a/logback-examples/src/main/java/chapters/appenders/mail/EMail.java +++ b/logback-examples/src/main/java/chapters/appenders/mail/EMail.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/appenders/mail/Marked_EMail.java b/logback-examples/src/main/java/chapters/appenders/mail/Marked_EMail.java index 14910de0f18b3edac00d91effa07796103b23073..28fbb8f9d46b6301d66b794b3f847a864a9f7908 100644 --- a/logback-examples/src/main/java/chapters/appenders/mail/Marked_EMail.java +++ b/logback-examples/src/main/java/chapters/appenders/mail/Marked_EMail.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/appenders/mail/customBufferSize.xml b/logback-examples/src/main/java/chapters/appenders/mail/customBufferSize.xml index 6a89723ba91e28d5b08cb6f87775bcb2792dedf9..de82f221226745d797f3ff30d17e12b4946a4a4a 100644 --- a/logback-examples/src/main/java/chapters/appenders/mail/customBufferSize.xml +++ b/logback-examples/src/main/java/chapters/appenders/mail/customBufferSize.xml @@ -9,7 +9,7 @@ - + 1 diff --git a/logback-examples/src/main/java/chapters/appenders/sift/SiftExample.java b/logback-examples/src/main/java/chapters/appenders/sift/SiftExample.java index be463ce7b95aef824e021b9e635beeb85893072e..d90f5f9649d6a40f90eb53005138ccfa5992c968 100644 --- a/logback-examples/src/main/java/chapters/appenders/sift/SiftExample.java +++ b/logback-examples/src/main/java/chapters/appenders/sift/SiftExample.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/appenders/socket/ConsolePluginClient.java b/logback-examples/src/main/java/chapters/appenders/socket/ConsolePluginClient.java index 1fd1e048247bbf7558d7488e71071698c5712ef2..73a0c0cbd8d0fce81a644a9f75f42164aaf16a02 100644 --- a/logback-examples/src/main/java/chapters/appenders/socket/ConsolePluginClient.java +++ b/logback-examples/src/main/java/chapters/appenders/socket/ConsolePluginClient.java @@ -1,3 +1,16 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ package chapters.appenders.socket; import org.slf4j.LoggerFactory; diff --git a/logback-examples/src/main/java/chapters/appenders/socket/SocketClient1.java b/logback-examples/src/main/java/chapters/appenders/socket/SocketClient1.java index f7821b802d47c02852c7132360021477d780843b..ce2cfd29f34dcc899e37d97b509789c085770353 100644 --- a/logback-examples/src/main/java/chapters/appenders/socket/SocketClient1.java +++ b/logback-examples/src/main/java/chapters/appenders/socket/SocketClient1.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/appenders/socket/SocketClient2.java b/logback-examples/src/main/java/chapters/appenders/socket/SocketClient2.java index e1df4b1d518f8653ea50828dd0cf1e12114b4b74..fd1e89e12fa0dbd8c58070510c90cb922de089fc 100644 --- a/logback-examples/src/main/java/chapters/appenders/socket/SocketClient2.java +++ b/logback-examples/src/main/java/chapters/appenders/socket/SocketClient2.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/appenders/socket/SocketRemoteClient.java b/logback-examples/src/main/java/chapters/appenders/socket/SocketRemoteClient.java deleted file mode 100644 index 900574857a03a337c37f1ed933efa6ac9baa0798..0000000000000000000000000000000000000000 --- a/logback-examples/src/main/java/chapters/appenders/socket/SocketRemoteClient.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * File created on Apr 2, 2013 - * - * Copyright 2008-2011 Virginia Polytechnic Institute and State University - * - * Licensed 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. - * - */ -package chapters.appenders.socket; - -import org.slf4j.LoggerFactory; - -import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.classic.joran.JoranConfigurator; - -/** - * This application loads a configuration containing a - * {@link SocketRemote} and then logs events received from the remote - * appender to the console. - */ -public class SocketRemoteClient { - - static void usage(String msg) { - System.err.println(msg); - System.err.println("Usage: java " + SocketRemoteClient.class.getName() + - " configFile\n" + - " configFile a logback configuration file" + - " in XML format."); - System.exit(1); - } - - static public void main(String[] args) throws Exception { - if (args.length != 1) { - usage("Wrong number of arguments."); - } - - String configFile = args[0]; - - if (configFile.endsWith(".xml")) { - LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); - JoranConfigurator configurator = new JoranConfigurator(); - lc.stop(); - configurator.setContext(lc); - configurator.doConfigure(configFile); - } - - Thread.sleep(Long.MAX_VALUE); - ((LoggerContext) LoggerFactory.getILoggerFactory()).stop(); - } - -} diff --git a/logback-examples/src/main/java/chapters/appenders/socket/remoteClient.xml b/logback-examples/src/main/java/chapters/appenders/socket/client2.xml similarity index 81% rename from logback-examples/src/main/java/chapters/appenders/socket/remoteClient.xml rename to logback-examples/src/main/java/chapters/appenders/socket/client2.xml index f48ed0d0c97a6db3eabd13fcaab4eebf97239ccb..acfc2759afac4cc5f4ca5dab3e5e5992fc57dd0c 100644 --- a/logback-examples/src/main/java/chapters/appenders/socket/remoteClient.xml +++ b/logback-examples/src/main/java/chapters/appenders/socket/client2.xml @@ -1,7 +1,7 @@ - + @@ -11,17 +11,17 @@ %date %-5level [%thread] %logger - %message%n + + + + - + ${host} ${port} 10000 - + - - - - diff --git a/logback-examples/src/main/java/chapters/appenders/socket/ssl/client.xml b/logback-examples/src/main/java/chapters/appenders/socket/ssl/client.xml index abd082d4b902f4f8e75004895560fe7aec1de18a..616da90ab7dbdf774cfd16596b5ed93991f64bfd 100644 --- a/logback-examples/src/main/java/chapters/appenders/socket/ssl/client.xml +++ b/logback-examples/src/main/java/chapters/appenders/socket/ssl/client.xml @@ -1,7 +1,7 @@ - + diff --git a/logback-examples/src/main/java/chapters/appenders/socket/ssl/server1.xml b/logback-examples/src/main/java/chapters/appenders/socket/ssl/server.xml similarity index 96% rename from logback-examples/src/main/java/chapters/appenders/socket/ssl/server1.xml rename to logback-examples/src/main/java/chapters/appenders/socket/ssl/server.xml index 32eb96f60ea1fad5691fcd4b622c26e600388dc7..21abbbd0fa115bb0d8d767882ce23e497404bedd 100644 --- a/logback-examples/src/main/java/chapters/appenders/socket/ssl/server1.xml +++ b/logback-examples/src/main/java/chapters/appenders/socket/ssl/server.xml @@ -1,7 +1,7 @@ - + diff --git a/logback-examples/src/main/java/chapters/appenders/sub/sample/Bar.java b/logback-examples/src/main/java/chapters/appenders/sub/sample/Bar.java index d926557ade86dffef14ff176df44eabe4efe0c3c..49a5675e2437a68825eddc414979f136b7493ce9 100644 --- a/logback-examples/src/main/java/chapters/appenders/sub/sample/Bar.java +++ b/logback-examples/src/main/java/chapters/appenders/sub/sample/Bar.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/architecture/Bar.java b/logback-examples/src/main/java/chapters/architecture/Bar.java index 4f282dd335dd88a3fb80b9d60863c148f3fc1f21..90a83dbff3b04b6e38d395fb1d03b887c0221563 100644 --- a/logback-examples/src/main/java/chapters/architecture/Bar.java +++ b/logback-examples/src/main/java/chapters/architecture/Bar.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/architecture/MyAppWithConfigFile.java b/logback-examples/src/main/java/chapters/architecture/MyAppWithConfigFile.java index 705d3aafc59ad3d5ca3034990f33afa34f54e6c7..d297f8d33c49e101f04d4d28f76300713d1a4af3 100644 --- a/logback-examples/src/main/java/chapters/architecture/MyAppWithConfigFile.java +++ b/logback-examples/src/main/java/chapters/architecture/MyAppWithConfigFile.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/architecture/SelectionRule.java b/logback-examples/src/main/java/chapters/architecture/SelectionRule.java index ba74fd5b30e1749866a3190fab9ab72c7ed25ecd..b0f50542ca5fd54507fdffaa116ae74ed659252f 100644 --- a/logback-examples/src/main/java/chapters/architecture/SelectionRule.java +++ b/logback-examples/src/main/java/chapters/architecture/SelectionRule.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/configuration/AddStatusListenerApp.java b/logback-examples/src/main/java/chapters/configuration/AddStatusListenerApp.java index dcb7f64831882e591b88123d22633d450aa6852e..d3131410335cfab751352296b2c22e3c355ae78d 100644 --- a/logback-examples/src/main/java/chapters/configuration/AddStatusListenerApp.java +++ b/logback-examples/src/main/java/chapters/configuration/AddStatusListenerApp.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/configuration/Foo.java b/logback-examples/src/main/java/chapters/configuration/Foo.java index 488e8fc8f58a412abe36837ebe93e3e36f3459c2..d88d5f945adb1874fe9506db2e2eebbe73ae2744 100644 --- a/logback-examples/src/main/java/chapters/configuration/Foo.java +++ b/logback-examples/src/main/java/chapters/configuration/Foo.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/configuration/MyApp1.java b/logback-examples/src/main/java/chapters/configuration/MyApp1.java index 930205ecfd84cb663d350d8de60fb1fe706eeeeb..9b62f8e6221c8ea253af3e057cd925323bed5531 100644 --- a/logback-examples/src/main/java/chapters/configuration/MyApp1.java +++ b/logback-examples/src/main/java/chapters/configuration/MyApp1.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/configuration/MyApp2.java b/logback-examples/src/main/java/chapters/configuration/MyApp2.java index 2e7a8a4f6b15fff4d9bc126257847004489c95bf..92386d0c9adc55b77bdcb9226af603e87dd26a28 100644 --- a/logback-examples/src/main/java/chapters/configuration/MyApp2.java +++ b/logback-examples/src/main/java/chapters/configuration/MyApp2.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/configuration/MyApp3.java b/logback-examples/src/main/java/chapters/configuration/MyApp3.java index dc3d14edfe4693143838ac511a28c2e4d9d5a56f..652bc77a3d4c47873e8ae708593ea1cf5e4dd9c4 100644 --- a/logback-examples/src/main/java/chapters/configuration/MyApp3.java +++ b/logback-examples/src/main/java/chapters/configuration/MyApp3.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/filters/FilterEvents.java b/logback-examples/src/main/java/chapters/filters/FilterEvents.java index 03103f7714b1ab36f9ef2feff9fdcf5e77a8a42f..92a9634d98eba103a9fc2e1a2e81c302bcbfa27c 100644 --- a/logback-examples/src/main/java/chapters/filters/FilterEvents.java +++ b/logback-examples/src/main/java/chapters/filters/FilterEvents.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/filters/GoMDC.java b/logback-examples/src/main/java/chapters/filters/GoMDC.java index 5dd4c547c3d51fc0958d0f6ba0cec4e0724cf5b4..e89627fd56b95e1281564d3e93f80c39ff318e8e 100644 --- a/logback-examples/src/main/java/chapters/filters/GoMDC.java +++ b/logback-examples/src/main/java/chapters/filters/GoMDC.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/filters/SampleFilter.java b/logback-examples/src/main/java/chapters/filters/SampleFilter.java index dfa9986de22848f91957d2e8a281293c50282d7d..070550b536442b72f5245cff20ccd37b7fec6dee 100644 --- a/logback-examples/src/main/java/chapters/filters/SampleFilter.java +++ b/logback-examples/src/main/java/chapters/filters/SampleFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/filters/SampleTurboFilter.java b/logback-examples/src/main/java/chapters/filters/SampleTurboFilter.java index 2840ea92409b7cee0c8b248f1fa6e54e514f1d2e..a41e95b9c66c5d54a4f8427d4aee81be1f3b2ef3 100644 --- a/logback-examples/src/main/java/chapters/filters/SampleTurboFilter.java +++ b/logback-examples/src/main/java/chapters/filters/SampleTurboFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/introduction/HelloWorld1.java b/logback-examples/src/main/java/chapters/introduction/HelloWorld1.java index 0a2503e2577c672e6e4461c99371b9099d188390..649e87c46e3ce1270f9d6d907a0d44ad49f506ed 100644 --- a/logback-examples/src/main/java/chapters/introduction/HelloWorld1.java +++ b/logback-examples/src/main/java/chapters/introduction/HelloWorld1.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/introduction/HelloWorld2.java b/logback-examples/src/main/java/chapters/introduction/HelloWorld2.java index 0952e3d43df42b02ecd85dc3d1402c699c1ab29f..f4314681b2bd4117e19d88b776d5fe3f6db4fa7a 100644 --- a/logback-examples/src/main/java/chapters/introduction/HelloWorld2.java +++ b/logback-examples/src/main/java/chapters/introduction/HelloWorld2.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/layouts/CallerEvaluatorExample.java b/logback-examples/src/main/java/chapters/layouts/CallerEvaluatorExample.java index 23d244ca3de8abb5bc5c6a60588a384c246c2498..58d6a0e0acb4a307445e79a5ac7c4eeb7bbea87d 100644 --- a/logback-examples/src/main/java/chapters/layouts/CallerEvaluatorExample.java +++ b/logback-examples/src/main/java/chapters/layouts/CallerEvaluatorExample.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/layouts/ExceptionEvaluatorExample.java b/logback-examples/src/main/java/chapters/layouts/ExceptionEvaluatorExample.java index 974a667bae9294acc824228ee2f5faa9d1e15ce0..88cc55fbd500efb1d48feb4c260fcf45abb1a9bd 100644 --- a/logback-examples/src/main/java/chapters/layouts/ExceptionEvaluatorExample.java +++ b/logback-examples/src/main/java/chapters/layouts/ExceptionEvaluatorExample.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/layouts/MySampleConverter.java b/logback-examples/src/main/java/chapters/layouts/MySampleConverter.java index b3c6d9b8b28f652ed2982754faf765bad42eedf1..692555ac8d6a79815e7be33290a2d19b62a6897e 100644 --- a/logback-examples/src/main/java/chapters/layouts/MySampleConverter.java +++ b/logback-examples/src/main/java/chapters/layouts/MySampleConverter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/layouts/MySampleLayout.java b/logback-examples/src/main/java/chapters/layouts/MySampleLayout.java index 096d9715ffe738e6dc9823e6a89309e46913ac7a..b115b4f592d86545255109bfad5ccac1b2575081 100644 --- a/logback-examples/src/main/java/chapters/layouts/MySampleLayout.java +++ b/logback-examples/src/main/java/chapters/layouts/MySampleLayout.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/layouts/MySampleLayout2.java b/logback-examples/src/main/java/chapters/layouts/MySampleLayout2.java index 7ef8f952518bacd86ecee2eb87e0797056a808ef..2a3042fb46eb3aedc374ecce025cbf1ee585bedd 100644 --- a/logback-examples/src/main/java/chapters/layouts/MySampleLayout2.java +++ b/logback-examples/src/main/java/chapters/layouts/MySampleLayout2.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/layouts/PatternSample.java b/logback-examples/src/main/java/chapters/layouts/PatternSample.java index 4cbbf8e02e9b0279dd31812f8cceef63965fb3f4..95130017c8ee9854ee4f868f58cf6bc395dd065a 100644 --- a/logback-examples/src/main/java/chapters/layouts/PatternSample.java +++ b/logback-examples/src/main/java/chapters/layouts/PatternSample.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/layouts/SampleLogging.java b/logback-examples/src/main/java/chapters/layouts/SampleLogging.java index 5502e7eb4bc1458b7b8f47147b5f6cfba03f0fa4..725a3addb3428b2231bf14b3487651a7216f655c 100644 --- a/logback-examples/src/main/java/chapters/layouts/SampleLogging.java +++ b/logback-examples/src/main/java/chapters/layouts/SampleLogging.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/layouts/TestException.java b/logback-examples/src/main/java/chapters/layouts/TestException.java index 248d347bfb6b02d9f26244cfdcc6a04af9b59776..886dc00ef69e4fe3cf123d2880686bb771dca75d 100644 --- a/logback-examples/src/main/java/chapters/layouts/TestException.java +++ b/logback-examples/src/main/java/chapters/layouts/TestException.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/layouts/TrivialMain.java b/logback-examples/src/main/java/chapters/layouts/TrivialMain.java index d2c4f5ad0ed7be7c802cb1519a3ef8b1230c9647..846061d8067e75b1c0ce24e13f8a8a56d351609f 100644 --- a/logback-examples/src/main/java/chapters/layouts/TrivialMain.java +++ b/logback-examples/src/main/java/chapters/layouts/TrivialMain.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/layouts/highlighted.xml b/logback-examples/src/main/java/chapters/layouts/highlighted.xml index 8a6ad8c71865e692a779be1794445ce49b90da00..34f8fc31446f9e823306dbd0c85d8bec01da9b2b 100644 --- a/logback-examples/src/main/java/chapters/layouts/highlighted.xml +++ b/logback-examples/src/main/java/chapters/layouts/highlighted.xml @@ -2,10 +2,10 @@ - false + true %date [%thread] %highlight(%-5level) %cyan(%-15logger{15}) %X - %msg %n diff --git a/logback-examples/src/main/java/chapters/mdc/NumberCruncher.java b/logback-examples/src/main/java/chapters/mdc/NumberCruncher.java index 8b68c9b030770351212ceb6ed12642bdb87cab90..55a63908db27a3accc018dfa28b8be0078cb7bfc 100644 --- a/logback-examples/src/main/java/chapters/mdc/NumberCruncher.java +++ b/logback-examples/src/main/java/chapters/mdc/NumberCruncher.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/mdc/NumberCruncherClient.java b/logback-examples/src/main/java/chapters/mdc/NumberCruncherClient.java index 06ea0fffa74dfe407d61edb384302ce400399475..3cc5ec72ed76de14e6f48e4b4370fcb7b42a60f7 100644 --- a/logback-examples/src/main/java/chapters/mdc/NumberCruncherClient.java +++ b/logback-examples/src/main/java/chapters/mdc/NumberCruncherClient.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/mdc/NumberCruncherServer.java b/logback-examples/src/main/java/chapters/mdc/NumberCruncherServer.java index b52e18e789b07f6383b2e12167f74d5aef98c839..46a387a124fff910f3f471398a85160b00d9a94b 100644 --- a/logback-examples/src/main/java/chapters/mdc/NumberCruncherServer.java +++ b/logback-examples/src/main/java/chapters/mdc/NumberCruncherServer.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/mdc/SimpleMDC.java b/logback-examples/src/main/java/chapters/mdc/SimpleMDC.java index 48fdae470a3074a3dc9a048a2dbf1b222da9ad95..57978e24172bf2ec7c605636ebe54d286f7dded2 100644 --- a/logback-examples/src/main/java/chapters/mdc/SimpleMDC.java +++ b/logback-examples/src/main/java/chapters/mdc/SimpleMDC.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/mdc/UserServletFilter.java b/logback-examples/src/main/java/chapters/mdc/UserServletFilter.java index 1fdacba02a41689b2ab5ef87aeb3e4ecd6cacd6c..a43f370be64d7082c3215f5ecf8cc2d15419c469 100644 --- a/logback-examples/src/main/java/chapters/mdc/UserServletFilter.java +++ b/logback-examples/src/main/java/chapters/mdc/UserServletFilter.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/migrationFromLog4j/Log4jMain.java b/logback-examples/src/main/java/chapters/migrationFromLog4j/Log4jMain.java index 10e14007c3c202c1e2fac88dee24e1eb7d22b01e..9d69077ece916247a30953927ef83b16c278e7b1 100644 --- a/logback-examples/src/main/java/chapters/migrationFromLog4j/Log4jMain.java +++ b/logback-examples/src/main/java/chapters/migrationFromLog4j/Log4jMain.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/migrationFromLog4j/LogbackMain.java b/logback-examples/src/main/java/chapters/migrationFromLog4j/LogbackMain.java index b144e132af41b53720973056643144f1616f506e..bd7ac57c487a39cbaa18d6b2497b42d6a218ece0 100644 --- a/logback-examples/src/main/java/chapters/migrationFromLog4j/LogbackMain.java +++ b/logback-examples/src/main/java/chapters/migrationFromLog4j/LogbackMain.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLog4jAppender.java b/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLog4jAppender.java index bdfa8c71531437420f54296020aa471ca6266919..934ff4f769dfaa910f6e3f8aca3a2bd393bdef24 100644 --- a/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLog4jAppender.java +++ b/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLog4jAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLog4jLayout.java b/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLog4jLayout.java index 4ae8a16405bec8d05033928ec0e64e7c9a614d16..804a1abd97c14fa40013a5b88129a3cb02d029e9 100644 --- a/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLog4jLayout.java +++ b/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLog4jLayout.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLogbackAppender.java b/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLogbackAppender.java index 884aab39782860e01b6cf33304b6cb6d8b80e130..e274d98386a196e1d577061f39b08ca447db5bb6 100644 --- a/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLogbackAppender.java +++ b/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLogbackAppender.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLogbackLayout.java b/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLogbackLayout.java index 3f5cefcd4a4343099e5b07d8152e89924075c60c..d8350f248275f44b4842e6d9b21e3e06c939a19f 100644 --- a/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLogbackLayout.java +++ b/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLogbackLayout.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/onJoran/SimpleConfigurator.java b/logback-examples/src/main/java/chapters/onJoran/SimpleConfigurator.java index 969a91f1225d1a6fa08ce9f3021f24c55eaa5c8b..07d0c5c895b69398ee7eec100134983567b32236 100644 --- a/logback-examples/src/main/java/chapters/onJoran/SimpleConfigurator.java +++ b/logback-examples/src/main/java/chapters/onJoran/SimpleConfigurator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -19,8 +19,9 @@ import java.util.Map; import ch.qos.logback.core.joran.GenericConfigurator; import ch.qos.logback.core.joran.action.Action; import ch.qos.logback.core.joran.action.ImplicitAction; +import ch.qos.logback.core.joran.spi.ElementPath; import ch.qos.logback.core.joran.spi.Interpreter; -import ch.qos.logback.core.joran.spi.Pattern; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.joran.spi.RuleStore; /** @@ -31,23 +32,23 @@ import ch.qos.logback.core.joran.spi.RuleStore; */ public class SimpleConfigurator extends GenericConfigurator { - final Map ruleMap; + final Map ruleMap; final List iaList; - public SimpleConfigurator(Map ruleMap) { + public SimpleConfigurator(Map ruleMap) { this(ruleMap, null); } - public SimpleConfigurator(Map ruleMap, List iaList) { + public SimpleConfigurator(Map ruleMap, List iaList) { this.ruleMap = ruleMap; this.iaList = iaList; } @Override protected void addInstanceRules(RuleStore rs) { - for (Pattern pattern : ruleMap.keySet()) { - Action action = ruleMap.get(pattern); - rs.addRule(pattern, action); + for (ElementSelector elementSelector : ruleMap.keySet()) { + Action action = ruleMap.get(elementSelector); + rs.addRule(elementSelector, action); } } @@ -60,5 +61,4 @@ public class SimpleConfigurator extends GenericConfigurator { interpreter.addImplicitAction(ia); } } - } diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/AddAction.java b/logback-examples/src/main/java/chapters/onJoran/calculator/AddAction.java index fbb960cdf00394e4e43e52d96f021a2d66b5d618..583054863c2a60cee69704f37bc939f91f22bdc7 100644 --- a/logback-examples/src/main/java/chapters/onJoran/calculator/AddAction.java +++ b/logback-examples/src/main/java/chapters/onJoran/calculator/AddAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/Calculator1.java b/logback-examples/src/main/java/chapters/onJoran/calculator/Calculator1.java index d675029df7c077fe218bc6203ddbef0f6904b575..46f5dc9ee173857c7e05b283737dff695e60e7bf 100644 --- a/logback-examples/src/main/java/chapters/onJoran/calculator/Calculator1.java +++ b/logback-examples/src/main/java/chapters/onJoran/calculator/Calculator1.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -19,7 +19,7 @@ import java.util.Map; import ch.qos.logback.core.Context; import ch.qos.logback.core.ContextBase; import ch.qos.logback.core.joran.action.Action; -import ch.qos.logback.core.joran.spi.Pattern; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.util.StatusPrinter; import chapters.onJoran.SimpleConfigurator; @@ -34,15 +34,15 @@ public class Calculator1 { public static void main(String[] args) throws Exception { Context context = new ContextBase(); - Map ruleMap = new HashMap(); + Map ruleMap = new HashMap(); // Associate "/computation" pattern with ComputationAction1 - ruleMap.put(new Pattern("/computation"), new ComputationAction1()); + ruleMap.put(new ElementSelector("/computation"), new ComputationAction1()); // Other associations - ruleMap.put(new Pattern("/computation/literal"), new LiteralAction()); - ruleMap.put(new Pattern("/computation/add"), new AddAction()); - ruleMap.put(new Pattern("/computation/multiply"), new MultiplyAction()); + ruleMap.put(new ElementSelector("/computation/literal"), new LiteralAction()); + ruleMap.put(new ElementSelector("/computation/add"), new AddAction()); + ruleMap.put(new ElementSelector("/computation/multiply"), new MultiplyAction()); SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap); // link the configurator with its context diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/Calculator2.java b/logback-examples/src/main/java/chapters/onJoran/calculator/Calculator2.java index e34eee01bc16cd91f89c458801c0b3e9f3573e81..935e7b8ea6f492f58541af13e99a745619466aaf 100644 --- a/logback-examples/src/main/java/chapters/onJoran/calculator/Calculator2.java +++ b/logback-examples/src/main/java/chapters/onJoran/calculator/Calculator2.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -19,8 +19,8 @@ import java.util.Map; import ch.qos.logback.core.Context; import ch.qos.logback.core.ContextBase; import ch.qos.logback.core.joran.action.Action; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.joran.spi.JoranException; -import ch.qos.logback.core.joran.spi.Pattern; import ch.qos.logback.core.util.StatusPrinter; import chapters.onJoran.SimpleConfigurator; @@ -38,16 +38,16 @@ import chapters.onJoran.SimpleConfigurator; */ public class Calculator2 { public static void main(String[] args) throws Exception { - Map ruleMap = new HashMap(); + Map ruleMap = new HashMap(); // Note the wild card character '*', in the paterns, signifying any level // of nesting. - ruleMap.put(new Pattern("*/computation"), new ComputationAction2()); + ruleMap.put(new ElementSelector("*/computation"), new ComputationAction2()); - ruleMap.put(new Pattern("*/computation/literal"), new LiteralAction()); - ruleMap.put(new Pattern("*/computation/add"), new AddAction()); - ruleMap.put(new Pattern("*/computation/multiply"), new MultiplyAction()); + ruleMap.put(new ElementSelector("*/computation/literal"), new LiteralAction()); + ruleMap.put(new ElementSelector("*/computation/add"), new AddAction()); + ruleMap.put(new ElementSelector("*/computation/multiply"), new MultiplyAction()); Context context = new ContextBase(); SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap); diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/ComputationAction1.java b/logback-examples/src/main/java/chapters/onJoran/calculator/ComputationAction1.java index 4c017752679509dc86b9472d1cd7ab81a666e9e7..c02cc0de993a0e392c6e6fa4e02c5f7ae761a4d0 100644 --- a/logback-examples/src/main/java/chapters/onJoran/calculator/ComputationAction1.java +++ b/logback-examples/src/main/java/chapters/onJoran/calculator/ComputationAction1.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/ComputationAction2.java b/logback-examples/src/main/java/chapters/onJoran/calculator/ComputationAction2.java index 76fd15b0cbca106f19fc3d25edefaa7d4b5bf6c2..287866cb970ce479591e7c15bdcbee0df75a91d6 100644 --- a/logback-examples/src/main/java/chapters/onJoran/calculator/ComputationAction2.java +++ b/logback-examples/src/main/java/chapters/onJoran/calculator/ComputationAction2.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/LiteralAction.java b/logback-examples/src/main/java/chapters/onJoran/calculator/LiteralAction.java index 9aefbf5ca1295abc099c1724663104a4db976190..4883c44bf54212418394c936896699fe04c26dfb 100644 --- a/logback-examples/src/main/java/chapters/onJoran/calculator/LiteralAction.java +++ b/logback-examples/src/main/java/chapters/onJoran/calculator/LiteralAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/onJoran/calculator/MultiplyAction.java b/logback-examples/src/main/java/chapters/onJoran/calculator/MultiplyAction.java index ba371158de71fe548371bef673abc3c6fe5c0391..0e19e1b422d53a516670d1a3d94938c04f7d4df6 100644 --- a/logback-examples/src/main/java/chapters/onJoran/calculator/MultiplyAction.java +++ b/logback-examples/src/main/java/chapters/onJoran/calculator/MultiplyAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/onJoran/helloWorld/HelloWorld.java b/logback-examples/src/main/java/chapters/onJoran/helloWorld/HelloWorld.java index ac0f7c0ba044a861241bd16e43edc474b5afce56..ae850e74ff1956e454a6b6ca29d6648d5d8dde30 100644 --- a/logback-examples/src/main/java/chapters/onJoran/helloWorld/HelloWorld.java +++ b/logback-examples/src/main/java/chapters/onJoran/helloWorld/HelloWorld.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -19,7 +19,7 @@ import java.util.Map; import ch.qos.logback.core.Context; import ch.qos.logback.core.ContextBase; import ch.qos.logback.core.joran.action.Action; -import ch.qos.logback.core.joran.spi.Pattern; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.util.StatusPrinter; import chapters.onJoran.SimpleConfigurator; @@ -31,10 +31,10 @@ import chapters.onJoran.SimpleConfigurator; */ public class HelloWorld { public static void main(String[] args) throws Exception { - Map ruleMap = new HashMap(); + Map ruleMap = new HashMap(); // Associate "hello-world" pattern with HelloWorldAction - ruleMap.put(new Pattern("hello-world"), new HelloWorldAction()); + ruleMap.put(new ElementSelector("hello-world"), new HelloWorldAction()); // Joran needs to work within a context. Context context = new ContextBase(); diff --git a/logback-examples/src/main/java/chapters/onJoran/helloWorld/HelloWorldAction.java b/logback-examples/src/main/java/chapters/onJoran/helloWorld/HelloWorldAction.java index 083e9de75b0d0acf2726719a80be4cc26e75ad88..9777e5871f645b2670781e105066f7b73edd1f6d 100644 --- a/logback-examples/src/main/java/chapters/onJoran/helloWorld/HelloWorldAction.java +++ b/logback-examples/src/main/java/chapters/onJoran/helloWorld/HelloWorldAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/onJoran/implicit/NOPAction.java b/logback-examples/src/main/java/chapters/onJoran/implicit/NOPAction.java index 3f94998cd27e9d1b49e9e3625240335195ba0d66..d70ececa9d3d22ea56b29a007c21b0b34cfb61ec 100644 --- a/logback-examples/src/main/java/chapters/onJoran/implicit/NOPAction.java +++ b/logback-examples/src/main/java/chapters/onJoran/implicit/NOPAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by diff --git a/logback-examples/src/main/java/chapters/onJoran/implicit/PrintMe.java b/logback-examples/src/main/java/chapters/onJoran/implicit/PrintMe.java index ea160b64f93cd6b25342f7ab8e1206ca9b05181a..3a68a1c568e157aae63a28512db6d510571345c3 100644 --- a/logback-examples/src/main/java/chapters/onJoran/implicit/PrintMe.java +++ b/logback-examples/src/main/java/chapters/onJoran/implicit/PrintMe.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -22,7 +22,7 @@ import ch.qos.logback.core.Context; import ch.qos.logback.core.ContextBase; import ch.qos.logback.core.joran.action.Action; import ch.qos.logback.core.joran.action.ImplicitAction; -import ch.qos.logback.core.joran.spi.Pattern; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.util.StatusPrinter; import chapters.onJoran.SimpleConfigurator; @@ -40,10 +40,10 @@ public class PrintMe { public static void main(String[] args) throws Exception { Context context = new ContextBase(); - Map ruleMap = new HashMap(); + Map ruleMap = new HashMap(); // we start with the rule for the top-most (root) element - ruleMap.put(new Pattern("*/foo"), new NOPAction()); + ruleMap.put(new ElementSelector("*/foo"), new NOPAction()); // Add an implicit action. List iaList = new ArrayList(); diff --git a/logback-examples/src/main/java/chapters/onJoran/implicit/PrintMeImplicitAction.java b/logback-examples/src/main/java/chapters/onJoran/implicit/PrintMeImplicitAction.java index 2795f0ae9c8954e1fec2f8dbc0bf03e3e7149815..20b37b54399c70c19fc29f6d82ca2bd566c6ac12 100644 --- a/logback-examples/src/main/java/chapters/onJoran/implicit/PrintMeImplicitAction.java +++ b/logback-examples/src/main/java/chapters/onJoran/implicit/PrintMeImplicitAction.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -13,11 +13,11 @@ */ package chapters.onJoran.implicit; +import ch.qos.logback.core.joran.spi.ElementPath; import org.xml.sax.Attributes; import ch.qos.logback.core.joran.action.ImplicitAction; import ch.qos.logback.core.joran.spi.InterpretationContext; -import ch.qos.logback.core.joran.spi.Pattern; /** * @@ -28,7 +28,7 @@ import ch.qos.logback.core.joran.spi.Pattern; */ public class PrintMeImplicitAction extends ImplicitAction { - public boolean isApplicable(Pattern pattern, Attributes attributes, + public boolean isApplicable(ElementPath elementPath, Attributes attributes, InterpretationContext ec) { String printmeStr = attributes.getValue("printme"); diff --git a/logback-examples/src/main/java/chapters/onJoran/newRule/NewRuleCalculator.java b/logback-examples/src/main/java/chapters/onJoran/newRule/NewRuleCalculator.java index 05c8b86a46082ed6f9c6d7b38d9e1506fa21e9dc..f0fe6c9e96cf3890c495a62f36a0c4277ee37e80 100644 --- a/logback-examples/src/main/java/chapters/onJoran/newRule/NewRuleCalculator.java +++ b/logback-examples/src/main/java/chapters/onJoran/newRule/NewRuleCalculator.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -20,7 +20,7 @@ import ch.qos.logback.core.Context; import ch.qos.logback.core.ContextBase; import ch.qos.logback.core.joran.action.Action; import ch.qos.logback.core.joran.action.NewRuleAction; -import ch.qos.logback.core.joran.spi.Pattern; +import ch.qos.logback.core.joran.spi.ElementSelector; import ch.qos.logback.core.util.StatusPrinter; import chapters.onJoran.SimpleConfigurator; import chapters.onJoran.calculator.ComputationAction1; @@ -39,16 +39,16 @@ public class NewRuleCalculator { Context context = new ContextBase(); - Map ruleMap = new HashMap(); + Map ruleMap = new HashMap(); // we start with the rule for the top-most (root) element - ruleMap.put(new Pattern("*/computation"), new ComputationAction1()); + ruleMap.put(new ElementSelector("*/computation"), new ComputationAction1()); // Associate "/new-rule" pattern with NewRuleAction from the // org.apache.joran.action package. // // We will let the XML file to teach the Joran interpreter about new rules - ruleMap.put(new Pattern("/computation/newRule"), new NewRuleAction()); + ruleMap.put(new ElementSelector("/computation/newRule"), new NewRuleAction()); SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap); // link the configurator with its context diff --git a/logback-examples/src/main/java/chapters/appenders/socket/SocketRemoteServer.java b/logback-examples/src/main/java/chapters/receivers/socket/AppenderExample.java old mode 100644 new mode 100755 similarity index 54% rename from logback-examples/src/main/java/chapters/appenders/socket/SocketRemoteServer.java rename to logback-examples/src/main/java/chapters/receivers/socket/AppenderExample.java index ca39388b91e84f134d5fd6b4cd5a9c2f22b2245d..926a55aa94bd162dee22f3c504978a2666beebe3 --- a/logback-examples/src/main/java/chapters/appenders/socket/SocketRemoteServer.java +++ b/logback-examples/src/main/java/chapters/receivers/socket/AppenderExample.java @@ -1,22 +1,17 @@ -/* - * File created on Apr 2, 2013 - * - * Copyright 2008-2011 Virginia Polytechnic Institute and State University - * - * Licensed 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 +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation * - * 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. + * or (per the licensee's choosing) * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. */ -package chapters.appenders.socket; +package chapters.receivers.socket; import java.io.BufferedReader; import java.io.InputStreamReader; @@ -28,15 +23,15 @@ import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.joran.JoranConfigurator; /** - * This application loads a configuration containing a - * {@link ServerSocketAppender} and then allows the user to enter messages - * which will be relayed to remote clients via this appender. + * This application loads a configuration containing some form of + * socket appender and then allows the user to enter messages + * which will be relayed to remote clients via the appender. */ -public class SocketRemoteServer { +public class AppenderExample { static void usage(String msg) { System.err.println(msg); - System.err.println("Usage: java " + SocketRemoteServer.class.getName() + + System.err.println("Usage: java " + AppenderExample.class.getName() + " configFile\n" + " configFile a logback configuration file" + " in XML format."); @@ -52,13 +47,13 @@ public class SocketRemoteServer { if (configFile.endsWith(".xml")) { LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + lc.reset(); JoranConfigurator configurator = new JoranConfigurator(); - lc.stop(); configurator.setContext(lc); configurator.doConfigure(configFile); } - Logger logger = LoggerFactory.getLogger(SocketRemoteServer.class); + Logger logger = LoggerFactory.getLogger(AppenderExample.class); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); diff --git a/logback-examples/src/main/java/chapters/appenders/socket/SocketServer.java b/logback-examples/src/main/java/chapters/receivers/socket/ReceiverExample.java old mode 100644 new mode 100755 similarity index 74% rename from logback-examples/src/main/java/chapters/appenders/socket/SocketServer.java rename to logback-examples/src/main/java/chapters/receivers/socket/ReceiverExample.java index a4c8338cf5a67274616c44b8b0d68119948dddef..b9cf043a3fd9fbd2f38eb4d0b03e518cd6da5f4c --- a/logback-examples/src/main/java/chapters/appenders/socket/SocketServer.java +++ b/logback-examples/src/main/java/chapters/receivers/socket/ReceiverExample.java @@ -1,6 +1,6 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2011, QOS.ch. All rights reserved. + * Copyright (C) 1999-2013, QOS.ch. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by @@ -11,23 +11,23 @@ * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ -package chapters.appenders.socket; +package chapters.receivers.socket; import org.slf4j.LoggerFactory; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.joran.JoranConfigurator; - /** - * This application uses an SSLSocketServer that log messages to a - * server on a host and port specified by the user. It waits for the - * user to type a message which will be sent to the server. - * */ -public class SocketServer { + * This application loads a configuration containing a + * receiver component and logs events received from the remote + * appender according to the local configuration. + */ +public class ReceiverExample { + static void usage(String msg) { System.err.println(msg); - System.err.println("Usage: java " + SocketServer.class.getName() + + System.err.println("Usage: java " + ReceiverExample.class.getName() + " configFile\n" + " configFile a logback configuration file" + " in XML format."); @@ -43,12 +43,13 @@ public class SocketServer { if (configFile.endsWith(".xml")) { LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + lc.reset(); JoranConfigurator configurator = new JoranConfigurator(); - lc.stop(); configurator.setContext(lc); configurator.doConfigure(configFile); } Thread.sleep(Long.MAX_VALUE); } + } diff --git a/logback-examples/src/main/java/chapters/receivers/socket/appender1.xml b/logback-examples/src/main/java/chapters/receivers/socket/appender1.xml new file mode 100644 index 0000000000000000000000000000000000000000..f50b2ad01576393eae2195c12586e6ac562fb900 --- /dev/null +++ b/logback-examples/src/main/java/chapters/receivers/socket/appender1.xml @@ -0,0 +1,22 @@ + + + + + + + + + + ${host} + ${port} + 10000 + + + + + + + + + + diff --git a/logback-examples/src/main/java/chapters/receivers/socket/appender2.xml b/logback-examples/src/main/java/chapters/receivers/socket/appender2.xml new file mode 100644 index 0000000000000000000000000000000000000000..020eb51a98de2ca5a2b3a94ad9b30bc2f97a5eff --- /dev/null +++ b/logback-examples/src/main/java/chapters/receivers/socket/appender2.xml @@ -0,0 +1,28 @@ + + + + + + + + + + ${host} + ${port} + 10000 + + + ${truststore} + ${password} + + + + + + + + + + + + diff --git a/logback-examples/src/main/java/chapters/appenders/socket/remoteServer.xml b/logback-examples/src/main/java/chapters/receivers/socket/appender3.xml similarity index 89% rename from logback-examples/src/main/java/chapters/appenders/socket/remoteServer.xml rename to logback-examples/src/main/java/chapters/receivers/socket/appender3.xml index acceeb3010020823c52eaf4aaf1ea745bef60d82..4ab2c5d6b6645f702169f81d8691cb71fffee8ef 100644 --- a/logback-examples/src/main/java/chapters/appenders/socket/remoteServer.xml +++ b/logback-examples/src/main/java/chapters/receivers/socket/appender3.xml @@ -9,7 +9,6 @@ ${port} - ${includeCallerData} diff --git a/logback-examples/src/main/java/chapters/appenders/socket/ssl/remoteServer.xml b/logback-examples/src/main/java/chapters/receivers/socket/appender4.xml similarity index 91% rename from logback-examples/src/main/java/chapters/appenders/socket/ssl/remoteServer.xml rename to logback-examples/src/main/java/chapters/receivers/socket/appender4.xml index 4b90daefcefd0adb41a524a04a886b5dca90e2df..5f670b185bb1ac624fcb5a9ebc3be5f092a66763 100644 --- a/logback-examples/src/main/java/chapters/appenders/socket/ssl/remoteServer.xml +++ b/logback-examples/src/main/java/chapters/receivers/socket/appender4.xml @@ -9,7 +9,6 @@ ${port} - ${includeCallerData} ${keystore} diff --git a/logback-examples/src/main/java/chapters/appenders/socket/server3.xml b/logback-examples/src/main/java/chapters/receivers/socket/receiver1.xml similarity index 76% rename from logback-examples/src/main/java/chapters/appenders/socket/server3.xml rename to logback-examples/src/main/java/chapters/receivers/socket/receiver1.xml index f9e1e2294b5eb5864373078ff76bf5d6a4f2042e..b66cb886aca590e3597752991682254dfdec4b58 100644 --- a/logback-examples/src/main/java/chapters/appenders/socket/server3.xml +++ b/logback-examples/src/main/java/chapters/receivers/socket/receiver1.xml @@ -1,7 +1,7 @@ - + @@ -16,9 +16,9 @@ - + ${port} - + diff --git a/logback-examples/src/main/java/chapters/appenders/socket/ssl/server2.xml b/logback-examples/src/main/java/chapters/receivers/socket/receiver2.xml similarity index 76% rename from logback-examples/src/main/java/chapters/appenders/socket/ssl/server2.xml rename to logback-examples/src/main/java/chapters/receivers/socket/receiver2.xml index 395b44d0966e90c66039ab504eb2f6f7f9daf86b..87575267c7ae1d1d641adabdc7ceaddb099f608a 100644 --- a/logback-examples/src/main/java/chapters/appenders/socket/ssl/server2.xml +++ b/logback-examples/src/main/java/chapters/receivers/socket/receiver2.xml @@ -1,22 +1,22 @@ - + - + %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n - + - + ${port} @@ -24,8 +24,8 @@ ${password} - - + + diff --git a/logback-examples/src/main/java/chapters/receivers/socket/receiver3.xml b/logback-examples/src/main/java/chapters/receivers/socket/receiver3.xml new file mode 100644 index 0000000000000000000000000000000000000000..a790440732203530d862c2996ca2f010dddb83a7 --- /dev/null +++ b/logback-examples/src/main/java/chapters/receivers/socket/receiver3.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n + + + + + + + + + ${host} + ${port} + 10000 + + + + + + diff --git a/logback-examples/src/main/java/chapters/appenders/socket/ssl/remoteClient.xml b/logback-examples/src/main/java/chapters/receivers/socket/receiver4.xml similarity index 68% rename from logback-examples/src/main/java/chapters/appenders/socket/ssl/remoteClient.xml rename to logback-examples/src/main/java/chapters/receivers/socket/receiver4.xml index 707ff433a3e3cd4c64048996ddfa2342f81386c6..3884e4d5fc05808d684ef36a397e91eb7c2329fd 100644 --- a/logback-examples/src/main/java/chapters/appenders/socket/ssl/remoteClient.xml +++ b/logback-examples/src/main/java/chapters/receivers/socket/receiver4.xml @@ -1,19 +1,23 @@ - + - - + + - %date %-5level [%thread] %logger - %message%n - + %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n + - - ${host} + + + + + + ${host} ${port} 10000 @@ -22,12 +26,8 @@ ${password} - + - - - - diff --git a/logback-site/pom.xml b/logback-site/pom.xml index 2eafe501dafd7c025d800f440915880e130ad55e..16b396061f644f5845a9d328d4f70b8eca367b48 100644 --- a/logback-site/pom.xml +++ b/logback-site/pom.xml @@ -5,7 +5,7 @@ ch.qos.logback logback-parent - 1.0.12-SNAPSHOT + 2.0.0-SNAPSHOT 4.0.0 diff --git a/logback-site/src/site/images.src/serverSocketReceiver.odg b/logback-site/src/site/images.src/serverSocketReceiver.odg new file mode 100644 index 0000000000000000000000000000000000000000..bb7fcd3e35280e5886616a4befc2b056726c0b1a Binary files /dev/null and b/logback-site/src/site/images.src/serverSocketReceiver.odg differ diff --git a/logback-site/src/site/images.src/socketReceiver.odg b/logback-site/src/site/images.src/socketReceiver.odg new file mode 100644 index 0000000000000000000000000000000000000000..9b7dffd40ff0b2e9727e4013c3ef9accf8990ba7 Binary files /dev/null and b/logback-site/src/site/images.src/socketReceiver.odg differ diff --git a/logback-site/src/site/pages/codes.html b/logback-site/src/site/pages/codes.html index 709397a5e085cf81c6faf3bb0c3d1582e92ffe24..7e60d60d2f7ffb9f5c6d3e66b47b9d427189c6bd 100755 --- a/logback-site/src/site/pages/codes.html +++ b/logback-site/src/site/pages/codes.html @@ -386,18 +386,18 @@ On Windows -

On certain platforms, e.g. Windows, a log file cannot be renamed - if there are handles referencing it. For example, when the file is - read by another process such as less, - tail, etc. During application hot-redeployment, the old - instance of the application will have open references to log files - until the old instance is completely shutdown or until the - stop() method on its On the Windows platform a log file cannot be renamed if there are + handles referencing it. For example, when the file is read by + another process such as less, tail, + etc. During application hot-redeployment, the old instance of the + application will have open references to log files until the old + instance is completely shutdown or until the stop() + method on its LoggerContext is invoked.

-

On the Windows platform, Process Explorer can help you locate the processes which reference a given file (Find -> Find Handle or DLL). On Linux, you can use @@ -405,20 +405,23 @@ pathToFile command to find which process has the file given by pathToFile open.

-

In practice, it can be hard to ensure that there are no file - handle references to log files. It can be easier to avoid file - renaming altogether. As a first step, let us note that for - TimeBasedRollingPolicy, the file option can be omitted. If omitted, no - file renaming will be performed during roll over. Thus, in order to - avoid file renaming errors just leave blank the file option of - RollingFileAppender, as shown in the next configuration - snippet. +

Rolling might also fail due to incorrect file permission + settings. On windows, renaming a file requires the "modify" + permission which is different than the permission to "write" to the + file.

+ + +

In practice, it can be hard to set the right permissions or to + ensure that there are no file handle references to log files. Under + such circumstances, it can be easier to avoid file renaming + altogether. File renaming can be avoided by omitting the file property in + TimeBasedRollingPolicy, as shown in the next + configuration snippet.

<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
-  <!-- file option left unset/blank -->
+  <!-- file property left unset/blank -->
   <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
     <fileNamePattern>mylog.%d{yyyy-MM-dd}.log</fileNamePattern>
   </rollingPolicy>
diff --git a/logback-site/src/site/pages/dependencies.html b/logback-site/src/site/pages/dependencies.html
index 7855cae63d33d92150c21a4497396572876a7374..7853588705ba50ca78b703a0d3f1023877d24353 100644
--- a/logback-site/src/site/pages/dependencies.html
+++ b/logback-site/src/site/pages/dependencies.html
@@ -22,28 +22,32 @@
 	
 		

Dependencies per module

+

As of version 1.0.12, logback requires JDK 1.6 to build, + however, it is inteded to run under JDK 1.5 (with the exception of + SSL related functionality).

+

Each logback module has a different set of dependencies. These are listed below in a separate table per module.

logback-core

- +
- + - + - + + + + + + - + - - - - - -
Component dependencies
Overall -
    -
  • JDK 1.5 -
  • -
-
  • JDK 1.5
ch.qos.logback.core.net.ssl.*
  • JDK 1.6
JaninoEventEvaluatorBase and derived classes
    @@ -52,7 +56,7 @@
SMTPAppenderBase and derived classes
    @@ -72,13 +76,13 @@

    logback-classic

    - +
    - + - + - + - +
    Component dependencies
    Overall
      @@ -88,7 +92,7 @@
    Overall
      @@ -110,7 +114,7 @@
    ch.qos.logback.classic.selector.*
      @@ -120,7 +124,7 @@
    c.q.l.c.boolex.JaninoEventEvaluator
    -

    Overview of rolling policies

    +

    Overview of rolling + policies

    RollingPolicy @@ -774,10 +769,8 @@ public interface RollingPolicy extends LifeCycle { ================= --> -

    - TimeBasedRollingPolicy +

    TimeBasedRollingPolicy

    -

    FixedWindowRollingPolicy +

    FixedWindowRollingPolicy

    When rolling over, -

    - Size - and time based archiving +

    Size and + time based archiving

    Sometimes you may wish to archive files essentially by date but @@ -1517,9 +1507,8 @@ public interface TriggeringPolicy<E> extends LifeCycle {

    -

    - SocketAppender and SSLSocketAppender +

    SocketAppender and + SSLSocketAppender

    The appenders covered thus far are only able to log to local @@ -1660,20 +1649,21 @@ public interface TriggeringPolicy<E> extends LifeCycle { for servers that can be used to receive logging events from SocketAppender or SSLSocketAppender.

      +
    • ServerSocketReceiver and its SSL-enabled + counterpart SSLServerSocketReceiver are receiver + components which can be configured in the logback.xml + configuration file of an application in order receive events + from a remote socket appender. See + Receivers for configuration details and usage examples. +
    • SimpleSocketServer and its SSL-enabled counterpart - SimpleSSLSocketServer, which both offer an + SimpleSSLSocketServer both offer an easy-to-use standalone Java application that is designed to be configured and run from your shell's command line interface. These applications simply wait for logging events from SocketAppender or SSLSocketAppender clients. Each received event is logged according to local server - policy. -
    • -
    • SocketServer and its SSL-enabled counterpart - SSLSocketServer which can be configured in the - logback.xml configuration file of any application - that uses Logback Classic, allowing any application to be a - receiver for remote logging events. + policy. Usage examples are given below.
    @@ -1824,7 +1814,7 @@ public interface TriggeringPolicy<E> extends LifeCycle {

    java -Djavax.net.ssl.keyStore=src/main/java/chapters/appenders/socket/ssl/keystore.jks \ -Djavax.net.ssl.keyStorePassword=changeit \ ch.qos.logback.classic.net.SimpleSSLSocketServer 6000 \ - src/main/java/chapters/appenders/socket/ssl/server1.xml + src/main/java/chapters/appenders/socket/ssl/server.xml

    This example runs SimpleSSLSocketServer using an @@ -1888,7 +1878,7 @@ public interface TriggeringPolicy<E> extends LifeCycle {

    java -Dhost=localhost -Dport=6000 \ - -Dtruststore=file:src/main/java/chapters/appenders/socket/ssl/keystore.jks \ + -Dtruststore=file:src/main/java/chapters/appenders/socket/ssl/truststore.jks \ -Dpassword=changeit \ chapters.appenders.socket.SocketClient2 src/main/java/chapters/appenders/socket/ssl/client.xml

    @@ -1900,225 +1890,30 @@ public interface TriggeringPolicy<E> extends LifeCycle {

    Note that the truststore property given on the command - line specifies a file URL that identifies the location of the trust - store. You may also use a classpath URL as described in - Using SSL. + line specifies a file URL that identifies the location of the + trust store. You may also use a classpath URL as described in Using SSL.

    -

    Note also that the trust store specified on the comamnd-line - is the same file we referenced when starting the server. This is a - convenience made possible by the fact that we are utilizing a - self-signed certificate suitable for testing and experimentation, only. - In a production setting you would not want to install - your server's X.509 credential (consisting of a private key and - certificate) in each of your client applications. You - would instead utilize a trust store containing only trusted root - certificate(s) as described in Using SSL. -

    - -

    As we saw previously at server startup, because the - client configuration has debug="true" specified on the - root element, the client's startup logging includes the details of - the SSL configuration as aid to auditing local policy conformance. +

    As we saw previously at server startup, because the client + configuration has debug="true" specified on the root + element, the client's startup logging includes the details of the + SSL configuration as aid to auditing local policy conformance.

    -

    Using SocketServer and SSLSocketServer

    -

    While SimpleSocketServer and - SimpleSSLSocketServer both provide an easy-to-use - standalone logging server application, you may wish instead to - integrate logging server functionality into an existing application - utilizing Logback Classic. This ability is provided by - - SocketServer and its SSL-enabled counterpart - - SSLSocketServer. -

    - -

    SocketServer and SSLSocketServer are - components that are configured in the same manner as appenders, - loggers, and the like — by placing the appropriate configuration - properties in your application's logback.xml configuration - file. This allows any application using Logback Classic - to be a receiver for remote logging events. -

    - -

    The SocketServer component provides the following - configurable properties:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Property NameTypeDescription
    addressStringThe local network interface address on which the server - will listen. If this property is not specified, the server - will listen on all network interfaces.
    portintThe TCP port on which the server will listen. If this - property is not specified, a default value will be used.
    sslSSLConfigurationSupported only for SSLSocketServer, this - property provides the SSL configuration that will be used by - the server, as described in Using SSL. -
    threadPoolThreadPoolFactoryBeanThis property specifies configuration for a thread pool that will - be used to manage the appender's thread resources. In most cases, - this configuration is not required, as the defaults are generally - adequate. See - ThreadPoolFactoryBean for a description of the - configurable properties and recommended settings. -
    - -

    For example, the following configuration uses the - SocketServer component with a minimal appender and - logger configuration. -

    - -

    Example: Basic SocketServer Configuration - (logback-examples/src/main/java/chapters/appenders/socket/server3.xml)

    - View as .groovy -
    <configuration debug="true">
    -  
    -  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    -    <encoder>
    -      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
    -    </encoder>
    -  </appender>
    -  
    -  <root level="DEBUG">
    -    <appender-ref ref="CONSOLE" />
    -  </root>
    -
    -  <server class="ch.qos.logback.classic.net.server.SocketServer">
    -    <port>${port}</port>
    -  </server>
    -  
    -</configuration>
    - -

    Note that the server configuration - property identifies the server class that we wish to use. Either - SocketServer or SSLSocketServer may be - specified here. -

    - -

    Our example server application is very similar in function and - design to SimpleSocketServer. It simply accepts a - path for a logback configuration file as a command line argument, - and runs the given configuration. While our example is somewhat - trivial, keep in mind that you can configure logback's - SocketServer (and SSLSocketServer) - component in any application. -

    - -

    We can run our example server application as follows:

    -

    java -Dport=6000 chapters.appenders.socket.SocketServer \ - src/main/java/chapters/appenders/socket/server3.xml -

    - -

    We can connect to the running server just as shown in the previous - examples for using SimpleSocketServer. -

    - -

    A minimal server configuration using SSLSocketServer - follows.

    - -

    Example: Basic SSLSocketServer Configuration - (logback-examples/src/main/java/chapters/appenders/socket/ssl/server2.xml)

    - View as .groovy -
    <configuration debug="true">
    -  
    -  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    -    <encoder>
    -      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
    -    </encoder>
    -  </appender>
    -  
    -  <root level="DEBUG">
    -    <appender-ref ref="CONSOLE" />
    -  </root>
    -
    -  <server class="ch.qos.logback.classic.net.server.SSLSocketServer">
    -    <port>${port}</port>
    -    <ssl>
    -      <keyStore>
    -        <location>${keystore}</location>
    -        <password>${password}</password>
    -      </keyStore>
    -    </ssl>
    -  </server>
    -  
    -</configuration>
    - -

    The essential differences between this configuration and the - previous example using SocketServer are the specification - of SSLSocketServer in the class attribute and - the presence of the nested ssl property, - which is used here to specify the location and password for the - key store containing the server's private key and certificate, using - substitution variables. The ssl property - of the server component accepts the same nested configuration - properties as those accepted by SSLSocketAppender. - See Using SSL for details on - configuring the SSL properties for SSLSocketServer. -

    - -

    We can now run our SSL-enabled server configuration using the - same example server application, by specifying values for the - substitution variables in our configuration and referencing the - appropriate configuration file:

    - -

    java -Dport=6000 \ - -Dkeystore=file:src/main/java/chapters/appenders/socket/ssl/keystore.jks \ - -Dpassword=changeit \ - chapters.appenders.socket.SocketServer \ - src/main/java/chapters/appenders/socket/ssl/server2.xml -

    - -

    Note that the keystore property given on the command - line specifies a file URL that identifies the location of the key - store. You may also use a classpath URL as described in - Using SSL. -

    - -

    Also we must point out once again that our example X.509 - credential is suitable for testing and experimentation, only. - In a production setting, you should obtain an appropriate - X.509 credential to identify your logging server. See Using SSL for more information.

    - -

    Once our server is started, we can connect to it just as shown in - the previous examples for using - SimpleSSLSocketServer. -

    - -

    + +

    ServerSocketAppender and SSLServerSocketAppender

    -

    The SocketAppender component (and its SSL-enabled - counterpart) discussed previously are designed to allow an application - to connect to a remote logging server over the network for the purpose - of delivering logging events to the server. In some certain situations, - it may be inconvenient or infeasible to have an application initiate a - connection to a remote logging server. For these situations, Logback - Classic offers - - ServerSocketAppender. +

    The SocketAppender component (and its SSL-enabled + counterpart) discussed previously are designed to allow an + application to connect to a remote logging server over the network + for the purpose of delivering logging events to the server. In + some situations, it may be inconvenient or infeasible to have an + application initiate a connection to a remote logging server. For + these situations, Logback offers + ServerSocketAppender.

    Instead of initiating a connection to a remote logging server, @@ -2144,47 +1939,12 @@ public interface TriggeringPolicy<E> extends LifeCycle { of connection initiation is reversed. While SocketAppender acts as the active peer in establishing the connection to a logging server, ServerSocketAppender is passive; it listens for - incoming connections from clients. This difference is especially useful - in situations such as the following: -

    -
      -
    • For security reasons, a central logging server may be - located behind a network firewall that does not allow incoming - connections. Using a ServerSocketAppender component, an - application that wishes to deliver events to the central - logger can passively wait for the central logger to initiate the - connection from behind the firewall. -
    • -
    • -

      A central logging server may be using a SocketServer - component (or a SimpleSocketServer) to receive events from - one or more applications using a SocketServer component. - Events received at the central logger server could then be distributed - to interested downstream receivers using ServerSocketAppender. - The has the advantage that the central logging server may not need to - be configured for each new downstream receiver. The central logging - serve thus acts as a hub, receiving logging events from applications - and distributing them to interested clients.

      -

      This is particularly relevant for developer tools such as IDE - plugins or enterprise management tools that might want to receive - events from server-based applications for local display, filtering, - and alerting. Arranging for the central server to initiate a - connection to such tools may prove difficult, particularly when the - tool is running on a developer's workstation, which may indeed be - mobile.

      -
    • -
    + incoming connections from clients.

    -

    The - SocketRemote component (and its SSL-enabled counterpart, - - SSLSocketRemote) provide the companion client that - connects to a ServerSocketAppender. This component is - configured in logback.xml just like other logback components. - When a configuration containing the remote component is loaded, the - component will initiate a connection to a ServerSocketAppender - running at a remote host and port. -

    +

    The ServerSocketAppender subtypes are intended to be + used exclusively with Logback receiver components. See + Receivers for additional information on + this component type.

    The following configuration properties are supported by ServerSocketAppender:

    @@ -2229,73 +1989,15 @@ public interface TriggeringPolicy<E> extends LifeCycle { the appender, as described in Using SSL.
threadPoolThreadPoolFactoryBeanThis property specifies configuration for a thread pool that will - be used to manage the appender's thread resources. In most cases, - this configuration is not required, as the defaults are generally - adequate. See - ThreadPoolFactoryBean for a description of the - configurable properties and recommended settings. -
- -

The following configuration properties are supported by - SocketRemote:

- - - - - - - - - - - - - - - - - - - - - - - - - - -
Property NameTypeDescription
hostStringThe hostname or address of the remote server socket appender.
portintThe port number of the remote server socket appender.
reconnectionDelayint - A positive integer representing the number of milliseconds to wait - before attempting to reconnect after a connection failure. The - default value is 30000 (30 seconds). -
sslSSLConfigurationSupported only for SSLSocketRemote, this - property provides the SSL configuration that will be used for - this remote, as described in Using SSL. -
-

Using SocketRemote with ServerSocketAppender

- -

The configuration used for SocketRemote and - ServerSocketAppender is conceptually similar to that used - with SocketAppender and SocketServer. The - differences relate to the fact that the roles of client - and server are reversed. -

-

The following example illustrates a configuration that uses - ServerSocketAppender: + ServerSocketAppender:

Example: Basic ServerSocketAppender Configuration - (logback-examples/src/main/java/chapters/appenders/socket/remoteServer.xml)

-
<configuration debug="true">
+    (logback-examples/src/main/java/chapters/appenders/socket/server4.xml)

+
<configuration debug="true">
   <appender name="SERVER" 
     class="ch.qos.logback.classic.net.server.ServerSocketAppender">
     <port>${port}</port>
@@ -2316,124 +2018,45 @@ public interface TriggeringPolicy<E> extends LifeCycle {
     server.
     

-

Assuming you are in the logback-examples/ directory, - you can run this example configuration using the following command:

-

java -Dport=6000 -DincludeCallerData=false \ - chapters.appenders.socket.SocketRemoteServer \ - src/main/java/chapters/appenders/socket/remoteServer.xml -

- -

The example application loads the specified configuration and then - prompts the user to enter messages which will be relayed to connected - clients. Since there are no client connections, yet, messages entered at - this point will be discarded by the appender. -

- -

Example: Basic SocketRemote Configuration - (logback-examples/src/main/java/chapters/appenders/socket/remoteClient.xml)

- View as .groovy -
<configuration debug="true">
-    
-  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">    
-    <encoder>
-      <pattern>%date %-5level [%thread] %logger - %message%n</pattern>
-    </encoder>
-  </appender>
-  
-  <remote class="ch.qos.logback.classic.net.SocketRemote">
-    <host>${host}</host>
-    <port>${port}</port>
-    <reconnectionDelay>10000</reconnectionDelay>
-  </remote>
-  
-  <root level="DEBUG">
-    <appender-ref ref="CONSOLE" />
-  </root>  
-
-</configuration>
+

The following example illustrates a configuration using + SSLServerSocketAppender.

-

This configuration will cause logback to connect to an - ServerSocketAppender running on the host and port specified - by the host and port substitution variables. Logging - events received from the remote appender will be logged locally - (according to the configuration shown here) via a console appender. You - can configure any valid combination of appender and logger elements to - direct events received from the remote appender to an appropriate - destination. Moreover, you can configure an any number of remote - components to connect to as many remote appenders as you desire. -

- -

Assuming you are in the logback-examples/ directory, - you can run this example configuration using the following command:

-

java -Dhost=localhost -Dport=6000 \ - chapters.appenders.socket.SocketRemoteClient \ - src/main/java/chapters/appenders/socket/remoteClient.xml -

- -

The example loads the configuration and then simply waits for logging - events from the remote appender. If you run this example when the remote - appender is not running, you'll see connection refused messages - appearing in the log output, periodically. The SocketRemote - component will periodically attempt to reconnect to the remote appender - until it succeeds or until the logger context is shut down. The delay - interval between attempts is configurable using the - reconnectionDelay property as shown in the - example configuration.

- -

Using SSLSocketRemote with SSLServerSocketAppender

-

- Using SSLSocketRemote is quite similar. The essential - differences are in the class specified for the remote and the ability to - nest the ssl property to specify SSL configuration - properties. The following example illustrates a basic configuration: -

- -

Example: Basic SSLSocketRemote Configuration - (logback-examples/src/main/java/chapters/appenders/socket/ssl/remoteClient.xml)

- View as .groovy -
<configuration debug="true">
-  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">    
-    <encoder>
-      <pattern>%date %-5level [%thread] %logger - %message%n</pattern>
-    </encoder>         
-  </appender>
-  
-  <remote class="ch.qos.logback.classic.net.SSLSocketRemote">
-    <host>${host}</host>
+     

Example: Basic SSLServerSocketAppender Configuration + (logback-examples/src/main/java/chapters/appenders/socket/ssl/server3.xml)

+
<configuration debug="true">
+  <appender name="SERVER" 
+    class="ch.qos.logback.classic.net.server.SSLServerSocketAppender">
     <port>${port}</port>
-    <reconnectionDelay>10000</reconnectionDelay>
+    <includeCallerData>${includeCallerData}</includeCallerData>
     <ssl>
-      <trustStore>
-        <location>${truststore}</location>
+      <keyStore>
+        <location>${keystore}</location>
         <password>${password}</password>
-      </trustStore>
+      </keyStore>
     </ssl>
-  </remote>
-  
-  <root level="DEBUG">
-    <appender-ref ref="CONSOLE" />
+  </appender>
+
+  <root level="debug">
+    <appender-ref ref="SERVER" />
   </root>  
-   
-</configuration>
-

Note that the class attribute now specifies - SSLSocketRemote and that in addition to the configuration - properties shown in the previous example, this configuration contains - an SSL configuration specifying the location and password for a - trust store that will be used in validating that the remote appender is - trusted. See Using SSL for more information - on configuring SSL properties for a remote. -

- -

It is important to note that our example is using a self-signed - X.509 credential that suitable for testing and experimentation, only. - In a production setting, you should obtain an appropriate - X.509 credential to identify your trusted appender components. - See Using SSL for more information. -

- -

-

+</configuration> +
+ +

The principal differences between this configuration and the + previous configuration is that the appender's class attribute + identifies the SSLServerSocketAppender type, and the + presence of the nested ssl element which + specifies, in this example, configuration of a key store containing + an X.509 credential for the appender. See + Using SSL for information regarding SSL configuration properties. +

+ +

Because the ServerSocketAppender subtypes are designed + to be used with receiver components, we will defer presenting + illustrative examples to the chapter entitled + Receivers.

+

SMTPAppender

The -

The SMTPAppender keeps only the last 256 logging @@ -2853,8 +2475,8 @@ public interface TriggeringPolicy<E> extends LifeCycle { HTMLLayout does not use inline CSS.

-

Custom buffer size

+

Custom buffer + size

By default, the outgoing message will contain the last 256 messages seen by SMTPAppender. If your heart so @@ -2870,7 +2492,7 @@ public interface TriggeringPolicy<E> extends LifeCycle { <subject>%logger{20} - %m</subject> <layout class="ch.qos.logback.classic.html.HTMLLayout"/> - <cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTrackerImpl"> + <cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTracker"> <!-- send just one log entry per email --> <bufferSize>1</bufferSize> </cyclicBufferTracker> @@ -3037,10 +2659,8 @@ logger.error(notifyAdmin, chapters.appenders.mail.Marked_EMail src/main/java/chapters/appenders/mail/mailWithMarker.xml

-

Marker-based triggering with - JaninoEventEvaluator

+

Marker-based + triggering with JaninoEventEvaluator

Note that instead of using the marker-centric OnMarkerEvaluator, we could use the much more generic @@ -3070,10 +2690,8 @@ logger.error(notifyAdmin, </appender> </configuration>

-

Marker-based triggering with - GEventEvaluator

+

Marker-based + triggering with GEventEvaluator

Here is the equivalent evaluator using GEventEvaluator.

@@ -3100,9 +2718,7 @@ logger.error(notifyAdmin,

- -

Authentication/STARTTLS/SSL

+

Authentication/STARTTLS/SSL

SMTPAppender supports authentication via plain user passwords as well as both the STARTTLS and SSL @@ -3113,9 +2729,8 @@ logger.error(notifyAdmin, connection is encrypted right from the start.

-

SMTPAppender configuration for Gmail - (SSL)

+

class="doAnchor"name="gmailSSL">SMTPAppender configuration + for Gmail (SSL)

The next example shows you how to configure SMTPAppender for Gmail with the SSL protocol.

@@ -3148,8 +2763,8 @@ logger.error(notifyAdmin, </configuration>
-

SMTPAppender for Gmail (STARTTLS)

+

SMTPAppender for Gmail + (STARTTLS)

The next example shows you how to configure SMTPAppender for Gmail for the STARTTLS protocol.

@@ -3180,8 +2795,8 @@ logger.error(notifyAdmin, </configuration> -

SMTPAppender with MDCDiscriminator

+

SMTPAppender with MDCDiscriminator

+

As mentioned earlier, by specifying a discriminator other than the default one, SMTPAppender will generate email @@ -3231,8 +2846,8 @@ logger.error(notifyAdmin, host, greatly facilitating problem diagnosis.

-

Buffer management in very busy systems

+

Buffer management in + very busy systems

Internally, each distinct value returned by the discriminator will cause the creation of a new cyclic buffer. However, at most @@ -3274,9 +2889,7 @@ logger.error(notifyAdmin, -

DBAppender -

+

DBAppender

The DBAppender @@ -3738,9 +3351,8 @@ logger.error(notifyAdmin, --> -

JNDIConnectionSource

+

JNDIConnectionSource

@@ -4027,15 +3639,44 @@ logger.error(notifyAdmin,

+ + + + + + + + + + + + + + + + + +
Property NameTypeDescription
timeoutDurationA nested appender which has not been accessed beyond the + timeout duration is deemed stale. A + stale appender is closed and unreferenced by + SiftingAppender. The dfault value for timeout is 30 minutes.
maxAppenderCountintegerThe maximum number of nested appenders + SiftingAppender may create and track. Default + value for maxAppenderCount is + Integer.MAX_VALUE.
+

SiftingAppender achieves this feat by creating - child appenders on the fly. Child appenders are created based on a - template specified within the configuration of the + nested appenders on the fly. Nested appenders are created based on + a template specified within the configuration of the SiftingAppender itself (enclosed within the <sift> element, see example below). SiftingAppender is responsible for managing the lifecycle of child appenders. For example, SiftingAppender will automatically close and remove - any unused child appender. + any stale appender. A nested appender is considered stale when no + accesses it beyond the duration specified by the timeout parameter.

When handling a logging event, SiftingAppender @@ -4134,17 +3775,75 @@ logger.debug("Alice says hello");

distinct log files, "unknown.log" and "Alice.log".

-

AsyncAppender

+

local-scoped variables As of version + 1.0.12, properties defined in local scope within the configuration + file will be available to nested appenders. Moreover, you can define variables or dynamically + compute variables from within the the + <sift> element. Combining a variable from parts + defined outside and within the <sift> element is + also supported. +

+ +

Getting the + timeout right

+ +

For certain types of applications, it may be difficult to get + the timeout parameter right. If the + timeout is too small, a nested appender + might be removed just to be created anew a few seconds later. This + phenomenon is called trashing. If the timeout is too long and appenders are created + in quick succession, you might run out of resources. Similarly, + setting maxAppenderCount too low might + cause trashing as well. +

+ +

In many case, it may be easier to pinpoint a location in your + code after which a nested appender is no longer needed. If such a + location exists, even approximately, log from that location using + the FINALIZE_SESSION + marker. Whenever SiftingAppender sees a logging event marked as + FINALIZE_SESSION it will end-of-life the associated + nested appender. Upon reaching its end-of-life, a nested appender + will linger for a few seconds to process any late coming events + (if any) and then will be closed. +

+ +
import org.slf4j.Logger;
+import static ch.qos.logback.classic.ClassicConstants.FINALIZE_SESSION_MARKER;
+
+  void job(String jobId) {
+   
+    MDC.put("jobId", jobId);
+    logger.info("Starting job.");
+
+    ... do whather the job needs to do
+    
+    // will cause the nested appender reach end-of-life. It will
+    // linger for a few seconds.
+    logger.info(FINALIZE_SESSION_MARKER, "About to end the job");
+
+    try {
+      .. perform clean up
+    } catch(Exception e);  
+      // This log statement will be handled by the lingering appender. 
+      // No new appender will be created.
+      logger.error("unexpected error while cleaning up", e);
+    }
+  }
+
+
+ +

AsyncAppender

AsyncAppender logs ILoggingEvents asynchronously. It acts solely as an event dispatcher and must therefore reference another appender in order to do anything - useful. In order to avoid loss of logging events, this appender - should be closed. It is the user's responsibility to close - appenders, typically at the end of the application lifecycle. -

+ useful.

Lossy by default if 80% full AsyncAppender buffers events in a favorable effect on performance at the cost of event loss.

+

Application stop/redeploy Upon + application shutdown or redeploy, AsyncAppender must + be stopped in order to stop and reclaim the worker thread and to + flush the logging events from the queue. This can be achieved by + stopping the + LoggerContext which will close all appenders, including any + AsyncAppender instances.

+ +

Here is the list of properties admitted by AsyncAppender:

@@ -4265,8 +3973,8 @@ logger.debug("Alice says hello");

</configuration> -

Writing your own Appender

+

Writing your own + Appender

You can easily write your appender by subclassing @@ -4384,8 +4092,7 @@ public class CountingConsoleAppender extends AppenderBase<ILoggingEvent> {

-

Logback - Access

+

Logback Access

Most of the appenders found in logback-classic have their equivalent in logback-access. These work essentially in the same @@ -4393,8 +4100,8 @@ public class CountingConsoleAppender extends AppenderBase<ILoggingEvent> { will cover their use.

- -

SocketAppender and SSLSocketAppender

+

SocketAppender + and SSLSocketAppender

The @@ -4417,8 +4124,9 @@ public class CountingConsoleAppender extends AppenderBase<ILoggingEvent> { for classic's SocketAppender.

- -

ServerSocketAppender and SSLServerSocketAppender

+

ServerSocketAppender and + SSLServerSocketAppender

Like SocketAppender, the @@ -4436,22 +4144,24 @@ public class CountingConsoleAppender extends AppenderBase<ILoggingEvent> { over the Secure Sockets Layer (SSL).

-

- The properties of access' ServerSocketAppender are the same - as those available for classic's ServerSocketAppender. +

The properties of access' ServerSocketAppender are + the same as those available for classic's + ServerSocketAppender.

-
-

SMTPAppender

+ +

SMTPAppender

-

- Access' - SMTPAppender works in the same way as its Classic counterpart. - However, the evaluator option is rather different. - By default, a URLEvaluator object - is used by SMTPAppender. This evaluator contains a list of URLs that are - checked against the current request's URL. When one of the pages given to the - URLEvaluator is requested, SMTPAppender sends an email. +

Access' + SMTPAppender works in the same way as its Classic + counterpart. However, the evaluator + option is rather different. By default, a + URLEvaluator object is used by + SMTPAppender. This evaluator contains a list of URLs + that are checked against the current request's URL. When one of + the pages given to the URLEvaluator is requested, + SMTPAppender sends an email.

@@ -4483,12 +4193,11 @@ public class CountingConsoleAppender extends AppenderBase<ILoggingEvent> { included in the email.

- -

DBAppender

+

DBAppender

-

- DBAppender - is used to insert the access events into a database. +

DBAppender + is used to insert the access events into a database.

Two tables are used by DBAppender: @@ -4643,8 +4352,8 @@ public class CountingConsoleAppender extends AppenderBase<ILoggingEvent> { </configuration> -

SiftingAppender

+

SiftingAppender

The SiftingAppender in logback-access is quite similar to its logback-classic counterpart. The main difference is that in diff --git a/logback-site/src/site/pages/manual/architecture.html b/logback-site/src/site/pages/manual/architecture.html old mode 100644 new mode 100755 index 242fc2a53fe91522a4692d1cdc5970e83496693b..8d537749adb08e777b93ae66a22a173b1a00432e --- a/logback-site/src/site/pages/manual/architecture.html +++ b/logback-site/src/site/pages/manual/architecture.html @@ -10,10 +10,12 @@ - + + +

@@ -82,8 +84,7 @@ loggers.

-

Logger context

+

Logger context

The first and foremost advantage of any logging API over plain System.out.println resides in its ability to disable @@ -149,9 +150,8 @@ public interface Logger { -

Effective Level aka Level Inheritance -

+

Effective Level aka + Level Inheritance

Loggers may be assigned levels. The set of possible levels (TRACE, DEBUG, INFO, WARN and ERROR) are defined in the @@ -330,9 +330,8 @@ public interface Logger { parent X, which has an assigned level.

-

Printing methods and the basic selection - rule

+

Printing methods and + the basic selection rule

By definition, the printing method determines the level of a logging request. For example, if L is a logger @@ -662,8 +661,8 @@ Logger y = LoggerFactory.getLogger("wombat");

-

Parameterized logging

+

Parameterized + logging

Given that loggers in logback-classic implement the SLF4J's @@ -841,8 +840,7 @@ logger.debug("Value {} was inserted between {} and {}.", paramArray); -

Performance

+

Performance

One of the often-cited arguments against logging is its computational cost. This is a legitimate concern as even diff --git a/logback-site/src/site/pages/manual/configuration.html b/logback-site/src/site/pages/manual/configuration.html index ccf1b9f720f9ee305ee2f04e1457508fc3e10de8..201e6950fa43818104ae676ba5dd4d2bcc0a4628 100755 --- a/logback-site/src/site/pages/manual/configuration.html +++ b/logback-site/src/site/pages/manual/configuration.html @@ -12,12 +12,15 @@ - + + + +

@@ -49,8 +52,8 @@

-

Configuration in logback

+

Configuration in + logback

Inserting log requests into the application code requires a fair amount of planning and effort. Observation shows that @@ -120,8 +123,8 @@

-

Automatically configuring logback

+

Automatically + configuring logback

The simplest way to configure logback is by letting logback fall back to its default configuration. Let us give a taste of how @@ -255,8 +258,7 @@ public class Foo { directory accessible from the class path. Running the MyApp1 application should give identical results to its previous run.

-

Automatic +

Automatic printing of status messages in case of warning or errors

If warning or errors occur during the parsing @@ -381,9 +383,9 @@ public class Foo { generated in case of errors.

-

Specifying the location of the default - configuration file as a system property

+

Specifying the + location of the default configuration file as a system + property

You may specify the location of the default configuration file with a system property named @@ -400,9 +402,8 @@ public class Foo { locating the configuration file.

-

Automatically reloading configuration file upon - modification

+

Automatically reloading + configuration file upon modification

Logback-classic can scan for changes in its configuration file and automatically reconfigure itself when the @@ -478,7 +479,7 @@ public class Foo { ReconfigureOnChangeFilter is in reality "alive" only once every N logging operations. Depending on how often your application logs, the value of N can be modified on - the fly by logback. By default N is 16, altough it can go as high + the fly by logback. By default N is 16, although it can go as high as 2^16 (= 65536) for CPU-intensive applications.

@@ -489,9 +490,8 @@ public class Foo { -

Invoking JoranConfigurator - directly

+

Invoking + JoranConfigurator directly

Logback relies on a configuration library called Joran, part of logback-core. Logback's default configuration mechanism invokes @@ -552,12 +552,8 @@ public class MyApp3 { errors. Note that for multi-step configuration, context.reset() invocation should be omitted.

-

Viewing - status messages -

- - +

Viewing status + messages

Logback collects its internal status data in a StatusManager @@ -600,9 +596,8 @@ public class MyApp3 { the URL http://host/yourWebapp/lbClassicStatus

-

Listening to status messages -

+

Listening to status + messages

You may also attach a StatusListener to a StatusManager so that you can take immediate action in @@ -649,9 +644,9 @@ public class MyApp3 { ... the rest of the configuration file </configuration> -

"logback.statusListenerClass" system property -

+

"logback.statusListenerClass" system + property

One may also register a status listener by setting the "logback.statusListenerClass" Java system property to the name of @@ -679,9 +674,32 @@ public class MyApp3 {

java -Dlogback.statusListenerClass=ch.qos.logback.core.status.NopStatusListener ...

-

Configuration file syntax -

+ +

Stopping + logback-classic

+ +

In order to release the resources used by logback-classic, it is + always a good idea to stop the logback context. Stopping the + context will close all appenders attached to loggers defined by the + context and stop any active threads. +

+ +
+import org.sflf4j.LoggerFactory;
+import ch.qos.logback.classic.LoggerContext;
+...
+
+// assume SLF4J is bound to logback-classic in the current environment
+LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
+loggerContext.stop();
+ +

In web-applications, such code would be invoked from within the + contextDestroyed + method of ServletContextListener in order to stop + logback-classic and release resources. + +

Configuration file syntax

As you have seen thus far in the manual with plenty of examples still to follow, logback allows you to redefine logging behavior @@ -720,10 +738,9 @@ public class MyApp3 { href="http://en.wikipedia.org/wiki/CamelCase">camelCase convention which is almost always the correct convention.

-

Case sensitivity of tag names

+

Case sensitivity of + tag names

-

Since logback version 0.9.17, tag names pertaining to explicit rules are case insensitive. For example, <logger>, <Logger> and <LOGGER> are valid configuration elements and will @@ -744,9 +761,8 @@ public class MyApp3 { is almost always the correct convention.

-

Configuring loggers, or the - <logger> element

+

Configuring loggers, or + the <logger> element

At this point you should have at least some understanding of level inheritance and @@ -785,9 +801,8 @@ public class MyApp3 { -

Configuring the root logger, or the - <root> element

+

Configuring the root + logger, or the <root> element

The <root> element configures the root logger. It supports a single attribute, namely the -

Configuring +

Configuring Appenders

An appender is configured with the <appender> @@ -1115,8 +1129,7 @@ public class MyApp3 { means for sharing encoders or layouts.

-

Appenders accumulate +

Appenders accumulate

By default, appenders are cumulative: a logger will log to @@ -1209,9 +1222,8 @@ public class MyApp3 { children will go into the myApp.log file.

-

Overriding - the default cumulative behaviour

+

Overriding the + default cumulative behaviour

In case the default cumulative behavior turns out to be unsuitable for your needs, you can override it by setting the @@ -1261,9 +1273,8 @@ public class MyApp3 { foo.log file and only in that file.

- -

Setting the context name

+

Setting the context + name

As mentioned in an earlier chapter, every logger is attached to a logger @@ -1301,9 +1312,7 @@ public class MyApp3 { - -

Variable +

Variable substitution

Note Earlier versions of this document @@ -1336,9 +1345,7 @@ public class MyApp3 {

As they often come in handy, the HOSTNAME and CONTEXT_NAME variables are automatically defined and have context scope.

- -

Defining variables

+

Defining variables

Variables can be defined one at a time in the configuration file itself or loaded wholesale from an external properties file or an @@ -1457,8 +1464,7 @@ public class MyApp3 { </configuration> -

Scopes

+

Scopes

A property can be defined for insertion in local scope, in context scope, or in system scope. Local scope @@ -1534,9 +1540,8 @@ public class MyApp3 { event, even those sent to remote hosts via serialization.

-

Default - values for variables

+

Default values + for variables

Under certain circumstances, it may be desirable for a variable to have a default value if it is not declared or its value is @@ -1547,8 +1552,7 @@ public class MyApp3 { not defined, "${aName:-golden}" will be interpreted as "golden".

-

Nested variables

+

Nested variables

Variable nesting is fully supported. Both the name, default-value and value definition of a variable can reference @@ -1615,23 +1619,20 @@ fileName=myApp.log -

HOSTNAME property

+

HOSTNAME property

As it often comes in handy, the HOSTNAME property is defined automatically during configuration with context scope.

-

CONTEXT_NAME property

+

CONTEXT_NAME property

As its name indicates, the CONTEXT_NAME property corresponds to the name of the current logging context.

-

Setting a timestamp

+

Setting a timestamp

The timestamp element can define a property according to current date and time. The timestamp element is .

-

Defining +

Defining properties on the fly

You may define properties dynamically using the @@ -1679,17 +1679,40 @@ fileName=myApp.log -

At the present time, logback does not ship with any classes - implementing PropertyDefiner. We merely provide an - extension point so that you (the user) may define properties - dynamically. +

At the present time, logback does ships with two fairly simple + implementations of PropertyDefiner.

+ + + + + + + + + + + + + + +
Implementation nameDescription
FileExistsPropertyDefiner + Set the named variable to "true" if the file specified by + path property exists, to "false" + otherwise. +
ResourceExistsPropertyDefiner + Set the named variable to "true" if the resource specified by the user is available + on the class path, to "false" otherwise. +
+ -

Conditional processing of configuration - files

+

Conditional processing of + configuration files

Developers often need to juggle between several logback configuration files targeting different environments such as @@ -1780,8 +1803,8 @@ fileName=myApp.log -

Obtaining variables from JNDI

+

Obtaining variables from + JNDI

Under certain circumstances, you may want to make use of env-entries stored in JNDI. The <insertFromJNDI> @@ -1819,8 +1842,7 @@ fileName=myApp.log directive.

-

File inclusion

+

File inclusion

Joran supports including parts of a configuration file from another file. This is done by declaring a <include> @@ -1886,9 +1908,18 @@ fileName=myApp.log +

If it cannot find the file to be included, logback will complain + by printing a status message. In case the included file is + optional, you can suppres the error message by setting optional attribute to true in the + <include> element.

+ + +
<include optional="true" ..../>
+ -

Adding a context listener

+

Adding a context + listener

Instances of the LoggerContextListener @@ -1902,9 +1933,8 @@ fileName=myApp.log href="jmxConfig.html">subsequent chapter.

-

LevelChangePropagator

+

LevelChangePropagator

As of version 0.9.25, logback-classic ships with LevelChangePropagator, diff --git a/logback-site/src/site/pages/manual/groovy.html b/logback-site/src/site/pages/manual/groovy.html index 2de2b512ddb1a167923990eb52388af0cea4e51f..a2454b1e77b46fa0bbf59eda9577abe3cb740118 100644 --- a/logback-site/src/site/pages/manual/groovy.html +++ b/logback-site/src/site/pages/manual/groovy.html @@ -110,7 +110,6 @@

  • import ch.qos.logback.core.status.*;
  • import ch.qos.logback.classic.net.*;
  • import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
  • -
  • import ch.qos.logback.classic.sift.SiftingAppender;
  • In addition, all constants in INFO or info without a static import statement.

    + +

    SiftingAppender no longer supported

    + +

    Since version 1.0.12 + SiftingAppender is no longer supported within groovy + configuration files. However, in case there is demand, it may be + re-introduced.

    +

    Extensions specific to logback.groovy

    @@ -129,6 +136,8 @@ exception: appenders MUST be defined before they can be attached to a logger.

    + +

    root(Level level, List<String> appenderNames = [])

    diff --git a/logback-site/src/site/pages/manual/index.html b/logback-site/src/site/pages/manual/index.html index 52c7c13329a89cb46cfb9d71aebc9992033f6faf..36577f4e5d8f682636b88dc450840e87f12d4c3e 100644 --- a/logback-site/src/site/pages/manual/index.html +++ b/logback-site/src/site/pages/manual/index.html @@ -112,6 +112,14 @@ Chapter 13: Migration from log4j

    +
  • + Chapter 14: Receivers +

  • + +
  • + Chapter 15: Using SSL +

  • +
    diff --git a/logback-site/src/site/pages/manual/introduction.html b/logback-site/src/site/pages/manual/introduction.html old mode 100644 new mode 100755 index 0eb94f552ee12c0d993bb5e9ac7305bfb2b89b69..f87242f024ab02908240903d5f67e60b2a0ed265 --- a/logback-site/src/site/pages/manual/introduction.html +++ b/logback-site/src/site/pages/manual/introduction.html @@ -10,10 +10,12 @@ - + + +
    @@ -220,20 +222,7 @@ public class HelloWorld2 { -

    Building logback

    - - - +

    Building logback

    As its build tool, logback relies on Maven, a widely-used open-source diff --git a/logback-site/src/site/pages/manual/layouts.html b/logback-site/src/site/pages/manual/layouts.html old mode 100644 new mode 100755 index 84bb7e8a229d2dc3486f48ba2576fb9906645527..f602d9a6410a14cd9b84ae31c3de4907bfbe8014 --- a/logback-site/src/site/pages/manual/layouts.html +++ b/logback-site/src/site/pages/manual/layouts.html @@ -534,65 +534,72 @@ WARN [main]: Message 2

    d{pattern}
    date{pattern}
    + d{pattern, timezone}
    + date{patterntimezone}
    -

    Used to output the date of the logging event. The date - conversion word admits a pattern string as an option. The - pattern syntax is compatible with the format accepted by java.text.SimpleDateFormat.

    - -

    You can specify the string "ISO8601" for the - ISO8601 date format. Note that the %date conversion word - defaults to the ISO 8601 date - format in the absence of a pattern option.

    - -

    Here are some sample option values. They assume that the - actual date is Friday 20th of October, 2006 and that the - author has returned to working on this document just after - lunch.

    +

    Used to output the date of the logging event. The date + conversion word admits a pattern string as a parameter. The + pattern syntax is compatible with the format accepted by java.text.SimpleDateFormat.

    + +

    You can specify the string "ISO8601" for the + ISO8601 date format. Note that the %date conversion word + defaults to the ISO 8601 date + format in the absence of a pattern parameter.

    + +

    Here are some sample parameter values. They assume that + the actual date is Friday 20th of October, 2006 and that the + author has returned to working on this document just after + lunch.

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    Conversion PatternResult
    %d2006-10-20 14:06:49,812
    %date2006-10-20 14:06:49,812
    %date{ISO8601}2006-10-20 14:06:49,812
    %date{HH:mm:ss.SSS}14:06:49.812
    %date{dd MMM yyyy ;HH:mm:ss.SSS}20 oct. 2006;14:06:49.812
    - -

    In addition to the date pattern, this converter admits a - second option as the timezone. Thus, the - '%date{HH:mm:ss.SSS,Australia/Perth} would print the time in - the time zone of Perth, Australia, the world's most isolated - city. + + + + + + + + + + + + + + + + + + + + + + + + + +
    Conversion PatternResult
    %d2006-10-20 14:06:49,812
    %date2006-10-20 14:06:49,812
    %date{ISO8601}2006-10-20 14:06:49,812
    %date{HH:mm:ss.SSS}14:06:49.812
    %date{dd MMM yyyy;HH:mm:ss.SSS}20 oct. 2006;14:06:49.812
    + +

    The second parameter specifies a timezone. For example, + the '%date{HH:mm:ss.SSS, Australia/Perth} would print + the time in the time zone of Perth, Australia, the world's + most isolated city. Note that in the absence of the + timezone parameter, the default timezone of the host Java + platform is used. If the specified timezone identifier is + unknown or misspelled, the GMT timezone is assumed as + dictated by the TimeZone.getTimeZone(String) + method specification.

    -

    Given that the comma ',' character is interpreted as the - option separator, the pattern string [HH:mm:ss,SSS] will - print the time in the [SSS] time zone which does not - exist. Thus, the time will be printed in the default GMT - timezone. If you wish to include a comma in your date - pattern, then simply enclose the pattern between quotes. For - example, %date{"HH:mm:ss,SSS"}. +

    common error Given that the + comma ',' character is interpreted as the parameter + separator, the pattern HH:mm:ss,SSS will be + interpreted as the pattern HM:mm:ss and the + timezone SSS. If you wish to include a comma in + your date pattern, then simply enclose the pattern between + quotes. For example, %date{"HH:mm:ss,SSS"}.

    @@ -753,8 +760,8 @@ Caller+2 at mainPackage.ConfigTester.main(ConfigTester.java:38) - X{key}
    - mdc{key}
    + X{key:-defaultVal}
    + mdc{key:-defaultVal}
    @@ -766,16 +773,19 @@ Caller+2 at mainPackage.ConfigTester.main(ConfigTester.java:38)

    If the mdc conversion word is followed by a key between braces, as in %mdc{userid}, then the MDC value corresponding to the key 'userid' will be output. If - the that value is null, the empty string is output. + the value is null, then the default + value speficied after the :- operator is + output. If no deault value is specified than the empty + string is output.

    -

    If no option is given, then the entire content of the MDC +

    If no key is given, then the entire content of the MDC will be output in the format "key1=val1, key2=val2".

    See the chapter on MDC for more - details on the subject. -

    + details on the subject.

    @@ -1676,6 +1686,8 @@ java.lang.Exception: display

    Building a custom conversion specifier consists of two steps.

    +

    Step 1

    +

    First, you must extend the ClassicConverter class. @@ -1688,9 +1700,8 @@ java.lang.Exception: display ILoggingEvent and returns it as a String. It might abbreviate the logger name in the process.

    -

    Let us say that our customized ClassicConverter - colors the level of the logging event, according to ANSI terminal - conventions. Here is a possible implementation:

    +

    Here is a customer converter which returns the time elapsed + since its creaton in nanoseconds:

    Example: Sample Converter Example
    @@ -1706,13 +1717,15 @@ java.lang.Exception: display } } -

    This implementation is relatively straightforward. The +

    This implementation is pretty straightforward. The MySampleConverter class extends ClassicConverter, and implements the convert method which returns the number of nano-seconds elapsed since its creation.

    +

    Step 2

    +

    In the second step, we must let logback know about the new Converter. For this purpose, we need to declare the new conversion word in the configuration file, as shown below:

    diff --git a/logback-site/src/site/pages/manual/menu.js b/logback-site/src/site/pages/manual/menu.js index 980a07e84046f8a842691163b9b2f75f83892664..4e1e717c1b4449ee0bdf62419fca1d7a6a882f48 100644 --- a/logback-site/src/site/pages/manual/menu.js +++ b/logback-site/src/site/pages/manual/menu.js @@ -13,3 +13,5 @@ document.write('
    '); document.write(''); document.write(''); +document.write(''); +document.write(''); diff --git a/logback-site/src/site/pages/manual/receivers.html b/logback-site/src/site/pages/manual/receivers.html new file mode 100755 index 0000000000000000000000000000000000000000..b6a1cde1dfa093052ac25da3ec5af8ec0776364e --- /dev/null +++ b/logback-site/src/site/pages/manual/receivers.html @@ -0,0 +1,541 @@ + + + + + Chapter 14: Receivers + + + + + + + + + + + + +
    + + +
    + + +
    + +

    Chapter 14: Receivers

    + +
    + +

    You cannot swim for new horizons until you have courage + to lose sight of the shore.

    + +

    —WILLIAM FAULKNER

    +
    + + + + + +

    What is a Receiver?

    + +

    A receiver is a Logback component that receives logging + events from a remote appender and logs each received event according + to local policy. Using a combination of socket-based appenders and + receivers, it is possible to construct sophisticated topologies + for distribution of application logging events over a network.

    + +

    A receiver extends the + ch.qos.logback.classic.net.ReceiverBase class. + By virtue of the fact that a receiver extends this class, a + receiver participates in the Logback component LifeCycle + and a receiver is + ContextAware.

    + +

    Historically, support for logging event delivery over a network + connection in Logback has been provided by SocketAppender + and the corresponding SimpleSocketServer. The appender + acts as a client, initiating a network connection to the server + application, and delivering logging events via the network connection. + The receiver component and corresponding appender support offers much + greater flexibility.

    + +

    A receiver component is configured in logback.xml, just + like any other logback component. This allows the full capabilities + of Joran to be utilized in configuring + a receiver component. Moreover, any application can + receive logging events from remote appenders by simply configuring + one or more receiver components.

    + +

    Connection initiation between an appender and a receiver + can occur in either direction. A receiver can act in the role of a + server, passively listening for connections from remote appender + clients. Alternatively, a receiver can act in the client role, + initiating a connection to a remote appender which is acting in the + server role. Regardless of the respective roles of the + appender and receiver, logging events always flow from + the appender towards the receiver.

    + +

    The flexibility to allow a receiver to initiate the connection + to an appender is particularly useful in certain situations: +

    +
      +
    • For security reasons, a central logging server may be + located behind a network firewall that does not allow incoming + connections. Using receiver components acting in the client + role, the central logging server (inside the firewall) + can initiate connections to the applications of interest + (outside the firewall). +
    • +
    • It is often desirable for developer tools (such as IDE plugins) + and enterprise management applications to have access to the + logging event stream of running applications. Traditionally, + Logback has supported this (for example in Logback Beagle) by + requiring the recipient application (e.g. a developer tool running + in an IDE) to act in the server role, passively listening for + connections from a remote appender. This can prove difficult to + manage, especially for tools running on a developer's workstation, + which may indeed by mobile. However, such tools can now be + implemented using a Logback receiver component acting in the + client role, initiating a connection to a remote appender in + order to receive logging events for local display, filtering, + and alerting. +
    • +
    + +

    A logback configuration can include any number of receiver components + acting in any combination of the server or client roles. The only + restrictions are that each receiver acting in the server role must + listen on a distinct port, and each receiver acting in the client + role will connect to exactly one remote appender.

    + +

    Receivers + that Act in the Server Role

    + +

    A receiver that is configured to act in the server role passively + listens for incoming connections from remote appenders. This is + functionally equivalent to using the standalone + SimpleSocketServer application, except that by using + the receiver component, any application that uses Logback + Classic can receive logging events from remote appenders by simply + configuring the receiver in logback.xml.

    + +

    + +

    + +

    Logback includes two receiver components that act in the + server role; + ServerSocketReceiver and its SSL-enabled + subtype + + SSLServerSocketReceiver. Both of these receiver + components are designed to accept connections from incoming + SocketAppender (or SSLSocketAppender) + clients.

    + +

    The ServerSocketReceiver components provide the + following configurable properties:

    + + + + + + + + + + + + + + + + + + + + + + +
    Property NameTypeDescription
    addressStringThe local network interface address on which the receiver + will listen. If this property is not specified, the receiver + will listen on all network interfaces.
    portintThe TCP port on which the receiver will listen. If this + property is not specified, a default value will be used.
    sslSSLConfigurationSupported only for SSLServerSocketReceiver, this + property provides the SSL configuration that will be used by + the receiver, as described in Using SSL. +
    + +

    Using + ServerSocketReceiver

    + +

    The following configuration uses the + ServerSocketReceiver component with a minimal local + appender and logger configuration. Logging events received from + a remote appender will be matched by the root logger and delivered + to the local console appender.

    + +

    Example: Basic ServerSocketReceiver Configuration + (logback-examples/src/main/java/chapters/receivers/socket/receiver1.xml)

    + + View as .groovy +
    <configuration debug="true">
    +
    +  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    +    <encoder>
    +      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
    +    </encoder>
    +  </appender>
    +
    +  <root level="DEBUG">
    +    <appender-ref ref="CONSOLE" />
    +  </root>
    +
    +  <receiver class="ch.qos.logback.classic.net.server.ServerSocketReceiver">
    +    <port>${port}</port>
    +  </receiver>
    +
    +</configuration>
    + +

    Note that the receiver component's class + attribute identifies the receiver subtype that we wish to use. In + this example we are using ServerSocketReceiver.

    + +

    Our example server application is very similar in function and + design to SimpleSocketServer. It simply accepts a + path for a logback configuration file as a command line argument, + and runs the given configuration. While our example is somewhat + trivial, keep in mind that you can configure logback's + ServerSocketReceiver (or SSLServerSocketReceiver) + component in any application. +

    + +

    From a shell in the logback-examples directory, + we can run our example server application as follows:

    + +

    java -Dport=6000 chapters.receivers.socket.ReceiverExample \ + src/main/java/chapters/receivers/socket/receiver1.xml

    + +

    We can connect to the running receiver using a client application + that is configured with a SocketAppender. Our example + client application simply loads a logback configuration that will + connect a socket appender to our example receiver. It then awaits + input from the user in the form of a message that will be relayed to + the receiver. We can run the example client application as follows: +

    + +

    java -Dhost=localhost -Dport=6000 \ + chapters.receivers.socket.AppenderExample \ + src/main/java/chapters/receivers/socket/appender1.xml

    + +

    Using + SSLServerSocketReceiver

    + +

    The following configuration repeats the same minimal appender + and logger configuration, but uses the SSL-enabled receiver component + that acts in the server role.

    + +

    Example: Basic SSLServerSocketReceiver Configuration + (logback-examples/src/main/java/chapters/receivers/socket/receiver2.xml)

    + View as .groovy +
    <configuration debug="true">
    +
    +  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    +    <encoder>
    +      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
    +    </encoder>
    +  </appender>
    +
    +  <root level="DEBUG">
    +    <appender-ref ref="CONSOLE" />
    +  </root>
    +
    +  <receiver class="ch.qos.logback.classic.net.server.SSLServerSocketReceiver">
    +    <port>${port}</port>
    +    <ssl>
    +      <keyStore>
    +        <location>${keystore}</location>
    +        <password>${password}</password>
    +      </keyStore>
    +    </ssl>
    +  </receiver>
    +
    +</configuration>
    + +

    The essential differences between this configuration and the + previous example using ServerSocketReceiver are the + specification of SSLServerSocketReceiver in the + class attribute and the presence of the nested + ssl property, which is used here to + specify the location and password for the key store containing the + receiver's private key and certificate, using substitution variables. + See Using SSL for details on + configuring SSL properties for Logback components.

    + +

    We can run this configurtation using the same example server + configuration, with just a couple of additional configuration + properties:

    + +

    java -Dport=6001 \ + -Dkeystore=file:src/main/java/chapters/appenders/socket/ssl/keystore.jks \ + -Dpassword=changeit \ + chapters.receivers.socket.ReceiverExample \ + src/main/java/chapters/receivers/socket/receiver2.xml

    + +

    Note that the keystore property given on the command + line specifies a file URL that identifies the location of the key + store. You may also use a classpath URL as described in + Using SSL. +

    + +

    We can connect to the running receiver using a client application + that is configured with a SSLSocketAppender. We use + the sample example client application used in the previous example, + with a configuration file that uses an SSL-enabled appender. We + run the example as follows: +

    + +

    java -Dhost=localhost -Dport=6001 \ + -Dtruststore=file:src/main/java/chapters/appenders/socket/ssl/truststore.jks \ + -Dpassword=changeit \ + chapters.receivers.socket.AppenderExample \ + src/main/java/chapters/receivers/socket/appender2.xml

    + +

    Note that our example is using a self-signed X.509 credential that + is suitable for testing and experimentation, only. In a + production setting, you should obtain an appropriate X.509 credential + to identify your SSL-enabled logback components. See + Using SSL for more information.

    + +

    Receivers + that Act in the Client Role

    + +

    A receiver that is configured to act in the client role initiates + a connection to a remote appender. The remote appender must be a + server type, such as ServerSocketAppender.

    + +

    + +

    + +

    Logback includes two receiver components that act in the client + role; + SocketReceiver and its SSL-enabled subtype + + SSLSocketReceiver. Both of these receiver + components are designed to initiate a connection to a remote appender + that is a ServerSocketAppender + (or SSLServerSocketAppender).

    + +

    The following configuration properties are supported by + SocketReceiver subtypes:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Property NameTypeDescription
    remoteHostStringThe hostname or address of the remote server socket appender.
    portintThe port number of the remote server socket appender.
    reconnectionDelayint + A positive integer representing the number of milliseconds to wait + before attempting to reconnect after a connection failure. The + default value is 30000 (30 seconds). +
    sslSSLConfigurationSupported only for SSLSocketReceiver, this + property provides the SSL configuration that will be used for + this receiver, as described in Using SSL. +
    + +

    Using + SocketReceiver

    + +

    The configuration used for SocketReceiver + is quite similar to the previous example that used + ServerSocketReceiver. The differences relate to the + fact that the roles of client and server are reversed; a receiver + of type SocketReceiver is a client, and the remote + appender acts as a server.

    + +

    Example: Basic SocketReceiver Configuration + (logback-examples/src/main/java/chapters/receivers/socket/receiver3.xml)

    + View as .groovy +
    <configuration debug="true">
    +    
    +  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">    
    +    <encoder>
    +      <pattern>%date %-5level [%thread] %logger - %message%n</pattern>
    +    </encoder>
    +  </appender>
    +
    +  <root level="DEBUG">
    +    <appender-ref ref="CONSOLE" />
    +  </root>  
    +
    +  <receiver class="ch.qos.logback.classic.net.SocketReceiver">
    +    <remoteHost>${host}</remoteHost>
    +    <port>${port}</port>
    +    <reconnectionDelay>10000</reconnectionDelay>
    +  </receiver>
    +
    +</configuration>
    + +

    This configuration will cause logback to connect to a + ServerSocketAppender running on the host and port specified + by the host and port substitution variables. Logging + events received from the remote appender will be logged locally + (according to the configuration shown here) via a console appender. +

    + +

    Assuming you are in the logback-examples/ directory, + you can run this example configuration using the following command:

    + + + +

    The example loads the configuration and then simply waits for logging + events from the remote appender. If you run this example when the remote + appender is not running, you'll see connection refused messages + appearing in the log output, periodically. The receiver will + periodically attempt to reconnect to the remote appender until it + succeeds or until the logger context is shut down. The delay + interval between attempts is configurable using the + reconnectionDelay property as shown in the + example configuration.

    java -Dhost=localhost -Dport=6000 \ + chapters.receivers.socket.ReceiverExample \ + src/main/java/chapters/receivers/socket/receiver3.xml

    + +

    We can provide a remote appender to which our example receiver + can connect, using the same appender example used previously. The + example loads a logback configuration containing a + ServerSocketAppender, and then waits input from the + user consisting of a message that will be delivered to connected + receivers. We can run the example appender application as follows: +

    + +

    java -Dport=6000 \ + chapters.receivers.socket.AppenderExample \ + src/main/java/chapters/receivers/socket/appender3.xml

    + +

    If you enter a message to send when the receiver is not connected, + note that the message is simply discarded.

    + +

    Using + SocketSSLReceiver

    + + +

    The configuration needed for SSLSocketReceiver is very + similar to that used with SocketReceiver. The essential + differences are in the class specified for the receiver and the ability + to nest the ssl property to specify SSL + configuration properties. The following example illustrates a basic + configuration: +

    + +

    Example: Basic SSLSocketReceiver Configuration + (logback-examples/src/main/java/chapters/receivers/socket/receiver4.xml)

    + View as .groovy +
    <configuration debug="true">
    +
    +  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">    
    +    <encoder>
    +      <pattern>%date %-5level [%thread] %logger - %message%n</pattern>
    +    </encoder>         
    +  </appender>
    +
    +  <root level="DEBUG">
    +    <appender-ref ref="CONSOLE" />
    +  </root>  
    + 
    +  <receiver class="ch.qos.logback.classic.net.SSLSocketReceiver">
    +    <remoteHost>${host}</remoteHost>
    +    <port>${port}</port>
    +    <reconnectionDelay>10000</reconnectionDelay>
    +    <ssl>
    +      <trustStore>
    +        <location>${truststore}</location>
    +        <password>${password}</password>
    +      </trustStore>
    +    </ssl>
    +  </receiver>
    +
    +</configuration>
    + +

    Note that the class attribute now specifies + SSLSocketReceiver and that in addition to the configuration + properties shown in the previous example, this configuration contains + an SSL configuration specifying the location and password for a + trust store that will be used in validating that the remote appender is + trusted. See Using SSL for more information + on configuring SSL properties. +

    + +

    You can run this example configuration using the following command:

    + +

    java -Dhost=localhost -Dport=6001 \ + -Dtruststore=file:src/main/java/chapters/appenders/socket/ssl/truststore.jks \ + -Dpassword=changeit \ + chapters.receivers.socket.ReceiverExample \ + src/main/java/chapters/receivers/socket/receiver4.xml

    + +

    Once started, the receiver attempts to connect to the specified + remote appender. Assuming that the appender is not yet running, you + will see a "connection refused" message appearing in the log output + periodically; the receiver will periodically retry the connection to + the remote appender after delaying for the period of time specified by + the reconnectionDelay property. +

    + +

    We can provide a remote appender to which our example receiver + can connect, using the same appender example used previously. The + example loads a logback configuration containing a + SSLServerSocketAppender, and then awaits input from the + user consisting of a message that will be delivered to connected + receivers. We can run the example appender application as follows: +

    + +

    java -Dport=6001 \ + -Dkeystore=file:src/main/java/chapters/appenders/socket/ssl/keystore.jks \ + -Dpassword=changeit \ + chapters.receivers.socket.AppenderExample \ + src/main/java/chapters/receivers/socket/appender4.xml

    + +

    If you enter a message to send when the receiver is not connected, + note that the message is simply discarded.

    + +

    It is important to note once again that our example is using a + self-signed X.509 credential that is suitable for testing and + experimentation, only. In a production setting, you should + obtain an appropriate X.509 credential to identify your SSL-enabled + logback components. See Using SSL + for more information.

    + + + +
    + + diff --git a/logback-site/src/site/pages/manual/usingSSL.html b/logback-site/src/site/pages/manual/usingSSL.html index f24661187b80a40d32bed44377c8a94d9c2c9219..9c089cedc4452e265966456c8ed396e29b3d32c5 100644 --- a/logback-site/src/site/pages/manual/usingSSL.html +++ b/logback-site/src/site/pages/manual/usingSSL.html @@ -3,7 +3,7 @@ - Logback: Using SSL + Chapter 15: Using SSL @@ -25,46 +25,81 @@
    -

    Using SSL

    -

    Logback Classic supports the use of the Secure Sockets Layer - (SSL) when delivering log events to a remote log server using - - SSLSocketAppender. This appender acts as a - secure network client, connecting to an SSL-enabled log server - and delivering serialized logging events over a secure channel. - It supports all of the same logging features as the plain old - SocketAppender while offering secure transport for - logging events over the network. +

    Chapter 15: Using SSL

    + +
    + +

    The whole difference between construction and creation is + exactly this: that a thing constructed can only be loved after it + is constructed; but a thing created is loved before it exists.

    +

    —CHARLES DICKENS

    +
    + + + + + +

    Logback supports the use of the Secure Sockets Layer + (SSL) when delivering log events from a socket-based appender + to a remote receiver. When using an SSL-enabled appender and + corresponding receiver, serialized logging events are delivered + over a secure channel.

    -

    Logback Classic supports two SSL-enabled logging servers.

    -
      -
    • The - SSLSocketServer is a logging server component - that can be added to any Logback configuration file (e.g. - logback.xml) to allow logging events to be - received from a remote logger and logged according to the - local configuration. -
    • -
    • For those who are presently using - - SimpleSocketServer and simply want to start - using SSLSocketAppender to deliver logging - events over a secure channel, Logback Classic provides the - - SimpleSSLSocketServer. This server - supports the same command line interface as the plain old - SimpleSocketServer, while offering secure - transport for logging events over the network. -
    • -
    -s +

    SSL and Component Roles

    + +

    Logback components such as appenders and receivers may act in + either the server role or the client role, with respect to network + connection initiation. When acting in the server role, a logback + component passively listens for connections from remote client + components. Conversely, a component acting in the client role + initiates a connection to remote server component. For example, + an appender acting in the client role connects to a + receiver acting in the server role. Or a receiver + acting in the client role connects to an appender + acting in the server role.

    + +

    The roles of the components are generally determined by the + component type. For example, an SSLServerSocketAppender + is an appender component that acts in the server role, while an + SSLSocketAppender is an appender component that acts + in the client role. Thus the developer or application administrator + can configure Logback components to support the desired direction + of network connection initiation.

    + +

    The direction of connection initiation is significant in the + context of SSL, because in SSL a server component must possess an + X.509 credential to identify itself to connecting clients. A + client component, when connecting to the server, uses the server's + certificate to validate that the server is trusted. The + developer or application administrator must be aware of the + roles of Logback components, so as to properly configure the + server's key store (containing the server's X.509 credential) + and the client's trust store (containing self-signed + root certificates used when validating server trust).

    + +

    When SSL is configured for mutual authentication, then + both the server component and the client component must possess + valid X.509 credentials whose trust can be asserted by their + respective peer. Mutual authentication is configured in the + server component, therefore the developer or application + administrator must be aware of which components are acting in + the server role.

    + +

    In this chapter, we use the term server component + or simply server to refer to a Logback component such + as an appender or receiver that is acting in the server role. We + use the term client component or simply client + to refer to a component that is acting in the client role. +

    SSL and X.509 Certificates

    +

    In order to use SSL-enabled Logback components, you will need an X.509 credential (a private key, corresponding certificate, - and CA certification chain) to identify your logging server. If - you wish to use mutual authentication, you will also need credentials - for your Logback appender clients using SSLSocketAppender. + and CA certification chain) to identify your components + that act as SSL servers. If you wish to use mutual authentication, + you will also need credentials for your components that + act as SSL clients.

    While you can use a credential issued by a commercial certification authority (CA), you can also use a certificate issued @@ -72,13 +107,14 @@ s following is all that is required:

      -
    1. The server must be configured with a key store containing - the server's private key, corresponding certificate, and - CA certification chain (if not using a self-signed certificate). +
    2. The server component must be configured + with a key store containing the server's private key, + corresponding certificate, and CA certification chain + (if not using a self-signed certificate).
    3. -
    4. The client must be configured with a trust store containing - the trusted root CA certificate(s) or the server's - signed root certificate. +
    5. The client component must be configured + with a trust store containing trusted root CA + certificate(s) or the server's self-signed root certificate.
    @@ -88,18 +124,16 @@ s support has many configurable options, and a pluggable provider framework that allows the built-in SSL and cryptographic capabilities of the platform to be replaced or augmented. - SSL-enabled Logback components such as - SSLSocketAppender and SSLSocketServer - provide the ability to fully specify all of the configurable - aspects of the SSL engine and cryptographic providers, to meet - your unique security needs. + SSL-enabled Logback components provide the ability to fully specify + all of the configurable aspects of the SSL engine and cryptographic + providers, to meet your unique security needs.

    Basic SSL Configuration using JSSE System Properties

    Fortunately, nearly all of the configurable SSL properties for SSL-enabled Logback components have reasonable defaults. In - most cases all that is needed to use SSL-enabled Logback - components is the configuration of some JSSE system properties. + most cases all that is needed is the configuration of some JSSE + system properties.

    The remainder of this section describes the specific JSSE @@ -110,13 +144,14 @@ s system properties to customize JSSE.

    -

    If you're using either the SSLSocketServer component - in your application's logback configuration or using the - SimpleSSLSocketServer as a standalone application - to receive logging events, you'll need to configure JSSE system - properties that provide the location, type, and password - of the key store containing the private key and certificate for - your logging server. +

    If you're using any of Logback's SSL-enabled appender or receiver + components that act in the server role (e.g. + SSLServerSocketReceiver, + SSLServerSocketAppender, + or SimpleSSLSocketServer) you'll need to configure + JSSE system properties that provide the location, type, and + password of the key store containing a private key and + certificate.

    @@ -129,7 +164,7 @@ s javax.net.ssl.keyStore Specifies a filesystem path to the file containing your - logging server's private key and certificate. + server components's private key and certificate. javax.net.ssl.keyStoreType @@ -145,22 +180,22 @@ s

    See Examples below for examples of - setting these system properties when starting a server - application via a command-line interface. + setting these system properties when starting an application + that uses Logback's SSL-enabled server components.

    -

    If your logging server is using a certificate that was - signed by a commercial certification authority (CA), you - probably don't need to provide any SSL configuration - in your applications that use - SSLSocketAppender. When using a - commercially-signed logging server certificate, simply setting - the key store system properties in the server is usually - all that is needed. +

    If your server component is using a certificate + that was signed by a commercial certification authority (CA), + you probably don't need to provide any SSL + configuration in your applications that use SSL-enabled client + components. When using a commercially-signed + certificate for your server component, simply setting the + system key store properties for JVM that runs the server + component is usually all that is needed.

    -

    If are using either a self-signed logging server certificate - or your logging server's certificate was signed by a +

    If you are using either a self-signed server certificate + or your server certificate was signed by a certification authority (CA) that is not among those whose root certificates are in the Java platform's default trust store (e.g. when your organization has its own internal certification @@ -168,9 +203,9 @@ s properties that provide the location, type, and password of the trust store containing your server's certificate or trusted root certificates for the certification authority (CA) that - signed your server's certificate. These properties will - need to be set in the application that utilizes - SSLSocketAppender. + signed your server's certificate. These properties will + need to be set in each application that utilizes an SSL-enabled + client component.

    @@ -183,8 +218,9 @@ s javax.net.ssl.trustStore Specifies a filesystem path to the file containing your - logging server's certificate or trusted root certificate(s) - for the certification authority (CA) that signed. + server component's certificate or trusted root + certificate(s) for the certification authority (CA) that + signed the server certificate. javax.net.ssl.trustStoreType @@ -200,15 +236,15 @@ s

    See Examples below for examples of - setting these system properties when starting a client - application via a command-line interface. + setting these system properties when starting an application + that utilizes Logback's SSL-enabled client components.

    Advanced SSL Configuration

    In certain situations, the basic SSL configuration using JSSE system properties is not adequate. For example, if you - are using the SSLSocketServer component in a web + are using the SSLServerSocketReceiver component in a web application, you may wish to use a different credential to identify your logging server for your remote logging clients than the credential that your web server uses to identify @@ -224,7 +260,7 @@ s specify the SSL configuration using the ssl property in the configuration of the component.

    -

    For example, if you wish to use SSLSocketServer +

    For example, if you wish to use SSLServerSocketReceiver and configure the key store properties for your logging server's credential, you could use a configuration such as the following. @@ -232,14 +268,6 @@ s View as .groovy

    <configuration>
    -  <server class="ch.qos.logback.classic.net.server.SSLSocketServer">
    -    <ssl>
    -      <keyStore>
    -        <location>classpath:/logging-server-keystore.jks</location>
    -        <password>changeit</password>
    -      </keyStore>
    -    </ssl>
    -  </server> 
     
       <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
         <encoder>
    @@ -251,6 +279,15 @@ s
         <appender-ref ref="CONSOLE" />
       </root>
     
    +  <receiver class="ch.qos.logback.classic.net.server.SSLServerSocketReceiver">
    +    <ssl>
    +      <keyStore>
    +        <location>classpath:/logging-server-keystore.jks</location>
    +        <password>changeit</password>
    +      </keyStore>
    +    </ssl>
    +  </receiver> 
    +
     </configuration>

    This configuration specifies the location of the key store @@ -260,7 +297,7 @@ s the key store.

    If you wanted to use SSLSocketAppender in your - application's logback configuration, but did not want to change + application's Logback configuration, but did not want to change the application's default trust store using the JSSE javax.net.ssl.trustStore property, you could configure the appender as follows. @@ -272,6 +309,7 @@ s <ssl> <trustStore> <location>classpath:/logging-server-truststore.jks</location> + <password>changeit</password> </trustStore> </ssl> </appender> @@ -293,19 +331,19 @@ s

    JSSE exposes a large number of configurable options, and Logback's SSL support makes nearly all of them available for - you to specify in your server or appender configuration. + you to specify in your SSL-enabled component configuration. When using XML configuration, SSL properties are introduced to - these components by nesting an <ssl> element in the appender - or server configuration. This configuration element corresponds + these components by nesting an <ssl> element in the + component configuration. This configuration element corresponds to the SSLConfiguration class.

    -

    When configuring SSL for your server or appender components +

    When configuring SSL for your components you need only configure those SSL properties for which the defaults are not adequate. Overspecifying the SSL configuration - is often those cause of difficult-to-diagnose problems. + is often the cause of difficult-to-diagnose problems.

    The following table describes the top-level SSL configuration @@ -699,7 +737,7 @@ s Set this property to the value true to configure a server to require a valid client certificate. This property is ignored when configured - for a client SSLSocketAppender. + for a client component such as SSLSocketAppender. @@ -709,7 +747,7 @@ s Set this property to the value true to configure the server to request a client certificate. This property is ignored when configured - for a client SSLSocketAppender. + for a client component such as SSLSocketAppender. @@ -754,17 +792,63 @@ s -

    Examples

    +

    Examples

    + +

    Using JSSE System Properties

    +

    JSSE system properties can be used to specify the location and + password for a key store containing your server's X.509 credential, + or to specify the location and password for a trust store + containing self-signed root CA certificates used by your client + components to validate server trust.

    + +

    Specifying the Server's Key Store

    +

    When running a server component, you need to specify the location + and password for the key store containing the server's credential. + One way to do this is using JSSE system properties. The following + example shows a command line that could be used to start the + SimpleSSLSocketServer that is shipped with Logback.

    + +

    java -DkeyStore=/etc/logback-server-keystore.jks \ + -DkeyStorePassword=changeit -DkeyStoreType=JKS \ + ch.qos.logback.net.SimpleSSLSocketServer 6000 /etc/logback-server-config.xml

    + +

    Note that when using the JSSE keyStore system property, + a path to the key store is specified. When specifying the location + in logback.xml, a URL for the key store is specified.

    + +

    While this example starts the standalone server application + provided with Logback, the same system properties could be specified + to start any application that uses an SSL-enabled Logback server + component. + +

    Specifying the Client's Trust Store

    + +

    When using a client component, you need to specify the location + and password for a trust store containing root CA certificates used + for validating server trust. One way to do this is using JSSE + system properties. The following example shows a command line + that could be used to start an application named + com.example.MyLoggingApplication that uses one or + more of Logback's SSL-enabled client components.

    -

    Creating and Using a Self-Signed Logging Server Credential

    +

    java -DtrustStore=/etc/logback-client-truststore.jks \ + -DtrustStorePassword=changeit -DtrustStoreType=JKS \ + com.example.MyLoggingApplication

    + +

    Note that when using the JSSE trustStore system property, + a path to the key store is specified. When specifying the location + in logback.xml, a URL for the trust store is specified.

    + +

    Creating and Using a Self-Signed Server Component Credential

    To generate a self-signed certificate, you can use the keytool utility that is shipped with the Java Runtime Environment (JRE). The instructions below walk through the process of creating a - self-signed X.509 credential in a key store for your logging server - and creating a trust store for use with your appender clients. + self-signed X.509 credential in a key store for your server + component and creating a trust store for use with your client + components.

    -

    Creating the logging server credential:

    +

    Creating the server component credential:

    The following command will generate the self-signed client credential in a file named server.keystore.

    keytool -genkey -alias server -dname "CN=my-logging-server" \
    @@ -777,7 +861,7 @@ Enter key password for <my-logging-server>
     
           

    The name my-logging-server used in the dname may be any valid name of your choosing. You may wish to use the - fully-qualified domain name of the logging server host. The + fully-qualified domain name of the server host. The validity argument specifies the number of calendar days from the present date until the credential expires.

    @@ -786,11 +870,11 @@ Enter key password for <my-logging-server> This password protects the server's private key, preventing it from being used by an authorized party. Make note of the password, because you will need it in subsequent steps and when - configuring your logging server. + configuring your server.

    -

    Creating a trust store for appender clients:

    -

    For use in the configuration of your appender clients, the +

    Creating a trust store for client components:

    +

    For use in the configuration of your client components, the server's certificate needs to be exported from the key store created in the previous step, and imported into a trust store. The following commands will export the certificate and import it into @@ -826,7 +910,7 @@ Trust this certificate? [no]: <Enter "yes"> clients.

    -

    Configuring the logging server:

    +

    Configuring the server component:

    You will need to copy the server.keystore file into your server application's configuration. The key store can be placed with your application's classpath resources, or it may simply be @@ -835,7 +919,7 @@ Trust this certificate? [no]: <Enter "yes"> either a classpath: URL or file: URL, as appropriate. A example server configuration follows:

    -

    Example: Logging Server Configuration

    +

    Example: Server Component Configuration

    <configuration debug="true">
       <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
         <encoder>
    @@ -847,7 +931,7 @@ Trust this certificate? [no]:  <Enter "yes">
         <appender-ref ref="CONSOLE" />
       </root>
     
    -  <server class="ch.qos.logback.classic.net.server.SSLSocketServer">
    +  <server class="ch.qos.logback.classic.net.server.SSLServerSocketReceiver">
         <ssl>
           <keyStore>
             <location>classpath:server.keystore</location>
    @@ -869,15 +953,14 @@ Trust this certificate? [no]:  <Enter "yes">
           using the entered password before configuring the logging system.
           

    -

    Configuring appender clients:

    +

    Configuring client components:

    You will need to copy the server.truststore file into - the application configuration of each application that uses - SSLSocketAppender to send logging events to your - server. The trust store can be placed with your application's - classpath resources, or it may simply be placed somewhere on the - filesystem. When specifying the location of the trust - store in the configuration, you will use either a - classpath: URL or file: URL, as + the application configuration of each application that uses an + SSL-enabled component acting in the client mode. The trust store + can be placed with your application's classpath resources, or it + may simply be placed somewhere on the filesystem. When specifying + the location of the trust store in the configuration, you will use + either a classpath: URL or file: URL, as appropriate. A example appender client configuration follows:

    Example: Appender Client Configuration

    @@ -914,10 +997,10 @@ Trust this certificate? [no]: <Enter "yes">

    In settings where secure communications are required, it is often necessary to audit the configuration of components that use SSL to validate conformance with local security policies. The SSL - support in Logback Classic addresses this need by providing detailed - logging of SSL configuration when the logback configuration is - initialized. You can enable audit logging using the - debug property in the configuration:

    + support in Logback addresses this need by providing detailed + logging of SSL configuration when Logback is initialized. You can + enable audit logging using the debug property in the + configuration:

    <configuration debug="true">
       
    @@ -932,10 +1015,10 @@ Trust this certificate? [no]:  <Enter "yes">
           
           

    Example: SSL Configuration Audit Logging

    -
    06:46:31,941 |-INFO in SSLSocketServer@4ef18d37 - SSL protocol 'SSL' provider 'SunJSSE version 1.6'
    -06:46:31,967 |-INFO in SSLSocketServer@4ef18d37 - key store of type 'JKS' provider 'SUN version 1.6': file:src/main/java/chapters/appenders/socket/ssl/keystore.jks
    -06:46:31,967 |-INFO in SSLSocketServer@4ef18d37 - key manager algorithm 'SunX509' provider 'SunJSSE version 1.6'
    -06:46:31,973 |-INFO in SSLSocketServer@4ef18d37 - secure random algorithm 'SHA1PRNG' provider 'SUN version 1.6'
    +      
    06:46:31,941 |-INFO in SSLServerSocketReceiver@4ef18d37 - SSL protocol 'SSL' provider 'SunJSSE version 1.6'
    +06:46:31,967 |-INFO in SSLServerSocketReceiver@4ef18d37 - key store of type 'JKS' provider 'SUN version 1.6': file:src/main/java/chapters/appenders/socket/ssl/keystore.jks
    +06:46:31,967 |-INFO in SSLServerSocketReceiver@4ef18d37 - key manager algorithm 'SunX509' provider 'SunJSSE version 1.6'
    +06:46:31,973 |-INFO in SSLServerSocketReceiver@4ef18d37 - secure random algorithm 'SHA1PRNG' provider 'SUN version 1.6'
     06:46:32,755 |-INFO in SSLParametersConfiguration@4a6f19d5 - enabled protocol: SSLv2Hello
     06:46:32,755 |-INFO in SSLParametersConfiguration@4a6f19d5 - enabled protocol: SSLv3
     06:46:32,755 |-INFO in SSLParametersConfiguration@4a6f19d5 - enabled protocol: TLSv1
    @@ -958,24 +1041,23 @@ Trust this certificate? [no]:  <Enter "yes">
           

    Resolving SSL Exceptions

    -

    When using SSLSocketAppender, the appender acts - as a client, connecting to an SSL-enabled logging server. - If SSL is misconfigured, it generally results in the client - and server being unable to negotiate an agreeable session. This - problem usually manifests itself as exceptions being thrown by - both parties when the client attempts to connect to the server. +

    When SSL is misconfigured, it generally results in the client + and server components being unable to negotiate an agreeable + session. This problem usually manifests itself as exceptions + being thrown by both parties when the client attempts to connect + to the server.

    The content of the exception messages varies depending on whether you are looking at the client's log or the server's log. This is mostly due to inherent protocol limitations in error reporting during session negotiation. As a consequence of this fact, in order to troubleshoot session negotiation problems, you will - usually want to look at the logs of both the appender client - and the logging server. + usually want to look at the logs of both the client and the + server.

    Server's Certificate is Not Available

    -

    When starting the logging server, you +

    When starting the server component, you see the following exception in the log:

    javax.net.ssl.SSLException: No available certificate or @@ -998,9 +1080,9 @@ Trust this certificate? [no]: <Enter "yes">

    Client Does Not Trust the Server

    -

    When the appender client attempts to connect to the logging - server, you see the following exception in the log: -

    +

    When the client attempts to connect to the server, you see the + following exception in the log:

    +

    javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed @@ -1068,7 +1150,7 @@ Trust this certificate? [no]: <Enter "yes"> certificate_expired or certificate_revoked the server needs a new certificate. The new certificate and associated private key needs to be placed in the key store - specified in the logging server's configuration. And, if using + specified in the server's configuration. And, if using a self-signed server certificate, the server's certificate also needs to be placed in the trust store specified in the appender client's configuration. @@ -1082,7 +1164,7 @@ Trust this certificate? [no]: <Enter "yes"> property).

    -

    When the appender client attempts to connect to the logging +

    When the client attempts to connect to the logging server, you see the following exception in the client's log:

    @@ -1135,9 +1217,9 @@ Trust this certificate? [no]: <Enter "yes"> certificate_expired or certificate_revoked the client needs a new certificate. The new certificate and associated private key needs to be placed in the key store - specified in the appender client's configuration. And, if using + specified in the client's configuration. And, if using a self-signed client certificate, the client's certificate also - needs to be placed in the trust store specified in the logging + needs to be placed in the trust store specified in the servers's configuration.

    @@ -1149,9 +1231,8 @@ Trust this certificate? [no]: <Enter "yes"> protocols in your configuration.

    -

    When the appender client attempts to connect to the logging - server, you see the following exception in the log: -

    +

    When the client attempts to connect to the server, you see + the following exception in the log:

    javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure @@ -1170,7 +1251,7 @@ Trust this certificate? [no]: <Enter "yes">

    Check the values specified for the excludedProtocols and includedProtocols - properties on both the logging server and appender client. + properties on both the server and client.

    Client and Server Cannot Agree on a Cipher Suite

    @@ -1181,7 +1262,7 @@ Trust this certificate? [no]: <Enter "yes"> cipher suites in your configuration.

    -

    When the appender client attempts to connect to the logging +

    When the client attempts to connect to the server, you see the following exception in the log:

    @@ -1196,7 +1277,7 @@ Trust this certificate? [no]: <Enter "yes">

    This means that you have configured the cipher suites on the - logging server and appender client such that the intersection + server and client such that the intersection of their respective sets of enabled cipher suites is empty.

    Solution

    @@ -1206,6 +1287,8 @@ Trust this certificate? [no]: <Enter "yes"> properties on both the server and client.

    + +
    \ No newline at end of file diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html index e7e4876059b3b0867a10a7937d0ef61f7ce30896..0cdf4d8385d65e98e1f733c379b239cacb96acdc 100755 --- a/logback-site/src/site/pages/news.html +++ b/logback-site/src/site/pages/news.html @@ -28,57 +28,95 @@ announce mailing list.

    + +
    -

    April, 2013 - Release of version 1.0.12

    +

    , 2013 - Release of version 2.0.0-alpha1

    + +

    The LoggingEvent constructor delays message + formatting so that it can be computed lazily by the + getFormattedMessage method. This fixes LOGBACK-873 and + re-fixes LOGBACK-495. +

    + +

    PackagingDataCalculator now checks for the case + where the caller has no protection domain. This fixes LOGBACK-617 + reported by Yuri de Wit. The relevant fix was provided by Mikhail + Mazursky. +

    -

    Several improvements and additions to socket-based appenders are - included in this release:

    + +
    + +

    May 10th, 2013 - Release of version 1.0.13

    + +

    In logback-access MANIFEST file, imports of Jetty and Tomcat + are now optional. This fixes LOGBACK-300 + reported by Christian Brensing who also provided the appropriate + pull request. +

    + +

    Logback will now correctly parses variables with a default + separator string nested within accolades, e.g. "{a:-b}". Such + strings resemble variable references but lack the $ prefix, e.g + "${a:-b}". This fixes LOGBACK-859 + reported by Yoni Moses.

    + +

    In InterpretationContext class replaced code using + JDK 1.6 API with code using JDK 1.5. This fixes LOGBACK-860 + reported by Bas Stoker. +

    + +

    Updated the "org.fusesource.jansi:jansi" dependency to version + 1.9.

    + +
    + +

    April 26th, 2013 - Release of version 1.0.12

    -
      -
    • A new SSLSocketAppender extends the basic - SocketAppender providing the ability to deliver logging - events over the Secure Socket Layer (SSL). The corresponding - SimpleSSLSocketServer extends the basic - SimpleSocketServer as a basic logging server application - that receives logging events from a SSLSocketAppender. -
    • +

      A new SSLSocketAppender extends the basic + SocketAppender providing the ability to deliver + logging events over the Secure Socket Layer (SSL). The + corresponding SimpleSSLSocketServer extends the classic + SimpleSocketServer as a basic logging server + application that receives logging events from a + SSLSocketAppender.

      -
    • A new SocketServer component (and its SSL-enabled - counterpart, SSLSocketServer) provides the ability to - incorporate logging server functionality into any application - that uses Logback Classic, as an alternative to the simple standalone - socket server application provided with logback. The new server - component is configured in logback.xml in the same manner as - other logback components such as appenders and loggers. A logback - configuration that includes a server component listens passively on - a TCP socket for connections from incoming socket appender clients. - Logging events received from remote appenders are logged according to - the local configuration. See - SocketServer and SSLSocketServer in the manual for usage - instructions. -
    • +

      Receiver components are configured in + logback.xml just like any other logback component.

      + +

      While SimpleSocketServer (and its new SSL-enabled + counterpart, SimpleSSLSocketServer) provide an + easy-to-use standalone logging server application, a new component + type known as a receiver allows any application + to receive logging events from remote appenders over a TCP/IP network + connection, using Logback Classic. Receiver components are + configured in logback.xml just like any other logback + component.

      -
    • While SocketAppender is designed to initiate a connection - to a remote logging server in order to deliver logging events, a new - ServerSocketAppender reverses the direction of connection - initiation. A logback configuration that utilizes - ServerSocketAppender (or SSLServerSocketAppender) - listens passively on a TCP socket for connections from interested - clients that wish to receive logging events. The corresponding - SocketRemote (and SSLSocketRemote) provides - a component that can be added to any logback configuration in order to - connect to a remote server socket appender, and to log events received - from the remote appender according to local configuration. See - ServerSocketAppender - and SSLServerSocketAppender in the manual for usage instructions. -
    • -
    - -

    All of the new capabilities for socket-based appenders were - contributed by Carl Harris. -

    - +

    A receiver can either listen passively for connections from + remote SocketAppender components acting as clients, + or it can assume the client role, initiating a connection to a + remote appender acting as a server. The receiver components + shipped with Logback include full support for logging event + delivery over the Secure Sockets Layer (SSL).

    + +

    All of the new socket-based receiver and appender components were + contributed by Carl Harris. See + Receivers in the Logback Manual + for more information on configuring receiver components. See + SocketAppender and + ServerSocketAppender + for information on configuring appenders as event sources for + receiver components.

    +

    RollingFileAppender will now detect when file property collides with fileNamePattern, emit +

    In configuration files, the <include> element + now admits the optional attribute. This + fixes LOGBACK-230 + reported by Attila Kiraly. Many thanks to Tommy Becker who + contributed a patch.

    +

    In response to LOGBACK-829, serialization of Logger instances has been @@ -101,10 +146,59 @@

    The code detecting whether Groovy is available on the class path deals with the case where logback binaries are installed as - endoresed libraries. This fixes LOGBACK-831.

    +

    Groovy configurator no longer supports + SiftingAppender.

    + +

    In response to LOGBACK-244, LOGBACK-724 and + in particular patches provided by Tommy Becker and David Roussel + component tracking code has been simplified and completely + re-written. SiftingAppender now supports the timeout and maxAppenderCount + parameters. As a direct consequence of modifications to component + tracking code, the groovy configurator no longer supports + SiftingAppender.

    + +

    SiftingAppender now propagates properties defined elsewhere in + the configuration file into the configuration process of nested + appenders. This fixes LOGBACK-833 with + David Roussel providing the appropriate patch. +

    + +

    As all other actions affecting properties, + TimestampAction now inserts the user-specified + property into the local scope by default. The property was + inserted into the context scope in earlier versions of logback. + This fixes LOGBACK-835 with + David Roussel providing the appropriate patch. +

    + +

    Logback is now able to retrieve the name of localhost when + running under OS X and Java 7. This issue was reported by LOGBACK-749 by + Oliver Schrenk with patches provided by Ralph Goers and Pavel + Valodzka. +

    + +

    The mdc converter can now + handle default values. This feature was requested in LOGBACK-246 by + Michael Osipov with Denis Bazhenov providing a patch. +

    + +

    DBAppender in logback-classic module no longer + assumes that caller information is always available. This fixes LOGBACK-805 + reported by Daris Cooper who also provided a corrective patch.

    +

    In order to simplify our build, several unit tests have been ported from Scala to Java. It follows that logback no longer depends on Scala, not even during the test phase of the build.

    @@ -143,11 +237,6 @@ (Wee-Willie-Winkie) who contributed the appropriate fix.

    -

    DBAppender in logback-classic module no longer - assumes that caller information is always available. This fixes LOGBACK-805 - reported by Daris Cooper who also provided a corrective patch.

    -

    In logback-access, more correct determination of whether contents of an HttpServletRequest are URL encoded or not. The bug diff --git a/logback-site/src/site/pages/reasonsToSwitch.html b/logback-site/src/site/pages/reasonsToSwitch.html old mode 100644 new mode 100755 index 79506a2d0dd09ec1829c73d25b7eba341ce307aa..606face61fda1286c8d6620ccabba1e7156ac9e0 --- a/logback-site/src/site/pages/reasonsToSwitch.html +++ b/logback-site/src/site/pages/reasonsToSwitch.html @@ -10,9 +10,11 @@ - + + +

    @@ -31,16 +33,14 @@ will probably love logback.

    -

    Faster implementation

    +

    Faster implementation

    Based on our previous work on log4j, logback internals have been re-written to perform about ten times faster on certain critical execution paths. Not only are logback components faster, they have a smaller memory footprint as well.

    -

    Extensive - battery of tests

    +

    Extensive battery of tests

    Logback comes with a very extensive battery of tests developed over the course of several years and untold hours of work. While @@ -51,8 +51,8 @@ conditions.

    -

    logback-classic speaks SLF4J natively

    +

    logback-classic speaks SLF4J + natively

    Since the Logger class in logback-classic implements the SLF4J API natively, you incur zero overhead when @@ -65,14 +65,13 @@ in switching logging frameworks.

    -

    Extensive documentation

    +

    Extensive documentation

    Logback ships with detailed and constantly updated documentation.

    -

    Configuration files in XML or Groovy

    +

    Configuration files in XML or + Groovy

    The traditional way of configuring logback is via an XML file. Most of the examples in the documentation use this XML @@ -90,9 +89,8 @@ logback.groovy.

    -

    Automatic reloading of configuration - files

    +

    Automatic reloading of + configuration files

    Logback-classic can automatically reload its @@ -104,8 +102,8 @@ of a separate thread for scanning.

    -

    Graceful recovery from I/O failures

    +

    Graceful recovery from I/O + failures

    Logback's FileAppender and all its sub-classes, including RollingFileAppender, can gracefully recover @@ -116,8 +114,8 @@ from the previous error condition.

    -

    Automatic removal of old log archives

    +

    Automatic removal of old + log archives

    By setting the maxHistory property of -

    Automatic compression of archived log - files

    +

    Automatic compression of + archived log files

    RollingFileAppender @@ -143,8 +140,7 @@ duration of the compression.

    -

    Prudent mode

    +

    Prudent mode

    In prudent mode, multiple FileAppender instances running on multiple @@ -153,17 +149,15 @@ RollingFileAppender.

    -

    Lilith

    +

    Lilith

    Lilith is a logging and access event viewer for logback. It is comparable to log4j's chainsaw, except that Lilith is designed to handle large amounts of logging data without flinching.

    -

    Conditional processing of configuration - files

    +

    Conditional processing of + configuration files

    Developers often need to juggle between several logback configuration files targeting different environments such as @@ -178,8 +172,7 @@

    -

    Filters

    +

    Filters

    Logback comes with a wide array of filtering capabilities going much @@ -212,8 +205,7 @@

    -

    SiftingAppender

    +

    SiftingAppender

    SiftingAppender @@ -224,9 +216,8 @@ user go into distinct log files, one log file per user.

    -

    Stack traces with packaging data -

    +

    Stack traces with + packaging data

    When logback prints an exception, the stack trace will include packaging data. Here is a sample stack trace generated by the .

    -

    Logback-access, i.e. HTTP-access logging with - brains, is an integral part of logback

    +

    Logback-access, + i.e. HTTP-access logging with brains, is an integral part of + logback

    Last but not least, the logback-access module, part of the logback distribution, integrates with Servlet containers such as @@ -275,8 +266,7 @@ java.lang.Exception: 99 is invalid design, all the logback-classic features you love are available in logback-access as well.

    -

    In summary

    +

    In summary

    We have listed a number of reasons for preferring logback over log4j. Given that logback builds upon on our previous work on diff --git a/logback-site/src/site/pages/recipes/emailPerTransaction.html b/logback-site/src/site/pages/recipes/emailPerTransaction.html index 28ceead63fd679c878643a9302d4d82f09d69060..93f4d76a23bc69dafb7538d4631060352c750b6f 100644 --- a/logback-site/src/site/pages/recipes/emailPerTransaction.html +++ b/logback-site/src/site/pages/recipes/emailPerTransaction.html @@ -415,7 +415,7 @@ public class PrimeAction extends Action { <defaultValue>default</defaultValue> </discriminator> - <cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTrackerImpl"> + <cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTracker"> <maxNumberOfBuffers>512</maxNumberOfBuffers> </cyclicBufferTracker> diff --git a/logback-site/src/site/pages/setup.html b/logback-site/src/site/pages/setup.html index d68c79136eda5d7a0372128b334485c6440a871c..1648a2de4816fbe00b2a713e9a86ee6956934aa7 100755 --- a/logback-site/src/site/pages/setup.html +++ b/logback-site/src/site/pages/setup.html @@ -280,8 +280,8 @@ -

    The above listed procedure has been last tested bu the author - using Juno on April 4th 2013.

    +

    The above listed procedure has been last tested by the author + using Eclipse Juno on April 4th 2013.

    diff --git a/logback-site/src/site/pages/templates/creative.js b/logback-site/src/site/pages/templates/creative.js index a23a95ace76125d10f19af1c1414f4e4550cca8d..1548ecc4801098cc9de847b87befb48bcaccd030 100644 --- a/logback-site/src/site/pages/templates/creative.js +++ b/logback-site/src/site/pages/templates/creative.js @@ -3,7 +3,7 @@ document.write(' cellspacing="0" width="70%">'); document.write(' '); document.write(' '); document.write('

    '); -document.write(' Authors: Ceki Gülcü, Sébastien Pennec'); +document.write(' Authors: Ceki Gülcü, Sébastien Pennec, Carl Harris'); document.write('
    '); document.write(' Copyright © 2000-2012, QOS.ch

    '); document.write(' '); diff --git a/logback-site/src/site/pages/templates/footer.js b/logback-site/src/site/pages/templates/footer.js index 22944f959c802204fdcc487ef6040f371b11aefa..ef09cdcacdc9ed8d95fb73efd2cd2ea05d58bba3 100755 --- a/logback-site/src/site/pages/templates/footer.js +++ b/logback-site/src/site/pages/templates/footer.js @@ -5,9 +5,11 @@ document.write('') document.write('Copyright © 2013 QOS.ch') -//document.write(' ') -//document.write(' ') -//document.write(' ') +document.write(' '); +document.write(' '); +document.write(' Follow @qos_ch'); +document.write(' '); +document.write(' '); document.write('') diff --git a/logback-site/src/site/pages/volunteer.html b/logback-site/src/site/pages/volunteer.html old mode 100644 new mode 100755 index 364757123eeef4de2bf8c53d566b40b20ab164f1..62ec8ea5cdc60de9fe56e8393fde843489bd1e70 --- a/logback-site/src/site/pages/volunteer.html +++ b/logback-site/src/site/pages/volunteer.html @@ -27,17 +27,36 @@
    1. top priority logback in 10 minutes -

      We are looking for a volunteer to write a short document - describing logback for beginners, entitled say "logback in 10 - minutes". This document is likely to be the most widely read - document of the project. Writing such a document is an excellent - opportunity to learn logback. Obviously, there would be plenty - of editorial help and guidance coming from the logback - developers. +

      We are looking for a volunteer, preferably a native English + speaker, to write a short document describing logback for + beginners, entitled say "logback in 10 minutes". This document + is likely to be the most widely read document of the + project. Writing such a document is an excellent opportunity to + learn logback. Obviously, there would be plenty of editorial + help and guidance coming from the logback developers.

    2. -
    3. high priority Maintain the groovy configurator +
    4. high priority Proof reading the documentation +

      We are always looking for volunteers to proof-read the + documentation. Suggestions as to the design and look-and-feel of + the site are also welcome.

      +
    5. + +
    6. medium priority Decoder: + parse log files and transform them into logging events + +

      This effort has been started under the logback-decoder + project but has stalled. This problem is technically + interesting, has a well-defined scope and mostly independent of + the logback framework. +

      + +
    7. + +
    8. medium priority Maintain the + groovy configurator

      The Groovy configurator, aka Gaffer, although pretty cool, is not getting the attention it deserves. The amount of code @@ -47,12 +66,6 @@

    9. -
    10. Write a tool for parsing log files - -

      We are looking for a volunteer to write a tool for parsing - log files.

      -
    11. -
    12. Improve OSGi support

      We are looking for an OSGi expert to review our current @@ -63,17 +76,56 @@

      We are looking for volunteers for fixing logback bugs. Volunteering to solve bugs is a good way to learn about any project. -

      -
    13. +

      -
    14. high priority Proof reading the documentation -

      We are always looking for volunteers to proof-read the - documentation. Suggestions as to the design and look-and-feel of - the site are also welcome.

      -
    15. -
    +

    For those looking for highly technical challenges with + limited scope, have a look at various build failures observable + on our Jenkins + instance. +

    + +

    Our build is quite stable but failures occur from time to + time on our Jenkins instance hosted on a relatively old + computer.

    + + + +

    These build failures are quite hard to reproduce. If you + intend to work on these problems, you will probably first need + to make changes to logback code so that the problem becomes + easily reproducible. One the problem is identified and + reproducible, solving it should be much easier. +

    + +

    Setting up the project

    -

    >If you wish to contribute to the project or just hack for fun, +

    If you wish to contribute to the project or just hack for fun, you will probably want to import logback as a project into your favorite IDE. See the instructions for building logback in Eclipse or IntelliJ diff --git a/logback-site/src/site/resources/manual/images/chapters/receivers/serverSocketReceiver.png b/logback-site/src/site/resources/manual/images/chapters/receivers/serverSocketReceiver.png new file mode 100644 index 0000000000000000000000000000000000000000..4aaa5047ff4b55337293bce62bf664bae6fb1b81 Binary files /dev/null and b/logback-site/src/site/resources/manual/images/chapters/receivers/serverSocketReceiver.png differ diff --git a/logback-site/src/site/resources/manual/images/chapters/receivers/socketReceiver.png b/logback-site/src/site/resources/manual/images/chapters/receivers/socketReceiver.png new file mode 100644 index 0000000000000000000000000000000000000000..dbd79ec7d076131dab58908290e5369c37a41f70 Binary files /dev/null and b/logback-site/src/site/resources/manual/images/chapters/receivers/socketReceiver.png differ diff --git a/pom.xml b/pom.xml index eefe6bf0c01a5e5ee8c4abbb43e57a05f89fc4c4..eb4957c9a296ce2ccb1f08d86886dac5abe84c44 100755 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ch.qos.logback logback-parent - 1.0.12-SNAPSHOT + 2.0.0-SNAPSHOT pom Logback-Parent logback project pom.xml file @@ -47,11 +47,12 @@ + + 1.5 UTF-8 - 2.12.4 - 1.7.4 + 1.7.5 4.10 1.4 2.6.1 @@ -60,9 +61,14 @@ 1.1.0 7.0.21 7.5.1.v20110908 - 1.8 - 2.5 - + 1.9 + + 2.3.2 + 2.3.1 + 2.14.1 + 1.9.0 + 2.5 + @@ -222,17 +228,17 @@ org.apache.maven.plugins maven-compiler-plugin - 2.3.2 + ${maven-compiler-plugin.version} - 1.5 - 1.5 + ${jdk.version} + ${jdk.version} org.apache.maven.plugins maven-surefire-plugin - 2.10 + ${maven-surefire-plugin.version} @@ -248,10 +254,11 @@ + org.apache.maven.plugins maven-jar-plugin - 2.3.1 + ${maven-jar-plugin.version} @@ -290,7 +297,7 @@ org.codehaus.mojo findbugs-maven-plugin - ${findbugs.version} + ${findbugs-maven-plugin.version} High @@ -393,7 +400,7 @@ - com.google.code.maven-license-plugin + com.mycila.maven-license-plugin maven-license-plugin 1.9.0 @@ -417,19 +424,6 @@ - - - mc-release - Local Maven repository of releases - http://mc-repo.googlecode.com/svn/maven2/releases - - false - - - true - - - diff --git a/src/main/clas/signed-clas.txt b/src/main/clas/signed-clas.txt index f9e4a33bd0f132933216e3971c542ca4434cd9d3..47434adadf770b306fe39507fff7d4e4bcf74ca0 100644 --- a/src/main/clas/signed-clas.txt +++ b/src/main/clas/signed-clas.txt @@ -1,5 +1,5 @@ -Here is a list of persons who have signed a CLA [1] in file. +Here is a list of persons who have signed a CLA [1]. Name Location Date ---- -------- ---- @@ -27,34 +27,36 @@ Matthew Bishop Vancouver, Canada 2012-09-18 Joris Kuipers Amstelveen, NL 2013-02-11 Andrey Korzhevskiy Skryabina Akademika, Russia 2013-03-26 Carl E. Harris Jr. VA, USA 2013-03-27 +Matthew R. Bertolini NJ, USA 2013-04-23 +Gregory A. Denton WA, USA 2013-05-02 Justification for CLAs ---------------------- -There is no denying that the CLA requirement adds overhead. However, -the CLA offers several advantages: - -advantage 1) having a CLA on file for all contributors provides -reassurance to downstream users. For example, IP officers from Eclipse +The CLA requirement adds a bureaucratic step before contributions can +be accepted. However, the CLA offers several advantages: + +1) having a CLA on file for all contributors provides reassurance to +downstream users. For example, IP officers from Eclipse foundation contact QOS.ch at regular intervals asking whether QOS.ch has CLA for -all SLF4J and logback contributions. +SLF4J and logback contributions. -advantage 2) allows QOS.ch to change the software license as long as -the change is not contrary to public interest. This allowed QOS.ch to -add Eclipse Public License 1.0 (in addition to LGPL) in logback -version 0.9.18. This was undoubtedly a net gain for those wishing to -use logback and it was a fairly painless process. Without the CLA on -file, dual-licensing logback would have been near impossible. +2) allows QOS.ch to change the software license as long as the change +is not contrary to public interest. This allowed QOS.ch to add Eclipse +Public License 1.0 (in addition to LGPL) in logback version +0.9.18. This was undoubtedly a net gain for those wishing to use +logback and it was a fairly painless process. Without the CLA on file, +dual-licensing logback would have been near impossible. -advantage 3) by virtue of clause 3 of the CLA, the contributor vouches -for his/her contributions as his/her own. Thus, QOS.ch takes a lesser -risk when distributing software because QOS.ch can claim that some -vetting has been performed (due dillegence). +3) by virtue of clause 3 of the CLA, the contributor vouches for +his/her contributions as his/her own. Thus, QOS.ch takes a lesser risk +when distributing software because QOS.ch can claim that some vetting +has been performed (due diligence). -A more neutral discussion of CLAs can be found at [2]. +A more detailed discussion of CLAs can be found at [2]. BTW, the CLA can be sent to Ceki directly by email. A scanned copy on -two separate pages is OK but please make sure that the images render +two separate pages is fine but please make sure that the images render reasonably well when printed on a laser printer. Images taken by cellphone cameras often render as a large gray smudge when printed. diff --git a/src/main/javadocHeaders.xml b/src/main/javadocHeaders.xml index a0fccd47f3f259333c0ce138c160f2a5b5aa364b..066abc14543ebc41268f081fbafc76374c06c09b 100644 --- a/src/main/javadocHeaders.xml +++ b/src/main/javadocHeaders.xml @@ -3,7 +3,8 @@ /** * */ - + true + false (\s|\t)*/\*.*$ .*\*/(\s|\t)*$ diff --git a/src/main/licenseHeader.txt b/src/main/licenseHeader.txt index 7be6cb66b2b7dbe68de85719c5003d0403b95c30..52ccb40a0191501d31db8699000bde081eba13d9 100644 --- a/src/main/licenseHeader.txt +++ b/src/main/licenseHeader.txt @@ -1,5 +1,5 @@ Logback: the reliable, generic, fast and flexible logging framework. -Copyright (C) 1999-2011, QOS.ch. All rights reserved. +Copyright (C) 1999-2013, QOS.ch. All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by