http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/db/DBAppender.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/db/DBAppender.java b/src/main/java/org/apache/log4j/db/DBAppender.java index 4f116c5..4a566e8 100644 --- a/src/main/java/org/apache/log4j/db/DBAppender.java +++ b/src/main/java/org/apache/log4j/db/DBAppender.java @@ -27,12 +27,9 @@ import org.apache.log4j.xml.DOMConfigurator; import org.apache.log4j.xml.UnrecognizedElementHandler; import org.w3c.dom.Element; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; import java.util.Set; @@ -48,7 +45,7 @@ import java.util.Set; * for your particular type of database system is missing, it should be quite * easy to write one, taking example on the already existing scripts. If you * send them to us, we will gladly include missing scripts in future releases. - * + * <p> * <p> * If the JDBC driver you are using supports the * {@link java.sql.Statement#getGeneratedKeys}method introduced in JDBC 3.0 @@ -59,7 +56,7 @@ import java.util.Set; * not support the {@link java.sql.Statement#getGeneratedKeys getGeneratedKeys} * method. * </p> - * + * <p> * <table border="1" cellpadding="4"> * <caption>supported dialects</caption> * <tr> @@ -93,11 +90,11 @@ import java.util.Set; * <td>not present, and not needed or used</td> * <tr> * <tr> - * <td>HSQL</td> - * <td align="center">NO</td> - * <td>present and used</td> + * <td>HSQL</td> + * <td align="center">NO</td> + * <td>present and used</td> * <tr> - * + * <p> * </table> * <p> * <b>Performance: </b> Experiments show that writing a single event into the @@ -105,9 +102,9 @@ import java.util.Set; * connections are used, this figure drops to under 10 milliseconds. Note that * most JDBC drivers already ship with connection pooling support. * </p> - * - * - * + * <p> + * <p> + * <p> * <p> * <b>Configuration </b> DBAppender can be configured programmatically, or using * {@link org.apache.log4j.xml.DOMConfigurator JoranConfigurator}. Example @@ -117,257 +114,257 @@ import java.util.Set; * @author Ray DeCampo */ public class DBAppender extends AppenderSkeleton implements UnrecognizedElementHandler { - static final String insertPropertiesSQL = - "INSERT INTO logging_event_property (event_id, mapped_key, mapped_value) VALUES (?, ?, ?)"; - static final String insertExceptionSQL = - "INSERT INTO logging_event_exception (event_id, i, trace_line) VALUES (?, ?, ?)"; - static final String insertSQL; - - - static { - String sql = "INSERT INTO logging_event (" + - "sequence_number, " + - "timestamp, " + - "rendered_message, " + - "logger_name, " + - "level_string, " + - "ndc, " + - "thread_name, " + - "reference_flag, " + - "caller_filename, " + - "caller_class, " + - "caller_method, " + - "caller_line) " + - " VALUES (?, ?, ? ,?, ?, ?, ?, ?, ?, ?, ?, ?)"; - insertSQL = sql; - } - - ConnectionSource connectionSource; - boolean cnxSupportsGetGeneratedKeys = false; - boolean cnxSupportsBatchUpdates = false; - SQLDialect sqlDialect; - boolean locationInfo = false; - - - public DBAppender() { - super(false); - } - - public void activateOptions() { - LogLog.debug("DBAppender.activateOptions called"); - - if (connectionSource == null) { - throw new IllegalStateException( - "DBAppender cannot function without a connection source"); - } - - sqlDialect = Util.getDialectFromCode(connectionSource.getSQLDialectCode()); - cnxSupportsGetGeneratedKeys = connectionSource.supportsGetGeneratedKeys(); - cnxSupportsBatchUpdates = connectionSource.supportsBatchUpdates(); - if (!cnxSupportsGetGeneratedKeys && (sqlDialect == null)) { - throw new IllegalStateException( - "DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect"); - } - - // all nice and dandy on the eastern front - super.activateOptions(); - } - - /** - * @return Returns the connectionSource. - */ - public ConnectionSource getConnectionSource() { - return connectionSource; - } - - /** - * @param connectionSource - * The connectionSource to set. - */ - public void setConnectionSource(ConnectionSource connectionSource) { - LogLog.debug("setConnectionSource called for DBAppender"); - this.connectionSource = connectionSource; - } - - protected void append(LoggingEvent event) { - Connection connection = null; - try { - connection = connectionSource.getConnection(); - connection.setAutoCommit(false); - - PreparedStatement insertStatement; - if (cnxSupportsGetGeneratedKeys) { - insertStatement = connection.prepareStatement(insertSQL, Statement.RETURN_GENERATED_KEYS); - } else { - insertStatement = connection.prepareStatement(insertSQL); - } - -/* insertStatement.setLong(1, event.getSequenceNumber());*/ - insertStatement.setLong(1, 0); - - insertStatement.setLong(2, event.getTimeStamp()); - insertStatement.setString(3, event.getRenderedMessage()); - insertStatement.setString(4, event.getLoggerName()); - insertStatement.setString(5, event.getLevel().toString()); - insertStatement.setString(6, event.getNDC()); - insertStatement.setString(7, event.getThreadName()); - insertStatement.setShort(8, DBHelper.computeReferenceMask(event)); - - LocationInfo li; - - if (event.locationInformationExists() || locationInfo) { - li = event.getLocationInformation(); - } else { - li = LocationInfo.NA_LOCATION_INFO; - } - - insertStatement.setString(9, li.getFileName()); - insertStatement.setString(10, li.getClassName()); - insertStatement.setString(11, li.getMethodName()); - insertStatement.setString(12, li.getLineNumber()); - - int updateCount = insertStatement.executeUpdate(); - if (updateCount != 1) { - LogLog.warn("Failed to insert loggingEvent"); - } - - ResultSet rs = null; - Statement idStatement = null; - boolean gotGeneratedKeys = false; - if (cnxSupportsGetGeneratedKeys) { - rs = insertStatement.getGeneratedKeys(); - gotGeneratedKeys = true; - } - - if (!gotGeneratedKeys) { - insertStatement.close(); - insertStatement = null; - - idStatement = connection.createStatement(); - idStatement.setMaxRows(1); - rs = idStatement.executeQuery(sqlDialect.getSelectInsertId()); - } - - // A ResultSet cursor is initially positioned before the first row; the - // first call to the method next makes the first row the current row - rs.next(); - int eventId = rs.getInt(1); - - rs.close(); - - // we no longer need the insertStatement - if(insertStatement != null) { - insertStatement.close(); - } - - if(idStatement != null) { - idStatement.close(); - } - - Set propertiesKeys = event.getPropertyKeySet(); - - if (propertiesKeys.size() > 0) { - PreparedStatement insertPropertiesStatement = - connection.prepareStatement(insertPropertiesSQL); - - for (Object propertiesKey : propertiesKeys) { - String key = (String) propertiesKey; - String value = event.getProperty(key); - - //LogLog.info("id " + eventId + ", key " + key + ", value " + value); - insertPropertiesStatement.setInt(1, eventId); - insertPropertiesStatement.setString(2, key); - insertPropertiesStatement.setString(3, value); - - if (cnxSupportsBatchUpdates) { - insertPropertiesStatement.addBatch(); - } else { - insertPropertiesStatement.execute(); - } - } - - if (cnxSupportsBatchUpdates) { - insertPropertiesStatement.executeBatch(); - } - - insertPropertiesStatement.close(); - } - - String[] strRep = event.getThrowableStrRep(); - - if (strRep != null) { - LogLog.debug("Logging an exception"); - - PreparedStatement insertExceptionStatement = - connection.prepareStatement(insertExceptionSQL); - - for (short i = 0; i < strRep.length; i++) { - insertExceptionStatement.setInt(1, eventId); - insertExceptionStatement.setShort(2, i); - insertExceptionStatement.setString(3, strRep[i]); - if (cnxSupportsBatchUpdates) { - insertExceptionStatement.addBatch(); - } else { - insertExceptionStatement.execute(); - } - } - if (cnxSupportsBatchUpdates) { - insertExceptionStatement.executeBatch(); - } - insertExceptionStatement.close(); - } - - connection.commit(); - } catch (Throwable sqle) { - LogLog.error("problem appending event", sqle); - } finally { - DBHelper.closeConnection(connection); - } - } - - public void close() { - closed = true; - } - - /** - * Returns value of the <b>LocationInfo </b> property which determines whether - * caller's location info is written to the database. - */ - public boolean getLocationInfo() { - return locationInfo; - } - - /** - * If true, the information written to the database will include caller's - * location information. Due to performance concerns, by default no location - * information is written to the database. - */ - public void setLocationInfo(boolean locationInfo) { - this.locationInfo = locationInfo; - } + static final String insertPropertiesSQL = + "INSERT INTO logging_event_property (event_id, mapped_key, mapped_value) VALUES (?, ?, ?)"; + static final String insertExceptionSQL = + "INSERT INTO logging_event_exception (event_id, i, trace_line) VALUES (?, ?, ?)"; + static final String insertSQL; + + + static { + String sql = "INSERT INTO logging_event (" + + "sequence_number, " + + "timestamp, " + + "rendered_message, " + + "logger_name, " + + "level_string, " + + "ndc, " + + "thread_name, " + + "reference_flag, " + + "caller_filename, " + + "caller_class, " + + "caller_method, " + + "caller_line) " + + " VALUES (?, ?, ? ,?, ?, ?, ?, ?, ?, ?, ?, ?)"; + insertSQL = sql; + } + + ConnectionSource connectionSource; + boolean cnxSupportsGetGeneratedKeys = false; + boolean cnxSupportsBatchUpdates = false; + SQLDialect sqlDialect; + boolean locationInfo = false; + + + public DBAppender() { + super(false); + } + + public void activateOptions() { + LogLog.debug("DBAppender.activateOptions called"); + + if (connectionSource == null) { + throw new IllegalStateException( + "DBAppender cannot function without a connection source"); + } + + sqlDialect = Util.getDialectFromCode(connectionSource.getSQLDialectCode()); + cnxSupportsGetGeneratedKeys = connectionSource.supportsGetGeneratedKeys(); + cnxSupportsBatchUpdates = connectionSource.supportsBatchUpdates(); + if (!cnxSupportsGetGeneratedKeys && (sqlDialect == null)) { + throw new IllegalStateException( + "DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect"); + } + + // all nice and dandy on the eastern front + super.activateOptions(); + } + + /** + * @return Returns the connectionSource. + */ + public ConnectionSource getConnectionSource() { + return connectionSource; + } + + /** + * @param connectionSource The connectionSource to set. + */ + public void setConnectionSource(ConnectionSource connectionSource) { + LogLog.debug("setConnectionSource called for DBAppender"); + this.connectionSource = connectionSource; + } + + protected void append(LoggingEvent event) { + Connection connection = null; + try { + connection = connectionSource.getConnection(); + connection.setAutoCommit(false); + + PreparedStatement insertStatement; + if (cnxSupportsGetGeneratedKeys) { + insertStatement = connection.prepareStatement(insertSQL, Statement.RETURN_GENERATED_KEYS); + } else { + insertStatement = connection.prepareStatement(insertSQL); + } + + /* insertStatement.setLong(1, event.getSequenceNumber());*/ + insertStatement.setLong(1, 0); + + insertStatement.setLong(2, event.getTimeStamp()); + insertStatement.setString(3, event.getRenderedMessage()); + insertStatement.setString(4, event.getLoggerName()); + insertStatement.setString(5, event.getLevel().toString()); + insertStatement.setString(6, event.getNDC()); + insertStatement.setString(7, event.getThreadName()); + insertStatement.setShort(8, DBHelper.computeReferenceMask(event)); + + LocationInfo li; + + if (event.locationInformationExists() || locationInfo) { + li = event.getLocationInformation(); + } else { + li = LocationInfo.NA_LOCATION_INFO; + } + + insertStatement.setString(9, li.getFileName()); + insertStatement.setString(10, li.getClassName()); + insertStatement.setString(11, li.getMethodName()); + insertStatement.setString(12, li.getLineNumber()); + + int updateCount = insertStatement.executeUpdate(); + if (updateCount != 1) { + LogLog.warn("Failed to insert loggingEvent"); + } + + ResultSet rs = null; + Statement idStatement = null; + boolean gotGeneratedKeys = false; + if (cnxSupportsGetGeneratedKeys) { + rs = insertStatement.getGeneratedKeys(); + gotGeneratedKeys = true; + } + + if (!gotGeneratedKeys) { + insertStatement.close(); + insertStatement = null; + + idStatement = connection.createStatement(); + idStatement.setMaxRows(1); + rs = idStatement.executeQuery(sqlDialect.getSelectInsertId()); + } + + // A ResultSet cursor is initially positioned before the first row; the + // first call to the method next makes the first row the current row + rs.next(); + int eventId = rs.getInt(1); + + rs.close(); + + // we no longer need the insertStatement + if (insertStatement != null) { + insertStatement.close(); + } + + if (idStatement != null) { + idStatement.close(); + } + + Set propertiesKeys = event.getPropertyKeySet(); + + if (propertiesKeys.size() > 0) { + PreparedStatement insertPropertiesStatement = + connection.prepareStatement(insertPropertiesSQL); + + for (Object propertiesKey : propertiesKeys) { + String key = (String) propertiesKey; + String value = event.getProperty(key); + + //LogLog.info("id " + eventId + ", key " + key + ", value " + value); + insertPropertiesStatement.setInt(1, eventId); + insertPropertiesStatement.setString(2, key); + insertPropertiesStatement.setString(3, value); + + if (cnxSupportsBatchUpdates) { + insertPropertiesStatement.addBatch(); + } else { + insertPropertiesStatement.execute(); + } + } + + if (cnxSupportsBatchUpdates) { + insertPropertiesStatement.executeBatch(); + } + + insertPropertiesStatement.close(); + } + + String[] strRep = event.getThrowableStrRep(); + + if (strRep != null) { + LogLog.debug("Logging an exception"); + + PreparedStatement insertExceptionStatement = + connection.prepareStatement(insertExceptionSQL); + + for (short i = 0; i < strRep.length; i++) { + insertExceptionStatement.setInt(1, eventId); + insertExceptionStatement.setShort(2, i); + insertExceptionStatement.setString(3, strRep[i]); + if (cnxSupportsBatchUpdates) { + insertExceptionStatement.addBatch(); + } else { + insertExceptionStatement.execute(); + } + } + if (cnxSupportsBatchUpdates) { + insertExceptionStatement.executeBatch(); + } + insertExceptionStatement.close(); + } + + connection.commit(); + } catch (Throwable sqle) { + LogLog.error("problem appending event", sqle); + } finally { + DBHelper.closeConnection(connection); + } + } + + public void close() { + closed = true; + } + + /** + * Returns value of the <b>LocationInfo </b> property which determines whether + * caller's location info is written to the database. + */ + public boolean getLocationInfo() { + return locationInfo; + } + + /** + * If true, the information written to the database will include caller's + * location information. Due to performance concerns, by default no location + * information is written to the database. + */ + public void setLocationInfo(boolean locationInfo) { + this.locationInfo = locationInfo; + } /** * Gets whether appender requires a layout. + * * @return false */ - public boolean requiresLayout() { - return false; - } + public boolean requiresLayout() { + return false; + } /** * {@inheritDoc} */ - public boolean parseUnrecognizedElement(Element element, Properties props) throws Exception { + public boolean parseUnrecognizedElement(Element element, Properties props) throws Exception { if ("connectionSource".equals(element.getNodeName())) { Object instance = - DOMConfigurator.parseElement(element, props, ConnectionSource.class); + DOMConfigurator.parseElement(element, props, ConnectionSource.class); if (instance instanceof ConnectionSource) { - ConnectionSource source = (ConnectionSource) instance; - source.activateOptions(); - setConnectionSource(source); + ConnectionSource source = (ConnectionSource) instance; + source.activateOptions(); + setConnectionSource(source); } return true; } return false; - } + } }
http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/db/DBHelper.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/db/DBHelper.java b/src/main/java/org/apache/log4j/db/DBHelper.java index b400506..7ffc375 100644 --- a/src/main/java/org/apache/log4j/db/DBHelper.java +++ b/src/main/java/org/apache/log4j/db/DBHelper.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,52 +17,51 @@ package org.apache.log4j.db; +import org.apache.log4j.spi.LoggingEvent; + import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; import java.util.Set; -import org.apache.log4j.spi.LoggingEvent; - /** * @author Ceki Gülcü - * */ public class DBHelper { - - public final static short PROPERTIES_EXIST = 0x01; - public final static short EXCEPTION_EXISTS = 0x02; - - public static short computeReferenceMask(LoggingEvent event) { - short mask = 0; - Set propertiesKeys = event.getPropertyKeySet(); - if(propertiesKeys.size() > 0) { - mask = PROPERTIES_EXIST; - } - String[] strRep = event.getThrowableStrRep(); - if(strRep != null) { - mask |= EXCEPTION_EXISTS; + + public final static short PROPERTIES_EXIST = 0x01; + public final static short EXCEPTION_EXISTS = 0x02; + + public static short computeReferenceMask(LoggingEvent event) { + short mask = 0; + Set propertiesKeys = event.getPropertyKeySet(); + if (propertiesKeys.size() > 0) { + mask = PROPERTIES_EXIST; + } + String[] strRep = event.getThrowableStrRep(); + if (strRep != null) { + mask |= EXCEPTION_EXISTS; + } + return mask; } - return mask; - } - - static public void closeConnection(Connection connection) { - if(connection != null) { - try { - connection.close(); - } catch(SQLException sqle) { - // static utility classes should not log without an explicit repository - // reference - } + + static public void closeConnection(Connection connection) { + if (connection != null) { + try { + connection.close(); + } catch (SQLException sqle) { + // static utility classes should not log without an explicit repository + // reference + } + } } - } - - public static void closeStatement(Statement statement) { - if(statement != null) { - try { - statement.close(); - } catch(SQLException sqle) { - } + + public static void closeStatement(Statement statement) { + if (statement != null) { + try { + statement.close(); + } catch (SQLException sqle) { + } + } } - } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/db/DBReceiver.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/db/DBReceiver.java b/src/main/java/org/apache/log4j/db/DBReceiver.java index dbd1ef5..bcb66e1 100644 --- a/src/main/java/org/apache/log4j/db/DBReceiver.java +++ b/src/main/java/org/apache/log4j/db/DBReceiver.java @@ -28,105 +28,104 @@ import org.w3c.dom.Element; import java.util.Properties; /** - * * @author Scott Deboy <sde...@apache.org> * @author Ceki Gülcü - * */ public class DBReceiver extends Receiver implements Pauseable, UnrecognizedElementHandler { - /** - * By default we refresh data every 1000 milliseconds. - * @see #setRefreshMillis - */ - static int DEFAULT_REFRESH_MILLIS = 1000; - ConnectionSource connectionSource; - int refreshMillis = DEFAULT_REFRESH_MILLIS; - DBReceiverJob receiverJob; - boolean paused = false; - - public void activateOptions() { - - if(connectionSource == null) { - throw new IllegalStateException( - "DBAppender cannot function without a connection source"); - } - - receiverJob = new DBReceiverJob(this); - receiverJob.setLoggerRepository(repository); - - if(this.repository == null) { - throw new IllegalStateException( - "DBAppender cannot function without a reference to its owning repository"); - } + /** + * By default we refresh data every 1000 milliseconds. + * + * @see #setRefreshMillis + */ + static int DEFAULT_REFRESH_MILLIS = 1000; + ConnectionSource connectionSource; + int refreshMillis = DEFAULT_REFRESH_MILLIS; + DBReceiverJob receiverJob; + boolean paused = false; + + public void activateOptions() { + + if (connectionSource == null) { + throw new IllegalStateException( + "DBAppender cannot function without a connection source"); + } + + receiverJob = new DBReceiverJob(this); + receiverJob.setLoggerRepository(repository); + + if (this.repository == null) { + throw new IllegalStateException( + "DBAppender cannot function without a reference to its owning repository"); + } + + if (repository instanceof LoggerRepositoryEx) { + Scheduler scheduler = ((LoggerRepositoryEx) repository).getScheduler(); + + scheduler.schedule( + receiverJob, System.currentTimeMillis() + 500, refreshMillis); + } - if (repository instanceof LoggerRepositoryEx) { - Scheduler scheduler = ((LoggerRepositoryEx) repository).getScheduler(); - - scheduler.schedule( - receiverJob, System.currentTimeMillis() + 500, refreshMillis); } - - } - public void setRefreshMillis(int refreshMillis) { - this.refreshMillis = refreshMillis; - } + public void setRefreshMillis(int refreshMillis) { + this.refreshMillis = refreshMillis; + } - public int getRefreshMillis() { - return refreshMillis; - } + public int getRefreshMillis() { + return refreshMillis; + } - /** - * @return Returns the connectionSource. - */ - public ConnectionSource getConnectionSource() { - return connectionSource; - } + /** + * @return Returns the connectionSource. + */ + public ConnectionSource getConnectionSource() { + return connectionSource; + } - /** - * @param connectionSource The connectionSource to set. - */ - public void setConnectionSource(ConnectionSource connectionSource) { - this.connectionSource = connectionSource; - } + /** + * @param connectionSource The connectionSource to set. + */ + public void setConnectionSource(ConnectionSource connectionSource) { + this.connectionSource = connectionSource; + } - /* (non-Javadoc) - * @see org.apache.log4j.plugins.Plugin#shutdown() - */ - public void shutdown() { - getLogger().info("removing receiverJob from the Scheduler."); + /* (non-Javadoc) + * @see org.apache.log4j.plugins.Plugin#shutdown() + */ + public void shutdown() { + getLogger().info("removing receiverJob from the Scheduler."); - if(this.repository instanceof LoggerRepositoryEx) { - Scheduler scheduler = ((LoggerRepositoryEx) repository).getScheduler(); - scheduler.delete(receiverJob); + if (this.repository instanceof LoggerRepositoryEx) { + Scheduler scheduler = ((LoggerRepositoryEx) repository).getScheduler(); + scheduler.delete(receiverJob); + } } - } - /* (non-Javadoc) - * @see org.apache.log4j.plugins.Pauseable#setPaused(boolean) - */ - public void setPaused(boolean paused) { - this.paused = paused; - } + /* (non-Javadoc) + * @see org.apache.log4j.plugins.Pauseable#setPaused(boolean) + */ + public void setPaused(boolean paused) { + this.paused = paused; + } - /* (non-Javadoc) - * @see org.apache.log4j.plugins.Pauseable#isPaused() - */ - public boolean isPaused() { - return paused; - } + /* (non-Javadoc) + * @see org.apache.log4j.plugins.Pauseable#isPaused() + */ + public boolean isPaused() { + return paused; + } /** * {@inheritDoc} */ - public boolean parseUnrecognizedElement(Element element, Properties props) throws Exception { + public boolean parseUnrecognizedElement(Element element, Properties props) throws Exception { if ("connectionSource".equals(element.getNodeName())) { Object instance = - DOMConfigurator.parseElement(element, props, ConnectionSource.class); + DOMConfigurator.parseElement(element, props, ConnectionSource.class); if (instance instanceof ConnectionSource) { ConnectionSource source = (ConnectionSource) instance; source.activateOptions(); @@ -135,6 +134,6 @@ public class DBReceiver extends Receiver implements Pauseable, UnrecognizedEleme return true; } return false; - } + } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/db/DBReceiverJob.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/db/DBReceiverJob.java b/src/main/java/org/apache/log4j/db/DBReceiverJob.java index 80af7cc..30091cd 100644 --- a/src/main/java/org/apache/log4j/db/DBReceiverJob.java +++ b/src/main/java/org/apache/log4j/db/DBReceiverJob.java @@ -35,192 +35,190 @@ import java.util.Vector; /** * Actual retrieval of data is made by the instance of DBReceiverJob associated * with DBReceiver. - * + * * @author Ceki Gülcü */ class DBReceiverJob extends ComponentBase implements Job { - String sqlException = "SELECT trace_line FROM logging_event_exception where event_id=? ORDER by i ASC"; - String sqlProperties = "SELECT mapped_key, mapped_value FROM logging_event_property WHERE event_id=?"; - String sqlSelect = - "SELECT " + - "sequence_number, timestamp, rendered_message, logger_name, " + - "level_string, ndc, thread_name, reference_flag, " + - "caller_filename, caller_class, caller_method, caller_line, " + - "event_id " + - "FROM logging_event " + - "WHERE event_id > ? ORDER BY event_id ASC"; - - - long lastId = Short.MIN_VALUE; - - DBReceiver parentDBReceiver; - - DBReceiverJob(DBReceiver parent) { - parentDBReceiver = parent; - } - - public void execute() { - getLogger().debug("DBReceiverJob.execute() called"); - - Connection connection = null; - - try { - connection = parentDBReceiver.connectionSource.getConnection(); - PreparedStatement statement = connection.prepareStatement(sqlSelect); - statement.setLong(1, lastId); - ResultSet rs = statement.executeQuery(); - //rs.beforeFirst(); - - while (rs.next()) { - Logger logger; - long timeStamp; - String level; - String threadName; - Object message; - String ndc; - String className; - String methodName; - String fileName; - String lineNumber; - Hashtable properties = new Hashtable(); - - - //event.setSequenceNumber(rs.getLong(1)); - timeStamp = rs.getLong(2); - message = rs.getString(3); - logger = Logger.getLogger(rs.getString(4)); - level = rs.getString(5); - Level levelImpl = Level.toLevel(level.trim()); - - ndc = rs.getString(6); - threadName = rs.getString(7); - - short mask = rs.getShort(8); - - fileName = rs.getString(9); - className = rs.getString(10); - methodName = rs.getString(11); - lineNumber = rs.getString(12).trim(); - - LocationInfo locationInfo; - if (fileName.equals(LocationInfo.NA)) { - locationInfo = LocationInfo.NA_LOCATION_INFO; - } else { - locationInfo = new LocationInfo(fileName, className, - methodName, lineNumber); - } - - long id = rs.getLong(13); - //LogLog.info("Received event with id=" + id); - lastId = id; + String sqlException = "SELECT trace_line FROM logging_event_exception where event_id=? ORDER by i ASC"; + String sqlProperties = "SELECT mapped_key, mapped_value FROM logging_event_property WHERE event_id=?"; + String sqlSelect = + "SELECT " + + "sequence_number, timestamp, rendered_message, logger_name, " + + "level_string, ndc, thread_name, reference_flag, " + + "caller_filename, caller_class, caller_method, caller_line, " + + "event_id " + + "FROM logging_event " + + "WHERE event_id > ? ORDER BY event_id ASC"; - ThrowableInformation throwableInfo = null; - if ((mask & DBHelper.EXCEPTION_EXISTS) != 0) { - throwableInfo = getException(connection, id); - } - LoggingEvent event = new LoggingEvent(logger.getName(), - logger, timeStamp, levelImpl, message, - threadName, - throwableInfo, - ndc, - locationInfo, - properties); + long lastId = Short.MIN_VALUE; + DBReceiver parentDBReceiver; - // Scott asked for this info to be - event.setProperty("log4jid", Long.toString(id)); + DBReceiverJob(DBReceiver parent) { + parentDBReceiver = parent; + } - if ((mask & DBHelper.PROPERTIES_EXIST) != 0) { - getProperties(connection, id, event); + public void execute() { + getLogger().debug("DBReceiverJob.execute() called"); + + Connection connection = null; + + try { + connection = parentDBReceiver.connectionSource.getConnection(); + PreparedStatement statement = connection.prepareStatement(sqlSelect); + statement.setLong(1, lastId); + ResultSet rs = statement.executeQuery(); + //rs.beforeFirst(); + + while (rs.next()) { + Logger logger; + long timeStamp; + String level; + String threadName; + Object message; + String ndc; + String className; + String methodName; + String fileName; + String lineNumber; + Hashtable properties = new Hashtable(); + + + //event.setSequenceNumber(rs.getLong(1)); + timeStamp = rs.getLong(2); + message = rs.getString(3); + logger = Logger.getLogger(rs.getString(4)); + level = rs.getString(5); + Level levelImpl = Level.toLevel(level.trim()); + + ndc = rs.getString(6); + threadName = rs.getString(7); + + short mask = rs.getShort(8); + + fileName = rs.getString(9); + className = rs.getString(10); + methodName = rs.getString(11); + lineNumber = rs.getString(12).trim(); + + LocationInfo locationInfo; + if (fileName.equals(LocationInfo.NA)) { + locationInfo = LocationInfo.NA_LOCATION_INFO; + } else { + locationInfo = new LocationInfo(fileName, className, + methodName, lineNumber); + } + + long id = rs.getLong(13); + //LogLog.info("Received event with id=" + id); + lastId = id; + + ThrowableInformation throwableInfo = null; + if ((mask & DBHelper.EXCEPTION_EXISTS) != 0) { + throwableInfo = getException(connection, id); + } + + LoggingEvent event = new LoggingEvent(logger.getName(), + logger, timeStamp, levelImpl, message, + threadName, + throwableInfo, + ndc, + locationInfo, + properties); + + + // Scott asked for this info to be + event.setProperty("log4jid", Long.toString(id)); + + if ((mask & DBHelper.PROPERTIES_EXIST) != 0) { + getProperties(connection, id, event); + } + + + if (!parentDBReceiver.isPaused()) { + parentDBReceiver.doPost(event); + } + } // while + statement.close(); + } catch (SQLException sqle) { + getLogger().error("Problem receiving events", sqle); + } finally { + closeConnection(connection); } + } - - - - if (!parentDBReceiver.isPaused()) { - parentDBReceiver.doPost(event); + void closeConnection(Connection connection) { + if (connection != null) { + try { + //LogLog.warn("closing the connection. ", new Exception("x")); + connection.close(); + } catch (SQLException sqle) { + // nothing we can do here + } } - } // while - statement.close(); - } catch (SQLException sqle) { - getLogger().error("Problem receiving events", sqle); - } finally { - closeConnection(connection); } - } - - void closeConnection(Connection connection) { - if (connection != null) { - try { - //LogLog.warn("closing the connection. ", new Exception("x")); - connection.close(); - } catch (SQLException sqle) { - // nothing we can do here - } + + /** + * Retrieve the event properties from the logging_event_property table. + * + * @param connection + * @param id + * @param event + * @throws SQLException + */ + void getProperties(Connection connection, long id, LoggingEvent event) + throws SQLException { + + try (PreparedStatement statement = connection.prepareStatement(sqlProperties)) { + statement.setLong(1, id); + ResultSet rs = statement.executeQuery(); + + while (rs.next()) { + String key = rs.getString(1); + String value = rs.getString(2); + event.setProperty(key, value); + } + } } - } - - /** - * Retrieve the event properties from the logging_event_property table. - * - * @param connection - * @param id - * @param event - * @throws SQLException - */ - void getProperties(Connection connection, long id, LoggingEvent event) - throws SQLException { - - try (PreparedStatement statement = connection.prepareStatement(sqlProperties)) { - statement.setLong(1, id); - ResultSet rs = statement.executeQuery(); - - while (rs.next()) { - String key = rs.getString(1); - String value = rs.getString(2); - event.setProperty(key, value); - } - } - } - - /** - * Retrieve the exception string representation from the - * logging_event_exception table. - * - * @param connection - * @param id - * @throws SQLException - */ - ThrowableInformation getException(Connection connection, long id) - throws SQLException { - - PreparedStatement statement = null; - - try { - statement = connection.prepareStatement(sqlException); - statement.setLong(1, id); - ResultSet rs = statement.executeQuery(); - - Vector<String> v = new Vector<>(); - - while (rs.next()) { - //int i = rs.getShort(1); - v.add(rs.getString(1)); - } - - int len = v.size(); - String[] strRep = new String[len]; - for (int i = 0; i < len; i++) { - strRep[i] = v.get(i); - } - // we've filled strRep, we now attach it to the event - return new ThrowableInformation(strRep); - } finally { - if (statement != null) { - statement.close(); - } + + /** + * Retrieve the exception string representation from the + * logging_event_exception table. + * + * @param connection + * @param id + * @throws SQLException + */ + ThrowableInformation getException(Connection connection, long id) + throws SQLException { + + PreparedStatement statement = null; + + try { + statement = connection.prepareStatement(sqlException); + statement.setLong(1, id); + ResultSet rs = statement.executeQuery(); + + Vector<String> v = new Vector<>(); + + while (rs.next()) { + //int i = rs.getShort(1); + v.add(rs.getString(1)); + } + + int len = v.size(); + String[] strRep = new String[len]; + for (int i = 0; i < len; i++) { + strRep[i] = v.get(i); + } + // we've filled strRep, we now attach it to the event + return new ThrowableInformation(strRep); + } finally { + if (statement != null) { + statement.close(); + } + } } - } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/db/DataSourceConnectionSource.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/db/DataSourceConnectionSource.java b/src/main/java/org/apache/log4j/db/DataSourceConnectionSource.java index 80f6697..04a5527 100644 --- a/src/main/java/org/apache/log4j/db/DataSourceConnectionSource.java +++ b/src/main/java/org/apache/log4j/db/DataSourceConnectionSource.java @@ -29,77 +29,77 @@ import java.util.Properties; /** - * The DataSourceConnectionSource is an implementation of {@link ConnectionSource} - * that obtains the Connection in the recommended JDBC manner based on - * a {@link javax.sql.DataSource DataSource}. - * <p> + * The DataSourceConnectionSource is an implementation of {@link ConnectionSource} + * that obtains the Connection in the recommended JDBC manner based on + * a {@link javax.sql.DataSource DataSource}. + * <p> * - * @author Ray DeCampo - * @author Ceki Gülcü + * @author Ray DeCampo + * @author Ceki Gülcü */ public class DataSourceConnectionSource extends ConnectionSourceSkeleton - implements UnrecognizedElementHandler { + implements UnrecognizedElementHandler { - private DataSource dataSource; + private DataSource dataSource; - - public void activateOptions() { - //LogLog.debug("**********DataSourceConnectionSource.activateOptions called"); - if (dataSource == null) { - getLogger().warn("WARNING: No data source specified"); - } else { - Connection connection = null; - try { - connection = getConnection(); - } catch(SQLException se) { - getLogger().warn("Could not get a connection to discover the dialect to use.", se); - } - if(connection != null) { - discoverConnnectionProperties(); - } - if(!supportsGetGeneratedKeys() && getSQLDialectCode() == ConnectionSource.UNKNOWN_DIALECT) { - getLogger().warn("Connection does not support GetGeneratedKey method and could not discover the dialect."); - } - } - } - /** - * @see org.apache.log4j.db.ConnectionSource#getConnection() - */ - public Connection getConnection() throws SQLException { - if (dataSource == null) { - getLogger().error("WARNING: No data source specified"); - return null; + public void activateOptions() { + //LogLog.debug("**********DataSourceConnectionSource.activateOptions called"); + if (dataSource == null) { + getLogger().warn("WARNING: No data source specified"); + } else { + Connection connection = null; + try { + connection = getConnection(); + } catch (SQLException se) { + getLogger().warn("Could not get a connection to discover the dialect to use.", se); + } + if (connection != null) { + discoverConnnectionProperties(); + } + if (!supportsGetGeneratedKeys() && getSQLDialectCode() == ConnectionSource.UNKNOWN_DIALECT) { + getLogger().warn("Connection does not support GetGeneratedKey method and could not discover the dialect."); + } + } } - if (getUser() == null) { - return dataSource.getConnection(); - } else { - return dataSource.getConnection(getUser(), getPassword()); + /** + * @see org.apache.log4j.db.ConnectionSource#getConnection() + */ + public Connection getConnection() throws SQLException { + if (dataSource == null) { + getLogger().error("WARNING: No data source specified"); + return null; + } + + if (getUser() == null) { + return dataSource.getConnection(); + } else { + return dataSource.getConnection(getUser(), getPassword()); + } } - } - public DataSource getDataSource() { - return dataSource; - } + public DataSource getDataSource() { + return dataSource; + } - public void setDataSource(DataSource dataSource) { - this.dataSource = dataSource; - } + public void setDataSource(DataSource dataSource) { + this.dataSource = dataSource; + } /** * {@inheritDoc} */ - public boolean parseUnrecognizedElement(Element element, Properties props) throws Exception { + public boolean parseUnrecognizedElement(Element element, Properties props) throws Exception { if ("dataSource".equals(element.getNodeName())) { Object instance = - DOMConfigurator.parseElement(element, props, DataSource.class); + DOMConfigurator.parseElement(element, props, DataSource.class); if (instance instanceof DataSource) { - setDataSource((DataSource) instance); + setDataSource((DataSource) instance); } return true; } return false; - } + } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/db/DriverManagerConnectionSource.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/db/DriverManagerConnectionSource.java b/src/main/java/org/apache/log4j/db/DriverManagerConnectionSource.java index 9bfdf65..a309759 100644 --- a/src/main/java/org/apache/log4j/db/DriverManagerConnectionSource.java +++ b/src/main/java/org/apache/log4j/db/DriverManagerConnectionSource.java @@ -23,23 +23,23 @@ import java.sql.SQLException; /** - * The DriverManagerConnectionSource is an implementation of {@link ConnectionSource} - * that obtains the Connection in the traditional JDBC manner based on the - * connection URL. - * <p> - * Note that this class will establish a new Connection for each call to - * {@link #getConnection()}. It is recommended that you either use a JDBC - * driver that natively supported Connection pooling or that you create - * your own implementation of {@link ConnectionSource} that taps into whatever - * pooling mechanism you are already using. (If you have access to a JNDI - * implementation that supports {@link javax.sql.DataSource}s, e.g. within - * a J2EE application server, see {@link JNDIConnectionSource}). See - * <a href="#dbcp">below</a> for a configuration example that uses the - * <a href="http://jakarta.apache.org/commons/dbcp/index.html">commons-dbcp</a> - * package from Apache. - * <p> - * Sample configuration:<br> - * <pre> + * The DriverManagerConnectionSource is an implementation of {@link ConnectionSource} + * that obtains the Connection in the traditional JDBC manner based on the + * connection URL. + * <p> + * Note that this class will establish a new Connection for each call to + * {@link #getConnection()}. It is recommended that you either use a JDBC + * driver that natively supported Connection pooling or that you create + * your own implementation of {@link ConnectionSource} that taps into whatever + * pooling mechanism you are already using. (If you have access to a JNDI + * implementation that supports {@link javax.sql.DataSource}s, e.g. within + * a J2EE application server, see {@link JNDIConnectionSource}). See + * <a href="#dbcp">below</a> for a configuration example that uses the + * <a href="http://jakarta.apache.org/commons/dbcp/index.html">commons-dbcp</a> + * package from Apache. + * <p> + * Sample configuration:<br> + * <pre> * <connectionSource class="org.apache.log4j.jdbc.DriverManagerConnectionSource"> * <param name="driver" value="com.mysql.jdbc.Driver" /> * <param name="url" value="jdbc:mysql://localhost:3306/mydb" /> @@ -47,87 +47,91 @@ import java.sql.SQLException; * <param name="password" value="myPassword" /> * </connectionSource> * </pre> - * <p> - * <a name="dbcp">If</a> you do not have another connection pooling mechanism - * built into your application, you can use the - * <a href="http://jakarta.apache.org/commons/dbcp/index.html">commons-dbcp</a> - * package from Apache:<br> - * <pre> + * <p> + * <a name="dbcp">If</a> you do not have another connection pooling mechanism + * built into your application, you can use the + * <a href="http://jakarta.apache.org/commons/dbcp/index.html">commons-dbcp</a> + * package from Apache:<br> + * <pre> * <connectionSource class="org.apache.log4j.jdbc.DriverManagerConnectionSource"> * <param name="driver" value="org.apache.commons.dbcp.PoolingDriver" /> * <param name="url" value="jdbc:apache:commons:dbcp:/myPoolingDriver" /> * </connectionSource> * </pre> - * Then the configuration information for the commons-dbcp package goes into - * the file myPoolingDriver.jocl and is placed in the classpath. See the - * <a href="http://jakarta.apache.org/commons/dbcp/index.html">commons-dbcp</a> - * documentation for details. + * Then the configuration information for the commons-dbcp package goes into + * the file myPoolingDriver.jocl and is placed in the classpath. See the + * <a href="http://jakarta.apache.org/commons/dbcp/index.html">commons-dbcp</a> + * documentation for details. * - * @author <a href="mailto:rdeca...@twcny.rr.com">Ray DeCampo</a> + * @author <a href="mailto:rdeca...@twcny.rr.com">Ray DeCampo</a> */ public class DriverManagerConnectionSource extends ConnectionSourceSkeleton { - private String driverClass = null; - private String url = null; + private String driverClass = null; + private String url = null; - public void activateOptions() { - try { - if (driverClass != null) { - Class.forName(driverClass); - discoverConnnectionProperties(); - } else { - getLogger().error( - "WARNING: No JDBC driver specified for log4j DriverManagerConnectionSource."); - } - } catch (final ClassNotFoundException cnfe) { - getLogger().error("Could not load JDBC driver class: " + driverClass, cnfe); + public void activateOptions() { + try { + if (driverClass != null) { + Class.forName(driverClass); + discoverConnnectionProperties(); + } else { + getLogger().error( + "WARNING: No JDBC driver specified for log4j DriverManagerConnectionSource."); + } + } catch (final ClassNotFoundException cnfe) { + getLogger().error("Could not load JDBC driver class: " + driverClass, cnfe); + } } - } - /** - * @see org.apache.log4j.db.ConnectionSource#getConnection() - */ - public Connection getConnection() throws SQLException { - if (getUser() == null) { - return DriverManager.getConnection(url); - } else { - return DriverManager.getConnection(url, getUser(), getPassword()); + /** + * @see org.apache.log4j.db.ConnectionSource#getConnection() + */ + public Connection getConnection() throws SQLException { + if (getUser() == null) { + return DriverManager.getConnection(url); + } else { + return DriverManager.getConnection(url, getUser(), getPassword()); + } } - } - /** - * Returns the url. - * @return String - */ - public String getUrl() { - return url; - } + /** + * Returns the url. + * + * @return String + */ + public String getUrl() { + return url; + } - /** - * Sets the url. - * @param url The url to set - */ - public void setUrl(String url) { - this.url = url; - } + /** + * Sets the url. + * + * @param url The url to set + */ + public void setUrl(String url) { + this.url = url; + } - /** - * Returns the name of the driver class. - * @return String - */ - public String getDriverClass() { - return driverClass; - } + /** + * Returns the name of the driver class. + * + * @return String + */ + public String getDriverClass() { + return driverClass; + } - /** - * Sets the driver class. - * @param driverClass The driver class to set - */ - public void setDriverClass(String driverClass) { - this.driverClass = driverClass; - } + /** + * Sets the driver class. + * + * @param driverClass The driver class to set + */ + public void setDriverClass(String driverClass) { + this.driverClass = driverClass; + } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/db/JNDIConnectionSource.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/db/JNDIConnectionSource.java b/src/main/java/org/apache/log4j/db/JNDIConnectionSource.java index 5f972a9..10f386b 100644 --- a/src/main/java/org/apache/log4j/db/JNDIConnectionSource.java +++ b/src/main/java/org/apache/log4j/db/JNDIConnectionSource.java @@ -16,128 +16,129 @@ */ package org.apache.log4j.db; -import java.sql.Connection; -import java.sql.SQLException; - import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.SQLException; // PortableRemoteObject was introduced in JDK 1.3. We won't use it. // import javax.rmi.PortableRemoteObject; -import javax.sql.DataSource; /** - * The {@code JNDIConnectionSource} is an implementation of - * {@link ConnectionSource} that obtains a {@link javax.sql.DataSource} from a - * JNDI provider and uses it to obtain a {@link java.sql.Connection}. It is - * primarily designed to be used inside of J2EE application servers or - * application server clients, assuming the application server supports remote - * access of {@link javax.sql.DataSource}s. In this way one can take - * advantage of connection pooling and whatever other goodies the application - * server provides. - * <p> - * Sample configuration:<br> - * <pre> + * The {@code JNDIConnectionSource} is an implementation of + * {@link ConnectionSource} that obtains a {@link javax.sql.DataSource} from a + * JNDI provider and uses it to obtain a {@link java.sql.Connection}. It is + * primarily designed to be used inside of J2EE application servers or + * application server clients, assuming the application server supports remote + * access of {@link javax.sql.DataSource}s. In this way one can take + * advantage of connection pooling and whatever other goodies the application + * server provides. + * <p> + * Sample configuration:<br> + * <pre> * <connectionSource class="org.apache.log4j.jdbc.JNDIConnectionSource"> * <param name="jndiLocation" value="jdbc/MySQLDS" /> * </connectionSource> * </pre> - * <p> - * Sample configuration (with username and password):<br> - * <pre> + * <p> + * Sample configuration (with username and password):<br> + * <pre> * <connectionSource class="org.apache.log4j.jdbc.JNDIConnectionSource"> * <param name="jndiLocation" value="jdbc/MySQLDS" /> * <param name="username" value="myUser" /> * <param name="password" value="myPassword" /> * </connectionSource> * </pre> - * <p> - * Note that this class will obtain an {@link javax.naming.InitialContext} - * using the no-argument constructor. This will usually work when executing - * within a J2EE environment. When outside the J2EE environment, make sure - * that you provide a jndi.properties file as described by your JNDI - * provider's documentation. + * <p> + * Note that this class will obtain an {@link javax.naming.InitialContext} + * using the no-argument constructor. This will usually work when executing + * within a J2EE environment. When outside the J2EE environment, make sure + * that you provide a jndi.properties file as described by your JNDI + * provider's documentation. * - * @author <a href="mailto:rdeca...@twcny.rr.com">Ray DeCampo</a> + * @author <a href="mailto:rdeca...@twcny.rr.com">Ray DeCampo</a> */ public class JNDIConnectionSource - extends ConnectionSourceSkeleton { - private String jndiLocation = null; - private DataSource dataSource = null; - - /** - * @see org.apache.log4j.spi.OptionHandler#activateOptions() - */ - public void activateOptions() { - if (jndiLocation == null) { - getLogger().error("No JNDI location specified for JNDIConnectionSource."); + extends ConnectionSourceSkeleton { + private String jndiLocation = null; + private DataSource dataSource = null; + + /** + * @see org.apache.log4j.spi.OptionHandler#activateOptions() + */ + public void activateOptions() { + if (jndiLocation == null) { + getLogger().error("No JNDI location specified for JNDIConnectionSource."); + } + + discoverConnnectionProperties(); + } - - discoverConnnectionProperties(); - - } - - /** - * @see org.apache.log4j.db.ConnectionSource#getConnection() - */ - public Connection getConnection() - throws SQLException { - Connection conn; - try { - - if(dataSource == null) { - dataSource = lookupDataSource(); - } - if (getUser() == null) { - conn = dataSource.getConnection(); - } else { - conn = dataSource.getConnection(getUser(), getPassword()); - } - } catch (final NamingException ne) { - getLogger().error("Error while getting data source", ne); - throw new SQLException("NamingException while looking up DataSource: " + ne.getMessage()); - } catch (final ClassCastException cce) { - getLogger().error("ClassCastException while looking up DataSource.", cce); - throw new SQLException("ClassCastException while looking up DataSource: " + cce.getMessage()); + + /** + * @see org.apache.log4j.db.ConnectionSource#getConnection() + */ + public Connection getConnection() + throws SQLException { + Connection conn; + try { + + if (dataSource == null) { + dataSource = lookupDataSource(); + } + if (getUser() == null) { + conn = dataSource.getConnection(); + } else { + conn = dataSource.getConnection(getUser(), getPassword()); + } + } catch (final NamingException ne) { + getLogger().error("Error while getting data source", ne); + throw new SQLException("NamingException while looking up DataSource: " + ne.getMessage()); + } catch (final ClassCastException cce) { + getLogger().error("ClassCastException while looking up DataSource.", cce); + throw new SQLException("ClassCastException while looking up DataSource: " + cce.getMessage()); + } + + return conn; + } + + /** + * Returns the jndiLocation. + * + * @return String + */ + public String getJndiLocation() { + return jndiLocation; } - return conn; - } - - /** - * Returns the jndiLocation. - * @return String - */ - public String getJndiLocation() { - return jndiLocation; - } - - - /** - * Sets the jndiLocation. - * @param jndiLocation The jndiLocation to set - */ - public void setJndiLocation(String jndiLocation) { - this.jndiLocation = jndiLocation; - } - - - private DataSource lookupDataSource() - throws NamingException, SQLException { - DataSource ds; - Context ctx = new InitialContext(); - Object obj = ctx.lookup(jndiLocation); - - // PortableRemoteObject was introduced in JDK 1.3. We won't use it. - //ds = (DataSource)PortableRemoteObject.narrow(obj, DataSource.class); - ds = (DataSource) obj; - - if (ds == null) { - throw new SQLException("Failed to obtain data source from JNDI location " + jndiLocation); - } else { - return ds; + + /** + * Sets the jndiLocation. + * + * @param jndiLocation The jndiLocation to set + */ + public void setJndiLocation(String jndiLocation) { + this.jndiLocation = jndiLocation; + } + + + private DataSource lookupDataSource() + throws NamingException, SQLException { + DataSource ds; + Context ctx = new InitialContext(); + Object obj = ctx.lookup(jndiLocation); + + // PortableRemoteObject was introduced in JDK 1.3. We won't use it. + //ds = (DataSource)PortableRemoteObject.narrow(obj, DataSource.class); + ds = (DataSource) obj; + + if (ds == null) { + throw new SQLException("Failed to obtain data source from JNDI location " + jndiLocation); + } else { + return ds; + } } - } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/db/dialect/HSQLDBDialect.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/db/dialect/HSQLDBDialect.java b/src/main/java/org/apache/log4j/db/dialect/HSQLDBDialect.java index 164a125..efddad5 100644 --- a/src/main/java/org/apache/log4j/db/dialect/HSQLDBDialect.java +++ b/src/main/java/org/apache/log4j/db/dialect/HSQLDBDialect.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,17 +15,17 @@ * limitations under the License. */ -package org.apache.log4j.db.dialect; +package org.apache.log4j.db.dialect; -/** - * The HSQLDB dialect. - * +/** + * The HSQLDB dialect. + * * @author <a href="http://www.qos.ch/log4j/">Ceki Gülcü</a> -*/ -public class HSQLDBDialect implements SQLDialect { - public static final String SELECT_CURRVAL = "CALL IDENTITY()"; + */ +public class HSQLDBDialect implements SQLDialect { + public static final String SELECT_CURRVAL = "CALL IDENTITY()"; - public String getSelectInsertId() { - return SELECT_CURRVAL; - } + public String getSelectInsertId() { + return SELECT_CURRVAL; + } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/db/dialect/MsSQLDialect.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/db/dialect/MsSQLDialect.java b/src/main/java/org/apache/log4j/db/dialect/MsSQLDialect.java index 08f4fc3..32368d6 100644 --- a/src/main/java/org/apache/log4j/db/dialect/MsSQLDialect.java +++ b/src/main/java/org/apache/log4j/db/dialect/MsSQLDialect.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,20 +15,20 @@ * limitations under the License. */ -package org.apache.log4j.db.dialect; +package org.apache.log4j.db.dialect; -/** -* The MS SQL Server dialect is untested. -* -* Note that the dialect is not needed if your JDBC driver supports -* the getGeneratedKeys method introduced in JDBC 3.0 specification. -* -* @author James Stauffer -*/ -public class MsSQLDialect implements SQLDialect { - public static final String SELECT_CURRVAL = "SELECT @@identity id"; +/** + * The MS SQL Server dialect is untested. + * <p> + * Note that the dialect is not needed if your JDBC driver supports + * the getGeneratedKeys method introduced in JDBC 3.0 specification. + * + * @author James Stauffer + */ +public class MsSQLDialect implements SQLDialect { + public static final String SELECT_CURRVAL = "SELECT @@identity id"; - public String getSelectInsertId() { - return SELECT_CURRVAL; - } + public String getSelectInsertId() { + return SELECT_CURRVAL; + } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/db/dialect/MySQLDialect.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/db/dialect/MySQLDialect.java b/src/main/java/org/apache/log4j/db/dialect/MySQLDialect.java index c1a63cd..993df83 100644 --- a/src/main/java/org/apache/log4j/db/dialect/MySQLDialect.java +++ b/src/main/java/org/apache/log4j/db/dialect/MySQLDialect.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,15 +18,12 @@ package org.apache.log4j.db.dialect; /** - * - * * @author Ceki - * */ public class MySQLDialect implements SQLDialect { - public static final String SELECT_LAST_INSERT_ID = "SELECT LAST_INSERT_ID()"; - - public String getSelectInsertId() { - return SELECT_LAST_INSERT_ID; - } + public static final String SELECT_LAST_INSERT_ID = "SELECT LAST_INSERT_ID()"; + + public String getSelectInsertId() { + return SELECT_LAST_INSERT_ID; + } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/db/dialect/OracleDialect.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/db/dialect/OracleDialect.java b/src/main/java/org/apache/log4j/db/dialect/OracleDialect.java index 1714f1f..cba2507 100644 --- a/src/main/java/org/apache/log4j/db/dialect/OracleDialect.java +++ b/src/main/java/org/apache/log4j/db/dialect/OracleDialect.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,16 +18,16 @@ package org.apache.log4j.db.dialect; /** - * The Oracle dialect. Tested successfully on Oracle9i Release 9.2.0.3.0 by + * The Oracle dialect. Tested successfully on Oracle9i Release 9.2.0.3.0 by * James Stauffer. - * + * * @author Ceki Gülcü */ public class OracleDialect implements SQLDialect { - public static final String SELECT_CURRVAL = "SELECT logging_event_id_seq.currval from dual"; + public static final String SELECT_CURRVAL = "SELECT logging_event_id_seq.currval from dual"; - public String getSelectInsertId() { - return SELECT_CURRVAL; - } + public String getSelectInsertId() { + return SELECT_CURRVAL; + } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/db/dialect/PostgreSQLDialect.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/db/dialect/PostgreSQLDialect.java b/src/main/java/org/apache/log4j/db/dialect/PostgreSQLDialect.java index 237fb0f..8f5d4c9 100644 --- a/src/main/java/org/apache/log4j/db/dialect/PostgreSQLDialect.java +++ b/src/main/java/org/apache/log4j/db/dialect/PostgreSQLDialect.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,17 +19,16 @@ package org.apache.log4j.db.dialect; /** - * * @author ceki - * + * <p> * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class PostgreSQLDialect - implements SQLDialect { - public static final String SELECT_CURRVAL = "SELECT currval('logging_event_id_seq')"; + implements SQLDialect { + public static final String SELECT_CURRVAL = "SELECT currval('logging_event_id_seq')"; - public String getSelectInsertId() { - return SELECT_CURRVAL; - } + public String getSelectInsertId() { + return SELECT_CURRVAL; + } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/db/dialect/SQLDialect.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/db/dialect/SQLDialect.java b/src/main/java/org/apache/log4j/db/dialect/SQLDialect.java index 2fcb0f7..538b74d 100644 --- a/src/main/java/org/apache/log4j/db/dialect/SQLDialect.java +++ b/src/main/java/org/apache/log4j/db/dialect/SQLDialect.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,10 +18,9 @@ package org.apache.log4j.db.dialect; /** * @author ceki - * */ public interface SQLDialect { - - String getSelectInsertId(); - + + String getSelectInsertId(); + } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/db/dialect/SybaseDialect.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/db/dialect/SybaseDialect.java b/src/main/java/org/apache/log4j/db/dialect/SybaseDialect.java index 44ba75e..38bcabb 100644 --- a/src/main/java/org/apache/log4j/db/dialect/SybaseDialect.java +++ b/src/main/java/org/apache/log4j/db/dialect/SybaseDialect.java @@ -17,16 +17,15 @@ * under the License. */ -package org.apache.log4j.db.dialect; +package org.apache.log4j.db.dialect; -/** - * The Sybase dialect. - * -*/ -public class SybaseDialect implements SQLDialect { - public static final String SELECT_CURRVAL = "select @@identity"; +/** + * The Sybase dialect. + */ +public class SybaseDialect implements SQLDialect { + public static final String SELECT_CURRVAL = "select @@identity"; - public String getSelectInsertId() { - return SELECT_CURRVAL; - } + public String getSelectInsertId() { + return SELECT_CURRVAL; + } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/db/dialect/Util.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/db/dialect/Util.java b/src/main/java/org/apache/log4j/db/dialect/Util.java index ff308e8..b807106 100644 --- a/src/main/java/org/apache/log4j/db/dialect/Util.java +++ b/src/main/java/org/apache/log4j/db/dialect/Util.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,98 +25,96 @@ import java.sql.SQLException; /** - * * @author Ceki Gulcu - * */ public class Util extends ComponentBase { - private static final String POSTGRES_PART = "postgresql"; - private static final String MYSQL_PART = "mysql"; - private static final String ORACLE_PART = "oracle"; - //private static final String MSSQL_PART = "mssqlserver4"; - private static final String MSSQL_PART = "microsoft"; - private static final String HSQL_PART = "hsql"; - - public static int discoverSQLDialect(DatabaseMetaData meta) { - int dialectCode = 0; - - try { - - String dbName = meta.getDatabaseProductName().toLowerCase(); - - if (dbName.contains(POSTGRES_PART)) { - return ConnectionSource.POSTGRES_DIALECT; - } else if (dbName.contains(MYSQL_PART)) { - return ConnectionSource.MYSQL_DIALECT; - } else if (dbName.contains(ORACLE_PART)) { - return ConnectionSource.ORACLE_DIALECT; - } else if (dbName.contains(MSSQL_PART)) { - return ConnectionSource.MSSQL_DIALECT; - } else if (dbName.contains(HSQL_PART)) { - return ConnectionSource.HSQL_DIALECT; - } else { - return ConnectionSource.UNKNOWN_DIALECT; - } - } catch (SQLException sqle) { - // we can't do much here + private static final String POSTGRES_PART = "postgresql"; + private static final String MYSQL_PART = "mysql"; + private static final String ORACLE_PART = "oracle"; + //private static final String MSSQL_PART = "mssqlserver4"; + private static final String MSSQL_PART = "microsoft"; + private static final String HSQL_PART = "hsql"; + + public static int discoverSQLDialect(DatabaseMetaData meta) { + int dialectCode = 0; + + try { + + String dbName = meta.getDatabaseProductName().toLowerCase(); + + if (dbName.contains(POSTGRES_PART)) { + return ConnectionSource.POSTGRES_DIALECT; + } else if (dbName.contains(MYSQL_PART)) { + return ConnectionSource.MYSQL_DIALECT; + } else if (dbName.contains(ORACLE_PART)) { + return ConnectionSource.ORACLE_DIALECT; + } else if (dbName.contains(MSSQL_PART)) { + return ConnectionSource.MSSQL_DIALECT; + } else if (dbName.contains(HSQL_PART)) { + return ConnectionSource.HSQL_DIALECT; + } else { + return ConnectionSource.UNKNOWN_DIALECT; + } + } catch (SQLException sqle) { + // we can't do much here + } + + return dialectCode; } - return dialectCode; - } + public static SQLDialect getDialectFromCode(int dialectCode) { + SQLDialect sqlDialect = null; - public static SQLDialect getDialectFromCode(int dialectCode) { - SQLDialect sqlDialect = null; + switch (dialectCode) { + case ConnectionSource.POSTGRES_DIALECT: + sqlDialect = new PostgreSQLDialect(); - switch (dialectCode) { - case ConnectionSource.POSTGRES_DIALECT: - sqlDialect = new PostgreSQLDialect(); + break; + case ConnectionSource.MYSQL_DIALECT: + sqlDialect = new MySQLDialect(); - break; - case ConnectionSource.MYSQL_DIALECT: - sqlDialect = new MySQLDialect(); + break; + case ConnectionSource.ORACLE_DIALECT: + sqlDialect = new OracleDialect(); - break; - case ConnectionSource.ORACLE_DIALECT: - sqlDialect = new OracleDialect(); + break; + case ConnectionSource.MSSQL_DIALECT: + sqlDialect = new MsSQLDialect(); - break; - case ConnectionSource.MSSQL_DIALECT: - sqlDialect = new MsSQLDialect(); + break; + case ConnectionSource.HSQL_DIALECT: + sqlDialect = new HSQLDBDialect(); - break; - case ConnectionSource.HSQL_DIALECT: - sqlDialect = new HSQLDBDialect(); - - break; + break; + } + return sqlDialect; } - return sqlDialect; - } - - /** - * This method handles cases where the - * {@link DatabaseMetaData#supportsGetGeneratedKeys} method is missing in the - * JDBC driver implementation. - */ - public boolean supportsGetGeneratedKeys(DatabaseMetaData meta) { - try { - return meta.supportsGetGeneratedKeys(); - } catch(Throwable e) { - getLogger().info("Could not call supportsGetGeneratedKeys method. This may be recoverable"); - return false; + + /** + * This method handles cases where the + * {@link DatabaseMetaData#supportsGetGeneratedKeys} method is missing in the + * JDBC driver implementation. + */ + public boolean supportsGetGeneratedKeys(DatabaseMetaData meta) { + try { + return meta.supportsGetGeneratedKeys(); + } catch (Throwable e) { + getLogger().info("Could not call supportsGetGeneratedKeys method. This may be recoverable"); + return false; + } } - } - -/** - * This method handles cases where the - * {@link DatabaseMetaData#supportsBatchUpdates} method is missing in the - * JDBC driver implementation. - */ - public boolean supportsBatchUpdates(DatabaseMetaData meta) { - try { - return meta.supportsBatchUpdates(); - } catch(Throwable e) { - getLogger().info("Missing DatabaseMetaData.supportsBatchUpdates method."); - return false; + + /** + * This method handles cases where the + * {@link DatabaseMetaData#supportsBatchUpdates} method is missing in the + * JDBC driver implementation. + */ + public boolean supportsBatchUpdates(DatabaseMetaData meta) { + try { + return meta.supportsBatchUpdates(); + } catch (Throwable e) { + getLogger().info("Missing DatabaseMetaData.supportsBatchUpdates method."); + return false; + } } - } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/db/package.html ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/db/package.html b/src/main/java/org/apache/log4j/db/package.html index 55652fb..c054d78 100644 --- a/src/main/java/org/apache/log4j/db/package.html +++ b/src/main/java/org/apache/log4j/db/package.html @@ -18,18 +18,18 @@ <html> <body> -<p>The org.apache.log4j.db package provides means to append logging events -into various databases. The persisted data can be later read back using -{@link org.apache.log4j.db.DBReceiver}. +<p>The org.apache.log4j.db package provides means to append logging events + into various databases. The persisted data can be later read back using + {@link org.apache.log4j.db.DBReceiver}. </p> <p>Most popular database systems, such as PostgreSQL, MySQL, Oracle, DB2 and MsSQL -are supported. + are supported. </p> <p>Just as importantly, the way for obtaining JDBC connections is pluggable. Connections can -be obtained through the tradinal way of DriverManager, or alternatively as a DataSource. -A DataSource can be instantiated directly or it can obtained through JNDI. + be obtained through the tradinal way of DriverManager, or alternatively as a DataSource. + A DataSource can be instantiated directly or it can obtained through JNDI. </p> </body> http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/helpers/Constants.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/helpers/Constants.java b/src/main/java/org/apache/log4j/helpers/Constants.java index 82b06c7..0de3245 100644 --- a/src/main/java/org/apache/log4j/helpers/Constants.java +++ b/src/main/java/org/apache/log4j/helpers/Constants.java @@ -20,111 +20,110 @@ package org.apache.log4j.helpers; /** * Constants used internally throughout log4j. - * */ public interface Constants { /** * log4j package name string literal. */ - String LOG4J_PACKAGE_NAME = "org.apache.log4j"; + String LOG4J_PACKAGE_NAME = "org.apache.log4j"; - /** - * The name of the default repository is "default" (without the quotes). - */ - String DEFAULT_REPOSITORY_NAME = "default"; + /** + * The name of the default repository is "default" (without the quotes). + */ + String DEFAULT_REPOSITORY_NAME = "default"; /** * application string literal. */ - String APPLICATION_KEY = "application"; + String APPLICATION_KEY = "application"; /** * hostname string literal. */ - String HOSTNAME_KEY = "hostname"; + String HOSTNAME_KEY = "hostname"; /** * receiver string literal. */ - String RECEIVER_NAME_KEY = "receiver"; + String RECEIVER_NAME_KEY = "receiver"; /** * group string literal. */ - String GROUP_KEY = "group"; + String GROUP_KEY = "group"; /** * log4jid string literal. */ - String LOG4J_ID_KEY = "log4jid"; + String LOG4J_ID_KEY = "log4jid"; /** * time stamp pattern string literal. */ - String TIMESTAMP_RULE_FORMAT = "yyyy/MM/dd HH:mm:ss"; + String TIMESTAMP_RULE_FORMAT = "yyyy/MM/dd HH:mm:ss"; - /** - * The default property file name for automatic configuration. - */ - String DEFAULT_CONFIGURATION_FILE = "log4j.properties"; - /** - * The default XML configuration file name for automatic configuration. - */ - String DEFAULT_XML_CONFIGURATION_FILE = "log4j.xml"; + /** + * The default property file name for automatic configuration. + */ + String DEFAULT_CONFIGURATION_FILE = "log4j.properties"; + /** + * The default XML configuration file name for automatic configuration. + */ + String DEFAULT_XML_CONFIGURATION_FILE = "log4j.xml"; /** * log4j.configuration string literal. */ - String DEFAULT_CONFIGURATION_KEY = "log4j.configuration"; + String DEFAULT_CONFIGURATION_KEY = "log4j.configuration"; /** * log4j.configuratorClass string literal. */ - String CONFIGURATOR_CLASS_KEY = "log4j.configuratorClass"; + String CONFIGURATOR_CLASS_KEY = "log4j.configuratorClass"; /** * JNDI context name string literal. */ - String JNDI_CONTEXT_NAME = "java:comp/env/log4j/context-name"; + String JNDI_CONTEXT_NAME = "java:comp/env/log4j/context-name"; /** * TEMP_LIST_APPENDER string literal. */ - String TEMP_LIST_APPENDER_NAME = "TEMP_LIST_APPENDER"; + String TEMP_LIST_APPENDER_NAME = "TEMP_LIST_APPENDER"; /** * TEMP_CONSOLE_APPENDER string literal. */ - String TEMP_CONSOLE_APPENDER_NAME = "TEMP_CONSOLE_APPENDER"; + String TEMP_CONSOLE_APPENDER_NAME = "TEMP_CONSOLE_APPENDER"; /** * Codes URL string literal. */ - String CODES_HREF = - "http://logging.apache.org/log4j/docs/codes.html"; + String CODES_HREF = + "http://logging.apache.org/log4j/docs/codes.html"; /** * ABSOLUTE string literal. */ - String ABSOLUTE_FORMAT = "ABSOLUTE"; + String ABSOLUTE_FORMAT = "ABSOLUTE"; /** * SimpleTimePattern for ABSOLUTE. */ - String ABSOLUTE_TIME_PATTERN = "HH:mm:ss,SSS"; + String ABSOLUTE_TIME_PATTERN = "HH:mm:ss,SSS"; /** * SimpleTimePattern for ABSOLUTE. */ - String SIMPLE_TIME_PATTERN = "HH:mm:ss"; + String SIMPLE_TIME_PATTERN = "HH:mm:ss"; /** * DATE string literal. */ - String DATE_AND_TIME_FORMAT = "DATE"; + String DATE_AND_TIME_FORMAT = "DATE"; /** * SimpleTimePattern for DATE. */ - String DATE_AND_TIME_PATTERN = "dd MMM yyyy HH:mm:ss,SSS"; + String DATE_AND_TIME_PATTERN = "dd MMM yyyy HH:mm:ss,SSS"; /** * ISO8601 string literal. */ - String ISO8601_FORMAT = "ISO8601"; + String ISO8601_FORMAT = "ISO8601"; /** * SimpleTimePattern for ISO8601. */ - String ISO8601_PATTERN = "yyyy-MM-dd HH:mm:ss,SSS"; + String ISO8601_PATTERN = "yyyy-MM-dd HH:mm:ss,SSS"; }