THRIFT-558. java: Replace use of log4j by commons-logging in Java library and generated Java code

This patch switches Thrift to use slf4j instead of log4j. 



git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@804349 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bryan Duxbury 2009-08-14 20:04:15 +00:00
parent f5a0b3dfc8
commit c27cda57a0
9 changed files with 30 additions and 19 deletions

View File

@ -294,7 +294,8 @@ string t_java_generator::java_type_imports() {
"import java.util.HashSet;\n" +
"import java.util.Collections;\n" +
"import java.util.BitSet;\n" +
"import org.apache.log4j.Logger;\n\n";
"import org.slf4j.Logger;\n" +
"import org.slf4j.LoggerFactory;\n\n";
}
/**
@ -1932,7 +1933,7 @@ void t_java_generator::generate_service_server(t_service* tservice) {
"public static class Processor" << extends_processor << " implements TProcessor {" << endl;
indent_up();
indent(f_service_) << "private static final Logger LOGGER = Logger.getLogger(Processor.class.getName());" << endl;
indent(f_service_) << "private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());" << endl;
indent(f_service_) <<
"public Processor(Iface iface)" << endl;

View File

@ -70,11 +70,13 @@ AX_THRIFT_LIB(java, [Java], yes)
if test "$with_java" = "yes"; then
AX_JAVAC_AND_JAVA
AC_PATH_PROG([ANT], [ant])
AX_CHECK_JAVA_CLASS(org.apache.log4j.Logger)
have_log4j="$success"
AX_CHECK_JAVA_CLASS(org.slf4j.Logger)
have_slf4j="$success"
AX_CHECK_JAVA_CLASS(org.slf4j.impl.SimpleLogger)
have_slf4j_simple="$success"
AX_CHECK_JAVA_CLASS(org.apache.commons.lang.builder.HashCodeBuilder)
have_hashcode="$success"
if test "x$have_log4j" = "xyes" && test "x$have_hashcode" = "xyes" ; then
if test "x$have_slf4j_simple" = "xyes" && test "x$have_slf4j" = "xyes" && test "x$have_hashcode" = "xyes" ; then
ANT_FLAGS="$ANT_FLAGS -Dnoivy="
fi
AC_SUBST(CLASSPATH)

View File

@ -1,7 +1,8 @@
<ivy-module version="1.0">
<info organisation="jayasoft" module="hello-ivy" />
<dependencies>
<dependency org="log4j" name="log4j" rev="1.2.15" conf="default->master"/>
<dependency org="org.slf4j" name="slf4j-api" rev="1.5.8" conf="* -> *,!sources,!javadoc"/>
<dependency org="org.slf4j" name="slf4j-simple" rev="1.5.8" conf="* -> *,!sources,!javadoc"/>
<dependency org="commons-lang" name="commons-lang" rev="2.4" conf="* -> *,!sources,!javadoc"/>
</dependencies>
</ivy-module>

View File

@ -30,7 +30,8 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.thrift.TByteArrayOutputStream;
import org.apache.thrift.TException;
@ -59,7 +60,7 @@ import org.apache.thrift.transport.TTransportException;
*/
public class TNonblockingServer extends TServer {
private static final Logger LOGGER =
Logger.getLogger(TNonblockingServer.class.getName());
LoggerFactory.getLogger(TNonblockingServer.class.getName());
// Flag for stopping the server
private volatile boolean stopped_;

View File

@ -28,7 +28,9 @@ import org.apache.thrift.transport.TServerTransport;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportFactory;
import org.apache.thrift.transport.TTransportException;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Simple singlethreaded server for testing.
@ -36,7 +38,7 @@ import org.apache.log4j.Logger;
*/
public class TSimpleServer extends TServer {
private static final Logger LOGGER = Logger.getLogger(TSimpleServer.class.getName());
private static final Logger LOGGER = LoggerFactory.getLogger(TSimpleServer.class.getName());
private boolean stopped_ = false;

View File

@ -29,8 +29,9 @@ import org.apache.thrift.transport.TServerTransport;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
import org.apache.thrift.transport.TTransportFactory;
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -46,7 +47,7 @@ import java.util.concurrent.TimeUnit;
*/
public class TThreadPoolServer extends TServer {
private static final Logger LOGGER = Logger.getLogger(TThreadPoolServer.class.getName());
private static final Logger LOGGER = LoggerFactory.getLogger(TThreadPoolServer.class.getName());
// Executor service for handling client connections
private ExecutorService executorService_;

View File

@ -19,7 +19,8 @@
package org.apache.thrift.transport;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
@ -34,7 +35,7 @@ import java.io.OutputStream;
*/
public class TIOStreamTransport extends TTransport {
private static final Logger LOGGER = Logger.getLogger(TIOStreamTransport.class.getName());
private static final Logger LOGGER = LoggerFactory.getLogger(TIOStreamTransport.class.getName());
/** Underlying inputStream */
protected InputStream inputStream_ = null;

View File

@ -19,7 +19,8 @@
package org.apache.thrift.transport;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.InetSocketAddress;
@ -33,7 +34,7 @@ import java.net.SocketException;
*/
public class TServerSocket extends TServerTransport {
private static final Logger LOGGER = Logger.getLogger(TServerSocket.class.getName());
private static final Logger LOGGER = LoggerFactory.getLogger(TServerSocket.class.getName());
/**
* Underlying serversocket object

View File

@ -19,7 +19,8 @@
package org.apache.thrift.transport;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@ -34,7 +35,7 @@ import java.net.SocketException;
*/
public class TSocket extends TIOStreamTransport {
private static final Logger LOGGER = Logger.getLogger(TSocket.class.getName());
private static final Logger LOGGER = LoggerFactory.getLogger(TSocket.class.getName());
/**
* Wrapped Socket object