carnold 2005/05/11 20:55:46 Modified: . build.xml src/java/org/apache/log4j Category.java LogManager.java Logger.java src/java/org/apache/log4j/joran/spi Interpreter.java JoranDocument.java src/java/org/apache/log4j/rolling/helper RollingCalendar.java src/java/org/apache/log4j/spi ComponentBase.java src/java/org/apache/log4j/varia ExternallyRolledFileAppender.java Roller.java tests build.xml ugli-test.xml tests/src/java/org/apache/log4j/rolling SizeBasedRollingTest.java tests/src/java/org/apache/log4j/varia ExternallyRolledFileAppenderTest.java Added: src/java/org/apache/log4j/helpers MessageFormatter.java src/java/org/apache/log4j/spi NOPULogger.java SimpleULogger.java src/no-slf4j/org/apache/log4j ULogger.java src/slf4j/org/apache/log4j ULogger.java src/slf4j/org/slf4j LoggerFactory.java tests/src/java/org/apache/ugli InvokingUGLI.java Removed: . slf4j.xml Log: Bug 34883: Conditional SLF4J builds using SLF4J jars Revision Changes Path 1.156 +75 -36 logging-log4j/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/logging-log4j/build.xml,v retrieving revision 1.155 retrieving revision 1.156 diff -u -r1.155 -r1.156 --- build.xml 11 May 2005 20:18:17 -0000 1.155 +++ build.xml 12 May 2005 03:55:45 -0000 1.156 @@ -30,6 +30,11 @@ <!-- Destination for generated jar files --> <property name="jar.dest" value="${basedir}"/> + + <!-- + Specifies if log4j should be build implementing slf4j interfaces + Required slf4j-api.jar property to be set --> + <property name="slf4j" value="false"/> <!-- The jar file that the jar task will generate --> <property name="log4j.jar" value="log4j-${version}.jar"/> @@ -81,6 +86,7 @@ <pathelement location="${jdbc-stdext.jar}"/> <pathelement location="${jndi.jar}"/> <pathelement location="${jakarta-oro.jar}"/> + <pathelement location="${slf4j-api.jar}"/> </path> <!-- Construct classpath for building the html pages--> @@ -114,7 +120,13 @@ javadoc - build project javadoc files - dist - will create a complete distribution in dist/ + dist - will create a complete distribution in dist + + For an SLF4J enabled build: + + ant jar -Dslf4j=true + -Dslf4j-api.jar=../slf4j-1.0-beta2/slf4j-nop.jar + </echo> </target> @@ -200,24 +212,40 @@ <fail unless="servletAPI-present"> Missing javax.servlet.* classes. - Please make sure to that the "servlet-api.jar" property in build.properties + Please make sure that the "servlet-api.jar" property in build.properties file is set correctly. </fail> </target> - + <target name="slf4jCheck"> - <available file="${java.source.dir}/org/slf4j/ULogger.java" - property="slf4j-present"/> - - <fail unless="slf4j-present"> - Missing src/java/org/slf4j/*.java source files. - - Just run the refresh-slf4j target with the command: + <condition property="implement-slf4j" value="true"> + <istrue value="${slf4j}"/> + </condition> - ant refresh-slf4j + <condition property="missing-slf4j" value="true"> + <and> + <isset property="implement-slf4j"/> + <not> + <and> + <available classname="org.slf4j.ULogger"> + <classpath refid="compile.classpath"/> + </available> + <available file="${slf4j-api.jar}"/> + </and> + </not> + </and> + </condition> + + <fail if="missing-slf4j"> + Missing org.slf4j.* classes. + + Please make sure that "slf4j" is false or "slf4j-api.jar" property in build.properties + file is set correctly. </fail> </target> + + <target name="jdbcExtensionCheck"> @@ -240,18 +268,12 @@ <mkdir dir="${examples.javac.dest}/" /> </target> - <target name="refresh-slf4j"> - <echo>Fecthing required source files from SLF4J.ORG</echo> - <!-- copy required SLF4J files into log4j --> - <ant antfile="slf4j.xml" target="refresh-slf4j"/> - </target> - <target name="build" description="Compile all log4j components." depends="init, build.core, build.oro, build.jms, build.smtp, build.db, build.examples"/> <target name="requiredepsCheck" - depends="jndiCheck,jmsCheck,oroCheck,javamailCheck,servletAPICheck,jdbcExtensionCheck,jaxpCheck" + depends="jndiCheck,jmsCheck,oroCheck,javamailCheck,servletAPICheck,jdbcExtensionCheck,jaxpCheck,slf4jCheck" description="Compile all log4j components - fail if dependencies do not exist" > <condition property="alldeps.exist"> @@ -271,23 +293,20 @@ </fail> </target> - <target name="copy-slf4j-into-log4j" unless="slf4j-present"> - <echo>Fecthing required source files from SLF4J.ORG</echo> - <!-- copy required SLF4J files into log4j --> - <ant antfile="slf4j.xml" target="copy-into-log4j"/> - </target> + <target name="build.core" depends="init, jndiCheck, jaxpCheck, slf4jCheck"> + <condition property="slf4j.src.dir" value="src/slf4j"> + <isset property="implement-slf4j"/> + </condition> + <property name="slf4j.src.dir" value="src/slf4j"/> - - <target name="build.core" depends="init, slf4jCheck, jndiCheck, jaxpCheck"> - <javac srcdir="${java.source.dir}" - destdir="${javac.dest}" - includes="org/slf4j/**/*.java, - ${stem}/**/*.java" - excludes="org/slf4j/impl/JDK14*.java, - **/UnitTest*.java, + <javac destdir="${javac.dest}" + includes="${stem}/**/*.java, + org/slf4j/*.java" + excludes="**/UnitTest*.java, **/StressCategory.java, **/doc-files/*, ${stem}/db/**, + ${stem}/ULogger.java, ${stem}/test/serialization/**, ${stem}/net/SMTPAppender.java, ${stem}/net/JMS*.java, @@ -299,6 +318,8 @@ deprecation="on" debug="${debug}" > + <src path="${java.source.dir}"/> + <src path="${slf4j.src.dir}"/> <classpath refid="compile.classpath"/> </javac> </target> @@ -523,12 +544,30 @@ <!-- ================================================================= --> <!-- Create log4j.jar, excluding tests and other odds and ends. --> <!-- ================================================================= --> - <target name="log4j.jar" depends="build.core, build.servletAPI"> + + <!-- + if implementing SLF4J, expand the interface classes from the slf4j-api.jar + to be included in the log4j.jar + --> + <target name="slf4jExtract" depends="slf4jCheck" if="implement-slf4j"> + <unjar src="${slf4j-api.jar}" dest="${javac.dest}"> + <patternset> + <include name="org/slf4j/ULogger.class"/> + </patternset> + </unjar> + <property name="slf4j.exclude.pattern" value="bogus.bogus"/> + </target> + + + <target name="log4j.jar" depends="build.core, build.servletAPI, slf4jExtract"> <delete file="${log4j.jar}" verbose="true"/> + + <!-- if not a SLF4J build, exclude any stray SLF4J classes --> + <property name="slf4j.exclude.pattern" value="org/slf4j/**/*.class"/> <jar jarfile="${jar.dest}/${log4j.jar}" basedir="${javac.dest}" - includes="org/slf4j/**/*.class, + includes="org/slf4j/*.class, ${stem}/*.class, ${stem}/joran/**/*.class, ${stem}/config/*.class, @@ -549,8 +588,7 @@ ${stem}/varia/List*Appender.class ${stem}/plugins/*.class, ${stem}/config/*.class" - excludes="org/slf4j/**/JDK14*.class, - **/UnitTest**, + excludes="**/UnitTest**, ${stem}/xml/Log4jEntityResolver.class, ${stem}/xml/UtilLoggingEntityResolver.class, ${stem}/xml/SAXErrorHandler.class, @@ -570,7 +608,8 @@ ${stem}/net/SocketHub*.class, ${stem}/net/Telnet*.class, ${stem}/pattern/StackPatternConverter.class, - ${stem}/DUMMY.java" + ${stem}/DUMMY.java, + ${slf4j.exclude.pattern}" > <manifest> <attribute name="Manifest-version" value="1.0"/> 1.97 +1 -2 logging-log4j/src/java/org/apache/log4j/Category.java Index: Category.java =================================================================== RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/Category.java,v retrieving revision 1.96 retrieving revision 1.97 diff -u -r1.96 -r1.97 --- Category.java 28 Apr 2005 16:33:17 -0000 1.96 +++ Category.java 12 May 2005 03:55:45 -0000 1.97 @@ -37,8 +37,7 @@ import org.apache.log4j.spi.AppenderAttachable; import org.apache.log4j.spi.LoggerRepository; import org.apache.log4j.spi.LoggingEvent; -import org.slf4j.ULogger; -import org.slf4j.impl.MessageFormatter; +import org.apache.log4j.helpers.MessageFormatter; import java.util.Enumeration; import java.util.MissingResourceException; 1.43 +0 -7 logging-log4j/src/java/org/apache/log4j/LogManager.java Index: LogManager.java =================================================================== RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/LogManager.java,v retrieving revision 1.42 retrieving revision 1.43 diff -u -r1.42 -r1.43 --- LogManager.java 28 Apr 2005 16:33:17 -0000 1.42 +++ LogManager.java 12 May 2005 03:55:45 -0000 1.43 @@ -26,7 +26,6 @@ import org.apache.log4j.spi.LoggerRepository; import org.apache.log4j.spi.RepositorySelector; import org.apache.log4j.spi.RootLogger; -import org.slf4j.impl.SimpleLoggerFA; import java.util.Enumeration; @@ -52,12 +51,6 @@ */ public final static LoggerRepository defaultLoggerRepository; - /** - * Log4j components resort to this instance of [EMAIL PROTECTED] SimpleLoggerFA} in case - * an appropriate LoggerRepository was not set or could not be found. It is - * used only in exceptional cases. - */ - public final static SimpleLoggerFA SIMPLE_LOGGER_FA = new SimpleLoggerFA(); // The following static initializer gets invoked immediately after a call to 1.31 +1 -1 logging-log4j/src/java/org/apache/log4j/Logger.java Index: Logger.java =================================================================== RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/Logger.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- Logger.java 28 Apr 2005 16:33:17 -0000 1.30 +++ Logger.java 12 May 2005 03:55:45 -0000 1.31 @@ -17,7 +17,7 @@ package org.apache.log4j; import org.apache.log4j.spi.LoggerFactory; -import org.slf4j.impl.MessageFormatter; +import org.apache.log4j.helpers.MessageFormatter; /** 1.5 +1 -1 logging-log4j/src/java/org/apache/log4j/helpers/MessageFormatter.java 1.6 +3 -3 logging-log4j/src/java/org/apache/log4j/joran/spi/Interpreter.java Index: Interpreter.java =================================================================== RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/joran/spi/Interpreter.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Interpreter.java 28 Apr 2005 16:33:16 -0000 1.5 +++ Interpreter.java 12 May 2005 03:55:45 -0000 1.6 @@ -16,13 +16,13 @@ package org.apache.log4j.joran.spi; -import org.apache.log4j.LogManager; +import org.apache.log4j.spi.SimpleULogger; import org.apache.log4j.joran.action.Action; import org.apache.log4j.joran.action.ImplicitAction; import org.apache.log4j.spi.Component; import org.apache.log4j.spi.ErrorItem; import org.apache.log4j.spi.LoggerRepository; -import org.slf4j.ULogger; +import org.apache.log4j.ULogger; import org.xml.sax.Attributes; import org.xml.sax.EntityResolver; @@ -402,7 +402,7 @@ if(repository != null) { return repository.getLogger(this.getClass().getName()); } else { - return LogManager.SIMPLE_LOGGER_FA.getLogger(this.getClass().getName()); + return SimpleULogger.getLogger(this.getClass().getName()); } } } 1.3 +3 -3 logging-log4j/src/java/org/apache/log4j/joran/spi/JoranDocument.java Index: JoranDocument.java =================================================================== RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/joran/spi/JoranDocument.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- JoranDocument.java 28 Apr 2005 16:33:16 -0000 1.2 +++ JoranDocument.java 12 May 2005 03:55:45 -0000 1.3 @@ -16,12 +16,12 @@ package org.apache.log4j.joran.spi; -import org.apache.log4j.LogManager; +import org.apache.log4j.spi.SimpleULogger; import org.apache.log4j.helpers.Constants; import org.apache.log4j.spi.ErrorItem; import org.apache.log4j.spi.LoggerRepository; -import org.slf4j.ULogger; +import org.apache.log4j.ULogger; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; @@ -163,7 +163,7 @@ if (repository != null) { return repository.getLogger(this.getClass().getName()); } else { - return LogManager.SIMPLE_LOGGER_FA.getLogger(this.getClass().getName()); + return SimpleULogger.getLogger(this.getClass().getName()); } } 1.5 +1 -1 logging-log4j/src/java/org/apache/log4j/rolling/helper/RollingCalendar.java Index: RollingCalendar.java =================================================================== RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/rolling/helper/RollingCalendar.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- RollingCalendar.java 28 Apr 2005 16:33:16 -0000 1.4 +++ RollingCalendar.java 12 May 2005 03:55:45 -0000 1.5 @@ -16,7 +16,7 @@ package org.apache.log4j.rolling.helper; -import org.slf4j.ULogger; +import org.apache.log4j.ULogger; import java.text.SimpleDateFormat; 1.8 +5 -5 logging-log4j/src/java/org/apache/log4j/spi/ComponentBase.java Index: ComponentBase.java =================================================================== RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/spi/ComponentBase.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ComponentBase.java 28 Apr 2005 16:33:17 -0000 1.7 +++ ComponentBase.java 12 May 2005 03:55:45 -0000 1.8 @@ -6,9 +6,9 @@ */ package org.apache.log4j.spi; -import org.apache.log4j.LogManager; -import org.slf4j.ULogger; -import org.slf4j.impl.NOPLogger; +import org.apache.log4j.ULogger; +import org.apache.log4j.spi.NOPULogger; +import org.apache.log4j.spi.SimpleULogger; /** @@ -69,7 +69,7 @@ if(repository != null) { logger = repository.getLogger(this.getClass().getName()); } else { - logger = LogManager.SIMPLE_LOGGER_FA.getLogger(this.getClass().getName()); + logger = SimpleULogger.getLogger(this.getClass().getName()); } } else if(repository != null && !(logger instanceof org.apache.log4j.Logger)){ // if repository is set but logger is not an instance of Logger, we @@ -89,7 +89,7 @@ */ protected ULogger getNonFloodingLogger() { if(errorCount++ >= ERROR_COUNT_LIMIT) { - return NOPLogger.NOP_LOGGER; + return NOPULogger.NOP_LOGGER; } else { return getLogger(); } 1.1 logging-log4j/src/java/org/apache/log4j/spi/NOPULogger.java Index: NOPULogger.java =================================================================== /* * Copyright 1999,2004 The Apache Software Foundation. * * 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 org.apache.log4j.spi; import org.apache.log4j.ULogger; /** * A no operation (NOP) implementation of [EMAIL PROTECTED] ULogger}. * * @author Ceki Gülcü */ public class NOPULogger implements ULogger { /** * The unique instance of NOPLogger. */ public final static NOPULogger NOP_LOGGER = new NOPULogger(); /** * There is no point in people creating multiple instances of NullLogger. * Hence, the private access modifier. */ private NOPULogger() { } public static NOPULogger getLogger(final String name) { return NOP_LOGGER; } /* Always returns false. * * @see org.apache.ugli.Logger#isDebugEnabled() */ public boolean isDebugEnabled() { return false; } /* A NOP implementation. * @see org.apache.ugli.Logger#debug(java.lang.Object) */ public void debug(Object msg) { // NOP } /* A NOP implementation. * @see org.apache.ugli.Logger#debug(java.lang.Object, java.lang.Object) */ public void debug(Object parameterizedMsg, Object param1) { // NOP } /* A NOP implementation. * @see org.apache.ugli.Logger#debug(java.lang.Object, java.lang.Object, java.lang.Object) */ public void debug(String parameterizedMsg, Object param1, Object param2) { // NOP } /* A NOP implementation. * @see org.apache.ugli.Logger#debug(java.lang.Object, java.lang.Throwable) */ public void debug(Object msg, Throwable t) { // NOP } /* Always returns false. * @see org.apache.ugli.Logger#isInfoEnabled() */ public boolean isInfoEnabled() { // NOP return false; } /* A NOP implementation. * @see org.apache.ugli.Logger#info(java.lang.Object) */ public void info(Object msg) { // NOP } /* A NOP implementation. * @see org.apache.ugli.Logger#info(java.lang.Object, java.lang.Object) */ public void info(Object parameterizedMsg, Object param1) { // NOP } /* A NOP implementation. * @see org.apache.ugli.Logger#info(java.lang.Object, java.lang.Object, java.lang.Object) */ public void info(String parameterizedMsg, Object param1, Object param2) { // NOP } /* A NOP implementation. * @see org.apache.ugli.Logger#info(java.lang.Object, java.lang.Throwable) */ public void info(Object msg, Throwable t) { // NOP } /* Always returns false. * @see org.apache.ugli.Logger#isWarnEnabled() */ public boolean isWarnEnabled() { return false; } /* A NOP implementation. * @see org.apache.ugli.Logger#warn(java.lang.Object) */ public void warn(Object msg) { // NOP } /* A NOP implementation. * @see org.apache.ugli.Logger#warn(java.lang.Object, java.lang.Object) */ public void warn(Object parameterizedMsg, Object param1) { // NOP } /* A NOP implementation. * @see org.apache.ugli.Logger#warn(java.lang.Object, java.lang.Object, java.lang.Object) */ public void warn(String parameterizedMsg, Object param1, Object param2) { // NOP } /* A NOP implementation. * @see org.apache.ugli.Logger#warn(java.lang.Object, java.lang.Throwable) */ public void warn(Object msg, Throwable t) { // NOP } /* Always returns false. * @see org.apache.ugli.Logger#isErrorEnabled() */ public boolean isErrorEnabled() { return false; } /* A NOP implementation. * @see org.apache.ugli.Logger#error(java.lang.Object) */ public void error(Object msg) { // NOP } /* A NOP implementation. * @see org.apache.ugli.Logger#error(java.lang.Object, java.lang.Object) */ public void error(Object parameterizedMsg, Object param1) { // NOP } /* A NOP implementation. * @see org.apache.ugli.Logger#error(java.lang.Object, java.lang.Object, java.lang.Object) */ public void error(String parameterizedMsg, Object param1, Object param2) { // NOP } /* A NOP implementation. * @see org.apache.ugli.Logger#error(java.lang.Object, java.lang.Throwable) */ public void error(Object msg, Throwable t) { // NOP } } 1.1 logging-log4j/src/java/org/apache/log4j/spi/SimpleULogger.java Index: SimpleULogger.java =================================================================== /* * Copyright 1999,2004 The Apache Software Foundation. * * 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 org.apache.log4j.spi; import org.apache.log4j.ULogger; import org.apache.log4j.helpers.MessageFormatter; /** * A simple implementation that logs messages of level INFO or higher on * the console (<code>System.out<code>). * <p> * The output includes the relative time in milliseconds, thread name, the level, * logger name, and the message followed by the line separator for the host. * In log4j terms it amounts to the "%r [%t] %level %logger - %m%n" pattern. * <pre> 176 [main] INFO examples.Sort - Populating an array of 2 elements in reverse order. 225 [main] INFO examples.SortAlgo - Entered the sort method. 304 [main] INFO SortAlgo.DUMP - Dump of interger array: 317 [main] INFO SortAlgo.DUMP - Element [0] = 0 331 [main] INFO SortAlgo.DUMP - Element [1] = 1 343 [main] INFO examples.Sort - The next log statement should be an error message. 346 [main] ERROR SortAlgo.DUMP - Tried to dump an uninitialized array. at org.log4j.examples.SortAlgo.dump(SortAlgo.java:58) at org.log4j.examples.Sort.main(Sort.java:64) 467 [main] INFO examples.Sort - Exiting main method. </pre> * * @author Ceki Gülcü */ public class SimpleULogger implements ULogger { private final String loggerName; /** * Mark the time when this class gets loaded into memory. */ private static long startTime = System.currentTimeMillis(); public static final String LINE_SEPARATOR = System.getProperty("line.separator"); static private String INFO_STR = "INFO"; static private String WARN_STR = "WARN"; static private String ERROR_STR = "ERROR"; /** * Constructor is private to force construction through getLogger. */ private SimpleULogger(final String name) { this.loggerName = name; } /** * Creates a new instance. * * @param name logger name * @return logger. */ public static SimpleULogger getLogger(final String name) { return new SimpleULogger(name); } /** * Always returns false. */ public boolean isDebugEnabled() { return false; } /** * A NOP implementation. */ public void debug(Object msg) { // NOP } /** * A NOP implementation. */ public void debug(Object parameterizedMsg, Object param1) { // NOP } /** * A NOP implementation. */ public void debug(String parameterizedMsg, Object param1, Object param2) { // NOP } /** * A NOP implementation. */ public void debug(Object msg, Throwable t) { // NOP } /** * This is our internal implementation for logging regular (non-parameterized) * log messages. * * @param level * @param message * @param t */ private void log(final String level, final String message, final Throwable t) { StringBuffer buf = new StringBuffer(); long millis = System.currentTimeMillis(); buf.append(millis-startTime); buf.append(" ["); buf.append(Thread.currentThread().getName()); buf.append("] "); buf.append(level); buf.append(" "); buf.append(loggerName); buf.append(" - "); buf.append(message); buf.append(LINE_SEPARATOR); System.out.print(buf.toString()); if(t != null) { t.printStackTrace(System.out); } System.out.flush(); } /** * For parameterized messages, first substitute parameters and then log. * * @param level * @param parameterizedMsg * @param param1 * @param param2 */ private void parameterizedLog(final String level, final Object parameterizedMsg, final Object param1, final Object param2) { if (parameterizedMsg instanceof String) { String msgStr = (String) parameterizedMsg; msgStr = MessageFormatter.format(msgStr, param1, param2); log(level, msgStr, null); } else { // To be failsafe, we handle the case where 'messagePattern' is not // a String. Unless the user makes a mistake, this should not happen. log(level, parameterizedMsg.toString(), null); } } /** * Always returns true. */ public boolean isInfoEnabled() { return true; } /** * A simple implementation which always logs messages of level INFO according * to the format outlined above. */ public void info(final Object msg) { log(INFO_STR, msg.toString(), null); } /** * Perform single parameter substitution before logging the message of level * INFO according to the format outlined above. */ public void info(final Object parameterizedMsg, final Object param1) { parameterizedLog(INFO_STR, parameterizedMsg, param1, null); } /** * Perform double parameter substitution before logging the message of level * INFO according to the format outlined above. */ public void info(final String parameterizedMsg, final Object param1, final Object param2) { parameterizedLog(INFO_STR, parameterizedMsg, param1, param2); } /** * Log a message of level INFO, including an exception. */ public void info(final Object msg, final Throwable t) { log(INFO_STR, msg.toString(), t); } /** * Always returns true. */ public boolean isWarnEnabled() { return true; } /** * A simple implementation which always logs messages of level WARN according * to the format outlined above. */ public void warn(final Object msg) { log(WARN_STR, msg.toString(), null); } /** * Perform single parameter substitution before logging the message of level * WARN according to the format outlined above. */ public void warn(final Object parameterizedMsg, final Object param1) { parameterizedLog(WARN_STR, parameterizedMsg, param1, null); } /** * Perform double parameter substitution before logging the message of level * WARN according to the format outlined above. */ public void warn(final String parameterizedMsg, final Object param1, final Object param2) { parameterizedLog(WARN_STR, parameterizedMsg, param1, param2); } /** * Log a message of level WARN, including an exception. */ public void warn(final Object msg, final Throwable t) { log(WARN_STR, msg.toString(), t); } /** * Always returns true. */ public boolean isErrorEnabled() { return true; } /** * A simple implementation which always logs messages of level ERROR acoording * to the format outlined above. */ public void error(final Object msg) { log(ERROR_STR, msg.toString(), null); } /** * Perform single parameter substitution before logging the message of level * ERROR according to the format outlined above. */ public void error(final Object parameterizedMsg, final Object param1) { parameterizedLog(ERROR_STR, parameterizedMsg, param1, null); } /** * Perform double parameter substitution before logging the message of level * ERROR according to the format outlined above. */ public void error(final String parameterizedMsg, final Object param1, final Object param2) { parameterizedLog(ERROR_STR, parameterizedMsg, param1, param2); } /** * Log a message of level ERROR, including an exception. */ public void error(final Object msg, final Throwable t) { log(ERROR_STR, msg.toString(), t); } } 1.18 +1 -3 logging-log4j/src/java/org/apache/log4j/varia/ExternallyRolledFileAppender.java Index: ExternallyRolledFileAppender.java =================================================================== RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/varia/ExternallyRolledFileAppender.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- ExternallyRolledFileAppender.java 11 May 2005 19:50:01 -0000 1.17 +++ ExternallyRolledFileAppender.java 12 May 2005 03:55:45 -0000 1.18 @@ -16,8 +16,6 @@ package org.apache.log4j.varia; -import org.apache.log4j.RollingFileAppender; - import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -49,7 +47,7 @@ @since version 0.9.0 @deprecated version 1.3 */ -public final class ExternallyRolledFileAppender extends RollingFileAppender { +public final class ExternallyRolledFileAppender extends org.apache.log4j.RollingFileAppender { /** The string constant sent to initiate a roll over. Current value of this string constant is <b>RollOver</b>. 1.7 +5 -0 logging-log4j/src/java/org/apache/log4j/varia/Roller.java Index: Roller.java =================================================================== RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/varia/Roller.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Roller.java 11 May 2005 19:34:21 -0000 1.6 +++ Roller.java 12 May 2005 03:55:45 -0000 1.7 @@ -88,6 +88,11 @@ } } + /** + * Sends a roll request on the specified port. + * + * @deprecated Deprecated since ExternallyRolledFileAppender is deprecated + */ static void roll() { try { 1.1 logging-log4j/src/no-slf4j/org/apache/log4j/ULogger.java Index: ULogger.java =================================================================== /* * Copyright 1999,2005 The Apache Software Foundation. * * 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 org.apache.log4j; /** * A proxy for org.slf4j.ULogger. In slf4j implementing builds, this * interface will extend org.slf4j.ULogger and add no additional methods. * * @author Ceki Gülcü * @author Curt Arnold */ public interface ULogger { /** * Is the logger instance enabled for the DEBUG level? * @return true if debug is enabled. */ public boolean isDebugEnabled(); // /** * Log a message object with the DEBUG level. * @param msg - the message object to be logged */ public void debug(Object msg); /** * Log a parameterized message object at the DEBUG level. * * <p>This form is useful in avoiding the superflous object creation * problem when invoking this method while it is disabled. * </p> * @param parameterizedMsg - the parameterized message object * @param param1 - the parameter */ public void debug(Object parameterizedMsg, Object param1); /** * Log a parameterized message object at the DEBUG level. * * <p>This form is useful in avoiding the superflous object creation * problem when invoking this method while it is disabled. * </p> * @param parameterizedMsg - the parameterized message object * @param param1 - the first parameter * @param param2 - the second parameter */ public void debug(String parameterizedMsg, Object param1, Object param2); public void debug(Object msg, Throwable t); public boolean isInfoEnabled(); public void info(Object msg); public void info(Object parameterizedMsg, Object param1); public void info(String parameterizedMsg, Object param1, Object param2); public void info(Object msg, Throwable t); public boolean isWarnEnabled(); public void warn(Object msg); public void warn(Object parameterizedMsg, Object param1); public void warn(String parameterizedMsg, Object param1, Object param2); public void warn(Object msg, Throwable t); public boolean isErrorEnabled(); public void error(Object msg); public void error(Object parameterizedMsg, Object param1); public void error(String parameterizedMsg, Object param1, Object param2); public void error(Object msg, Throwable t); } 1.1 logging-log4j/src/slf4j/org/apache/log4j/ULogger.java Index: ULogger.java =================================================================== /* * Copyright 1999,2005 The Apache Software Foundation. * * 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 org.apache.log4j; /** * A proxy for org.slf4j.ULogger. In slf4j implementing builds, this * interface will extend org.slf4j.ULogger and add no additional methods. * * @author Ceki Gülcü * @author Curt Arnold */ public interface ULogger extends org.slf4j.ULogger { } 1.1 logging-log4j/src/slf4j/org/slf4j/LoggerFactory.java Index: LoggerFactory.java =================================================================== /* * Copyright 1999,2005 The Apache Software Foundation. * * 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 org.slf4j; import org.apache.log4j.Logger; /** * Concrete implementation of SLF4J LoggerFactory contract * that returns log4j Loggers. * * @author Curt Arnold */ public class LoggerFactory { private LoggerFactory() { } static public ULogger getLogger(final String name) { return Logger.getLogger(name); } static public ULogger getLogger(final String domainName, final String subDomainName) { return Logger.getLogger(domainName); } static public ULogger getLogger(final Class clazz) { return Logger.getLogger(clazz.getName()); } static public ULogger getLogger(final Class clazz, final String subDomainName) { return Logger.getLogger(clazz.getName()); } } 1.105 +2 -0 logging-log4j/tests/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/logging-log4j/tests/build.xml,v retrieving revision 1.104 retrieving revision 1.105 diff -u -r1.104 -r1.105 --- build.xml 11 May 2005 19:27:14 -0000 1.104 +++ build.xml 12 May 2005 03:55:46 -0000 1.105 @@ -33,6 +33,8 @@ <pathelement location="${javac.dest}"/> <pathelement location="./resources"/> <pathelement location="${jakarta-oro.jar}"/> + <pathelement location="${javamail.jar}"/> + <pathelement location="${activation.jar}"/> <fileset dir="./lib/"> <include name="*.jar"/> </fileset> 1.5 +11 -79 logging-log4j/tests/ugli-test.xml Index: ugli-test.xml =================================================================== RCS file: /home/cvs/logging-log4j/tests/ugli-test.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ugli-test.xml 11 Feb 2005 14:45:51 -0000 1.4 +++ ugli-test.xml 12 May 2005 03:55:46 -0000 1.5 @@ -1,5 +1,8 @@ <project name="testing-UGLI" default="usage" basedir="." > + <!-- The build.properties file defines the parth to local jar files --> + <property file="build.properties"/> + <!-- The directory where source files are stored. --> <property name="tests.source.home" value="./src/java/"/> @@ -21,24 +24,9 @@ <path id="compile.classpath"> <path refid="basic.classpath"/> - <pathelement location="../ugli-nop.jar"/> + <pathelement location="${slf4j-api.jar}"/> </path> - <path id="nop.classpath"> - <path refid="basic.classpath"/> - <pathelement location="../ugli-nop.jar"/> - </path> - - <path id="simple.classpath"> - <path refid="basic.classpath"/> - <pathelement location="../ugli-simple.jar"/> - </path> - - <path id="jdk14.classpath"> - <path refid="basic.classpath"/> - <pathelement location="../ugli-jdk14.jar"/> - </path> - <path id="log4j.classpath"> <path refid="basic.classpath"/> <fileset dir=".."> @@ -63,15 +51,10 @@ </echo> </target> - <target name="siblingBuild"> - <ant antfile="build.xml" target="build"/> - </target> - - - <target name="build" depends="siblingBuild"> + <target name="build"> <javac srcdir="${tests.source.home}" destdir="${javac.dest}" - includes="${stem}/ugli/**.java" + includes="org/apache/ugli/**.java" deprecation="${deprecation}" debug="on"> <classpath refid="compile.classpath"/> @@ -79,27 +62,11 @@ </target> - <target name="cleanOutputDir"> - <ant antfile="build.xml" target="cleanOutputDir"/> - </target> - - <target name="ugli-nop.jar"> - <!-- Invoke ugli.xml located one directory up --> - <ant dir=".." antfile="ugli.xml" target="ugli-nop.jar"/> - </target> - - <target name="ugli-simple.jar"> - <!-- Invoke ugli.xml located one directory up --> - <ant dir=".." antfile="ugli.xml" target="ugli-simple.jar"/> - </target> - - <target name="ugli-jdk14.jar"> - <ant dir=".." antfile="ugli.xml" target="ugli-jdk14.jar"/> - </target> - <target name="log4j.jar"> <!-- The main build is big enough to have its own properties --> - <ant dir=".." antfile="build.xml" target="log4j.jar" inheritAll="false"/> + <ant dir=".." antfile="build.xml" target="log4j.jar" inheritAll="false"> + <property name="slf4j" value="true"/> + </ant> </target> <!-- ================================================================= --> @@ -112,46 +79,11 @@ <!-- unit tests. Regression tests compare output with a previously --> <!-- created witness file. --> <!-- ================================================================= --> - <target name="regression" depends="MessageFormatter, - InvokeNOP, - InvokeSimple, - InvokeJDK14" - /> + <target name="regression" depends="InvokeLog4J"/> - <target name="MessageFormatter" depends="build, cleanOutputDir"> - <junit printsummary="yes" fork="yes" haltonfailure="yes"> - <classpath refid="compile.classpath"/> - <formatter type="plain" usefile="false"/> - <test name="org.apache.ugli.impl.MessageFormatterTest" /> - </junit> - </target> - - <target name="InvokeNOP" depends="build, ugli-nop.jar, cleanOutputDir"> - <junit printsummary="yes" fork="yes" haltonfailure="yes"> - <classpath refid="nop.classpath"/> - <formatter type="plain" usefile="false"/> - <test name="org.apache.ugli.InvokingUGLI" /> - </junit> - </target> - - <target name="InvokeSimple" depends="build, ugli-simple.jar, cleanOutputDir"> - <junit printsummary="yes" fork="yes" haltonfailure="yes"> - <classpath refid="simple.classpath"/> - <formatter type="plain" usefile="false"/> - <test name="org.apache.ugli.InvokingUGLI" /> - </junit> - </target> - - <target name="InvokeJDK14" depends="build, ugli-jdk14.jar, cleanOutputDir"> - <junit printsummary="yes" fork="yes" haltonfailure="yes"> - <classpath refid="jdk14.classpath"/> - <formatter type="plain" usefile="false"/> - <test name="org.apache.ugli.InvokingUGLI" /> - </junit> - </target> - <target name="InvokeLog4j" depends="build, log4j.jar, cleanOutputDir"> + <target name="InvokeLog4J" depends="build, log4j.jar"> <copy file="input/ugli/basic.xml" tofile="${javac.dest}/log4j.xml"/> 1.13 +0 -3 logging-log4j/tests/src/java/org/apache/log4j/rolling/SizeBasedRollingTest.java Index: SizeBasedRollingTest.java =================================================================== RCS file: /home/cvs/logging-log4j/tests/src/java/org/apache/log4j/rolling/SizeBasedRollingTest.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- SizeBasedRollingTest.java 8 May 2005 03:43:41 -0000 1.12 +++ SizeBasedRollingTest.java 12 May 2005 03:55:46 -0000 1.13 @@ -165,9 +165,6 @@ assertTrue(Compare.gzCompare("output/sbr-test3.1.gz", "witness/rolling/sbr-test3.1.gz")); } - boolean isWindows() { - return System.getProperty("os.name").indexOf("Windows") != -1; - } /** * Build test suite using this class and ObsoleteRollingFileAppenderTest. 1.2 +6 -0 logging-log4j/tests/src/java/org/apache/log4j/varia/ExternallyRolledFileAppenderTest.java Index: ExternallyRolledFileAppenderTest.java =================================================================== RCS file: /home/cvs/logging-log4j/tests/src/java/org/apache/log4j/varia/ExternallyRolledFileAppenderTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ExternallyRolledFileAppenderTest.java 11 May 2005 19:27:14 -0000 1.1 +++ ExternallyRolledFileAppenderTest.java 12 May 2005 03:55:46 -0000 1.2 @@ -122,6 +122,12 @@ assertTrue(new File("output/obsoleteERFA-test2.log.1").exists()); } + /** + * Sends a roll request to the appender. + * + * @deprecated Class under test is deprecated. + * @throws java.io.IOException + */ private void roll() throws java.io.IOException { Socket socket = new Socket(InetAddress.getLocalHost(), portNo); DataOutputStream dos = new DataOutputStream(socket.getOutputStream()); 1.3 +3 -1 logging-log4j/tests/src/java/org/apache/ugli/InvokingUGLI.java
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]