} catch (Exception ex) { if (!ignoreExceptions()) { throw new AppenderLoggingException(ex);
@Override public void reportError(String message, Exception e) { if (e != null) { throw new AppenderLoggingException(e); } LOGGER.error(message, null, 0); } };
@Override public void reportError(String message, Exception e) { if (e != null) { throw new AppenderLoggingException(e); } LOGGER.error(message, null, 0); } };
@Override public void reportError(String message, Exception e) { if (e != null) { throw new AppenderLoggingException(e); } LOGGER.error(message, null, 0); } };
@Override protected void connectAndStart() { try { this.entityManager = this.entityManagerFactory.createEntityManager(); this.transaction = this.entityManager.getTransaction(); this.transaction.begin(); } catch (final Exception e) { throw new AppenderLoggingException( "Cannot write logging event or flush buffer; manager cannot create EntityManager or transaction.", e ); } }
@Override protected void writeToDestination(final byte[] bytes, final int offset, final int length) { try { randomAccessFile.write(bytes, offset, length); } catch (final IOException ex) { final String msg = "Error writing to RandomAccessFile " + getName(); throw new AppenderLoggingException(msg, ex); } }
/** * Flushes any buffers. */ public synchronized void flush() { try { writer.flush(); } catch (final IOException ex) { final String msg = "Error flushing stream " + getName(); throw new AppenderLoggingException(msg, ex); } }
@Override protected void connectAndStart() { try { this.connection = this.connectionSource.getConnection(); this.connection.setAutoCommit(false); this.statement = this.connection.prepareStatement(this.sqlStatement); } catch (final SQLException e) { throw new AppenderLoggingException( "Cannot write logging event or flush buffer; JDBC manager cannot connect to the database.", e ); } }
/** * Calls {@code flush()} on the underlying output stream. * @since 2.6 */ protected synchronized void flushDestination() { final OutputStream stream = outputStream; // access volatile field only once per method if (stream != null) { try { stream.flush(); } catch (final IOException ex) { throw new AppenderLoggingException("Error flushing stream " + getName(), ex); } } }
/** * Some output streams synchronize writes while others do not. Synchronizing here insures that * log events won't be intertwined. * @param str the string to write * @throws AppenderLoggingException if an error occurs. */ protected synchronized void write(final String str) { try { writer.write(str); } catch (final IOException ex) { final String msg = "Error writing to stream " + getName(); throw new AppenderLoggingException(msg, ex); } }
/** * Handle an error with a message and an exception. * @param msg The message. * @param t The Throwable. */ @Override public void error(final String msg, final Throwable t) { final long current = System.nanoTime(); if (current - lastException > EXCEPTION_INTERVAL || exceptionCount++ < MAX_EXCEPTIONS) { LOGGER.error(msg, t); } lastException = current; if (!appender.ignoreExceptions() && t != null && !(t instanceof AppenderLoggingException)) { throw new AppenderLoggingException(msg, t); } }
/** * Handle an error with a message, and exception and a logging event. * @param msg The message. * @param event The LogEvent. * @param t The Throwable. */ @Override public void error(final String msg, final LogEvent event, final Throwable t) { final long current = System.nanoTime(); if (current - lastException > EXCEPTION_INTERVAL || exceptionCount++ < MAX_EXCEPTIONS) { LOGGER.error(msg, t); } lastException = current; if (!appender.ignoreExceptions() && t != null && !(t instanceof AppenderLoggingException)) { throw new AppenderLoggingException(msg, t); } }
@Override public void start() { super.start(); try { this.eventHubsManager.startup(); } catch (Throwable exception) { final String errMsg = String.format(Locale.US, "[%s] Appender initialization failed with error: [%s]", this.getName(), exception.getMessage()); LOGGER.error(errMsg); throw new AppenderLoggingException(errMsg, exception); } }
/** * Writes the specified section of the specified byte array to the stream. * * @param bytes the array containing data * @param offset from where to write * @param length how many bytes to write * @since 2.6 */ protected synchronized void writeToDestination(final byte[] bytes, final int offset, final int length) { try { getOutputStream().write(bytes, offset, length); } catch (final IOException ex) { throw new AppenderLoggingException("Error writing to stream " + getName(), ex); } }
private void handleError(final String prefix) { final String msg = appenderErrorHandlerMessage(prefix); if (!appender.ignoreExceptions()) { throw new AppenderLoggingException(msg); } }
@Override public void append(LogEvent event) { readLock.lock(); try{ final byte[] bytes = getLayout().toByteArray(event); LoggingConsoleRT.instance.addMessage(new String(bytes)); }catch(Exception e){ if(!ignoreExceptions()) throw new AppenderLoggingException(e); }finally{ readLock.unlock(); } }
private void tryCallAppender(final LogEvent event) { try { appender.append(event); } catch (final RuntimeException ex) { handleAppenderError(ex); } catch (final Exception ex) { handleAppenderError(new AppenderLoggingException(ex)); } }
@Override protected synchronized void writeToDestination(final byte[] bytes, final int offset, final int length) { try { if (randomAccessFile == null) { String fileName = getFileName(); File file = new File(fileName); FileUtils.makeParentDirs(file); createFileAfterRollover(fileName); } randomAccessFile.write(bytes, offset, length); size += length; } catch (final IOException ex) { final String msg = "Error writing to RandomAccessFile " + getName(); throw new AppenderLoggingException(msg, ex); } }
@Override public final void append(final LogEvent event) { this.readLock.lock(); try { this.getManager().write(event); } catch (final LoggingException e) { LOGGER.error("Unable to write to database [{}] for appender [{}].", this.getManager().getName(), this.getName(), e); throw e; } catch (final Exception e) { LOGGER.error("Unable to write to database [{}] for appender [{}].", this.getManager().getName(), this.getName(), e); throw new AppenderLoggingException("Unable to write to database in appender: " + e.getMessage(), e); } finally { this.readLock.unlock(); } }
throw new AppenderLoggingException(ex);