mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
migrate from JUL to SLF4j
This commit is contained in:
1 parent
4ce891eb43
commit
0a951165e5
108 files changed
+688
-631
No files matched your search
@@ -8,8 +8,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.RollbackException;
|
||||
@@ -21,13 +19,15 @@ import com.avaje.ebeaninternal.api.SpiTransaction;
|
||||
import com.avaje.ebeaninternal.api.TransactionEvent;
|
||||
import com.avaje.ebeaninternal.server.persist.BatchControl;
|
||||
import com.avaje.ebeaninternal.server.transaction.TransactionManager.OnQueryOnly;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* JDBC Connection based transaction.
|
||||
*/
|
||||
public class JdbcTransaction implements SpiTransaction {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(JdbcTransaction.class.getName());
|
||||
private static final Logger logger = LoggerFactory.getLogger(JdbcTransaction.class);
|
||||
|
||||
private static final String illegalStateMessage = "Transaction is Inactive";
|
||||
|
||||
@@ -517,7 +517,7 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
connection.setReadOnly(false);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
logger.log(Level.SEVERE, "Error setting to readOnly?", e);
|
||||
logger.error("Error setting to readOnly?", e);
|
||||
}
|
||||
try {
|
||||
if (this.autoCommit) {
|
||||
@@ -525,14 +525,14 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
connection.setAutoCommit(true);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
logger.log(Level.SEVERE, "Error setting to readOnly?", e);
|
||||
logger.error("Error setting to readOnly?", e);
|
||||
}
|
||||
try {
|
||||
connection.close();
|
||||
} catch (Exception ex) {
|
||||
// the connection pool will automatically remove the
|
||||
// connection if it does not pass the test
|
||||
logger.log(Level.SEVERE, "Error closing connection", ex);
|
||||
logger.error("Error closing connection", ex);
|
||||
}
|
||||
connection = null;
|
||||
active = false;
|
||||
@@ -581,7 +581,7 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String m = "Error when ending a query only transaction via " + onQueryOnly;
|
||||
logger.log(Level.SEVERE, m, e);
|
||||
logger.error(m, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-12
@@ -1,8 +1,5 @@
|
||||
package com.avaje.ebeaninternal.server.transaction;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.persistence.PersistenceException;
|
||||
@@ -20,6 +17,8 @@ import javax.transaction.UserTransaction;
|
||||
import com.avaje.ebean.LogLevel;
|
||||
import com.avaje.ebean.config.ExternalTransactionManager;
|
||||
import com.avaje.ebeaninternal.api.SpiTransaction;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Hook into external JTA transaction manager.
|
||||
@@ -28,7 +27,7 @@ import com.avaje.ebeaninternal.api.SpiTransaction;
|
||||
*/
|
||||
public class JtaTransactionManager implements ExternalTransactionManager {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(JtaTransactionManager.class.getName());
|
||||
private static final Logger logger = LoggerFactory.getLogger(JtaTransactionManager.class);
|
||||
|
||||
private static final String EBEAN_TXN_RESOURCE = "EBEAN_TXN_RESOURCE";
|
||||
|
||||
@@ -106,15 +105,15 @@ public class JtaTransactionManager implements ExternalTransactionManager {
|
||||
if (currentEbeanTransaction != null){
|
||||
// NOT expecting this so log WARNING
|
||||
String msg = "JTA Transaction - no current txn BUT using current Ebean one "+currentEbeanTransaction.getId();
|
||||
logger.log(Level.WARNING, msg);
|
||||
logger.warn(msg);
|
||||
return currentEbeanTransaction;
|
||||
}
|
||||
|
||||
UserTransaction ut = getUserTransaction();
|
||||
if (ut == null){
|
||||
// no current JTA transaction
|
||||
if (logger.isLoggable(Level.FINE)){
|
||||
logger.fine("JTA Transaction - no current txn");
|
||||
if (logger.isDebugEnabled()){
|
||||
logger.debug("JTA Transaction - no current txn");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -203,8 +202,8 @@ public class JtaTransactionManager implements ExternalTransactionManager {
|
||||
|
||||
switch (status) {
|
||||
case Status.STATUS_COMMITTED:
|
||||
if (logger.isLoggable(Level.FINE)){
|
||||
logger.fine("Jta Txn ["+transaction.getId()+"] committed");
|
||||
if (logger.isDebugEnabled()){
|
||||
logger.debug("Jta Txn ["+transaction.getId()+"] committed");
|
||||
}
|
||||
transactionManager.notifyOfCommit(transaction);
|
||||
// Remove this transaction object as it is completed
|
||||
@@ -212,8 +211,8 @@ public class JtaTransactionManager implements ExternalTransactionManager {
|
||||
break;
|
||||
|
||||
case Status.STATUS_ROLLEDBACK:
|
||||
if (logger.isLoggable(Level.FINE)){
|
||||
logger.fine("Jta Txn ["+transaction.getId()+"] rollback");
|
||||
if (logger.isDebugEnabled()){
|
||||
logger.debug("Jta Txn ["+transaction.getId()+"] rollback");
|
||||
}
|
||||
transactionManager.notifyOfRollback(transaction, null);
|
||||
// Remove this transaction object as it is completed
|
||||
@@ -221,7 +220,7 @@ public class JtaTransactionManager implements ExternalTransactionManager {
|
||||
break;
|
||||
|
||||
default:
|
||||
logger.fine("Jta Txn ["+transaction.getId()+"] status:"+status);
|
||||
logger.debug("Jta Txn ["+transaction.getId()+"] status:"+status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.avaje.ebeaninternal.server.transaction;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.avaje.ebeaninternal.api.SpiTransaction;
|
||||
import com.avaje.ebeaninternal.api.TransactionEvent;
|
||||
@@ -13,6 +11,8 @@ import com.avaje.ebeaninternal.api.TransactionEventTable.TableIUD;
|
||||
import com.avaje.ebeaninternal.server.cluster.ClusterManager;
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Performs post commit processing using a background thread.
|
||||
@@ -22,7 +22,7 @@ import com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager;
|
||||
*/
|
||||
public final class PostCommitProcessing {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(PostCommitProcessing.class.getName());
|
||||
private static final Logger logger = LoggerFactory.getLogger(PostCommitProcessing.class);
|
||||
|
||||
private final ClusterManager clusterManager;
|
||||
|
||||
@@ -87,7 +87,7 @@ public final class PostCommitProcessing {
|
||||
public void notifyCluster() {
|
||||
if (remoteTransactionEvent != null && !remoteTransactionEvent.isEmpty()) {
|
||||
// send the interesting events to the cluster
|
||||
if (manager.getClusterDebugLevel() > 0 || logger.isLoggable(Level.FINE)) {
|
||||
if (manager.getClusterDebugLevel() > 0 || logger.isDebugEnabled()) {
|
||||
logger.info("Cluster Send: " + remoteTransactionEvent.toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@ import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.sql.DataSource;
|
||||
@@ -23,6 +21,8 @@ import com.avaje.ebeaninternal.api.TransactionEventTable.TableIUD;
|
||||
import com.avaje.ebeaninternal.server.cluster.ClusterManager;
|
||||
import com.avaje.ebeaninternal.server.core.BootupClasses;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Manages transactions.
|
||||
@@ -33,7 +33,7 @@ import com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager;
|
||||
*/
|
||||
public class TransactionManager {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(TransactionManager.class.getName());
|
||||
private static final Logger logger = LoggerFactory.getLogger(TransactionManager.class);
|
||||
|
||||
/**
|
||||
* The behaviour desired when ending a query only transaction.
|
||||
@@ -217,7 +217,7 @@ public class TransactionManager {
|
||||
c.close();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
logger.log(Level.SEVERE, "closing connection", ex);
|
||||
logger.error("closing connection", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -326,7 +326,7 @@ public class TransactionManager {
|
||||
c.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
logger.log(Level.SEVERE,"Error closing failed connection", e);
|
||||
logger.error("Error closing failed connection", e);
|
||||
}
|
||||
throw new PersistenceException(ex);
|
||||
}
|
||||
@@ -359,7 +359,7 @@ public class TransactionManager {
|
||||
c.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
logger.log(Level.SEVERE,"Error closing failed connection", e);
|
||||
logger.error("Error closing failed connection", e);
|
||||
}
|
||||
throw ex;
|
||||
|
||||
@@ -396,7 +396,7 @@ public class TransactionManager {
|
||||
log(transaction.getLogBuffer());
|
||||
} catch (Exception ex) {
|
||||
String m = "Potentially Transaction Log incomplete due to error:";
|
||||
logger.log(Level.SEVERE, m, ex);
|
||||
logger.error(m, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ public class TransactionManager {
|
||||
|
||||
} catch (Exception ex) {
|
||||
String m = "Potentially Transaction Log incomplete due to error:";
|
||||
logger.log(Level.SEVERE, m, ex);
|
||||
logger.error(m, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,7 +482,7 @@ public class TransactionManager {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
String m = "NotifyOfCommit failed. Cache/Lucene potentially not notified.";
|
||||
logger.log(Level.SEVERE, m, ex);
|
||||
logger.error(m, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,7 +515,7 @@ public class TransactionManager {
|
||||
*/
|
||||
public void remoteTransactionEvent(RemoteTransactionEvent remoteEvent) {
|
||||
|
||||
if (clusterDebugLevel > 0 || logger.isLoggable(Level.FINE)){
|
||||
if (clusterDebugLevel > 0 || logger.isDebugEnabled()){
|
||||
logger.info("Cluster Received: "+remoteEvent.toString());
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -7,14 +7,14 @@ import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import com.avaje.ebeaninternal.server.transaction.TransactionLogBuffer;
|
||||
import com.avaje.ebeaninternal.server.transaction.TransactionLogBuffer.LogEntry;
|
||||
import com.avaje.ebeaninternal.server.transaction.TransactionLogWriter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Default transaction logger implementation.
|
||||
@@ -30,7 +30,7 @@ import com.avaje.ebeaninternal.server.transaction.TransactionLogWriter;
|
||||
*/
|
||||
public class FileTransactionLogger implements Runnable, TransactionLogWriter {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(FileTransactionLogger.class.getName());
|
||||
private static final Logger logger = LoggerFactory.getLogger(FileTransactionLogger.class);
|
||||
|
||||
/**
|
||||
* Used to print stack trace.
|
||||
@@ -158,17 +158,17 @@ public class FileTransactionLogger implements Runnable, TransactionLogWriter {
|
||||
try {
|
||||
// wait max 20 seconds
|
||||
logWriterThread.wait(20000);
|
||||
logger.fine("Shutdown LogBufferWriter " + threadName + " shutdownComplete:" + shutdownComplete);
|
||||
logger.debug("Shutdown LogBufferWriter " + threadName + " shutdownComplete:" + shutdownComplete);
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
logger.fine("InterruptedException:" + e);
|
||||
logger.debug("InterruptedException:" + e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!shutdownComplete) {
|
||||
String m = "WARNING: Shutdown of LogBufferWriter " + threadName + " not completed.";
|
||||
System.err.println(m);
|
||||
logger.warning(m);
|
||||
logger.warn(m);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public class FileTransactionLogger implements Runnable, TransactionLogWriter {
|
||||
try {
|
||||
Thread.sleep(20);
|
||||
} catch (InterruptedException e) {
|
||||
logger.log(Level.INFO, "Interrupted TxnLogBufferWriter", e);
|
||||
logger.info("Interrupted TxnLogBufferWriter", e);
|
||||
}
|
||||
}
|
||||
synchronized (queueMonitor) {
|
||||
@@ -345,7 +345,7 @@ public class FileTransactionLogger implements Runnable, TransactionLogWriter {
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.log(Level.SEVERE, "Error switch log file", e);
|
||||
logger.error("Error switch log file", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ public class FileTransactionLogger implements Runnable, TransactionLogWriter {
|
||||
} else {
|
||||
if (!f.mkdirs()) {
|
||||
String msg = "Failed to create transaction logs directory " + dir;
|
||||
logger.log(Level.SEVERE, msg);
|
||||
logger.error(msg);
|
||||
}
|
||||
}
|
||||
return dir;
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package com.avaje.ebeaninternal.server.transaction.log;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.avaje.ebean.config.GlobalProperties;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebeaninternal.server.transaction.TransactionLogBuffer;
|
||||
import com.avaje.ebeaninternal.server.transaction.TransactionLogWriter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Wraps a FileTransactionLogger to provide delayed initialisation.
|
||||
@@ -21,7 +21,7 @@ import com.avaje.ebeaninternal.server.transaction.TransactionLogWriter;
|
||||
*/
|
||||
public class FileTransactionLoggerWrapper implements TransactionLogWriter {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(FileTransactionLoggerWrapper.class.getName());
|
||||
private static final Logger logger = LoggerFactory.getLogger(FileTransactionLoggerWrapper.class);
|
||||
|
||||
private final String serverName;
|
||||
private final String dir;
|
||||
|
||||
+3
-5
@@ -1,13 +1,12 @@
|
||||
package com.avaje.ebeaninternal.server.transaction.log;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebeaninternal.server.transaction.TransactionLogBuffer;
|
||||
import com.avaje.ebeaninternal.server.transaction.TransactionLogBuffer.LogEntry;
|
||||
import com.avaje.ebeaninternal.server.transaction.TransactionLogWriter;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* A transactionLogger that uses a java.util.logging.Logger.
|
||||
@@ -17,9 +16,8 @@ import com.avaje.ebeaninternal.server.transaction.TransactionLogWriter;
|
||||
* @author rbygrave
|
||||
*/
|
||||
public class JuliTransactionLogger implements TransactionLogWriter {
|
||||
private static final Logger logger = Logger.getLogger(JuliTransactionLogger.class.getName());
|
||||
|
||||
private static Logger logger = Logger.getLogger(JuliTransactionLogger.class.getName());
|
||||
|
||||
public void log(TransactionLogBuffer logBuffer) {
|
||||
|
||||
String txnId = logBuffer.getTransactionId();
|
||||
@@ -41,7 +39,7 @@ public class JuliTransactionLogger implements TransactionLogWriter {
|
||||
message = "Trans["+txnId+"] "+message;
|
||||
}
|
||||
|
||||
logger.log(Level.INFO, message);
|
||||
logger.info(message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.avaje.ebeaninternal.server.transaction.log;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
@@ -21,7 +22,7 @@ import javax.persistence.PersistenceException;
|
||||
*/
|
||||
public class SimpleLogger {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(SimpleLogger.class.getName());
|
||||
private static final Logger logger = LoggerFactory.getLogger(SimpleLogger.class);
|
||||
|
||||
/**
|
||||
* Used to print stack trace.
|
||||
@@ -294,7 +295,7 @@ public class SimpleLogger {
|
||||
} else {
|
||||
if (!f.mkdirs()) {
|
||||
String msg = "Failed to create transaction logs directory "+dir;
|
||||
logger.log(Level.SEVERE, msg);
|
||||
logger.error(msg);
|
||||
}
|
||||
}
|
||||
return dir;
|
||||
|
||||
Reference in new issue
Block a user