Java 类java.util.logging.ErrorManager 实例源码

项目:tomcat7    文件:FileHandler.java   
protected void closeWriter() {

    writerLock.writeLock().lock();
    try {
        if (writer == null)
            return;
        writer.write(getFormatter().getTail(this));
        writer.flush();
        writer.close();
        writer = null;
        date = "";
    } catch (Exception e) {
        reportError(null, e, ErrorManager.CLOSE_FAILURE);
    } finally {
        writerLock.writeLock().unlock();
    }
}
项目:tomcat7    文件:FileHandler.java   
/**
 * Flush the writer.
 */
@Override
public void flush() {

    writerLock.readLock().lock();
    try {
        if (writer == null)
            return;
        writer.flush();
    } catch (Exception e) {
        reportError(null, e, ErrorManager.FLUSH_FAILURE);
    } finally {
        writerLock.readLock().unlock();
    }

}
项目:lams    文件:FileHandler.java   
/**
 * Close the currently open log file (if any).
 */
public void close() {

    try {
        if (writer == null)
            return;
        writer.write(getFormatter().getTail(this));
        writer.flush();
        writer.close();
        writer = null;
        date = "";
    } catch (Exception e) {
        reportError(null, e, ErrorManager.CLOSE_FAILURE);
    }

}
项目:lams    文件:FileHandler.java   
/**
 * Open the new log file for the date specified by <code>date</code>.
 */
private void open() {

    // Create the directory if necessary
    File dir = new File(directory);
    dir.mkdirs();

    // Open the current log file
    try {
        String pathname = dir.getAbsolutePath() + File.separator +
            prefix + date + suffix;
        writer = new PrintWriter(new FileWriter(pathname, true), true);
        writer.write(getFormatter().getHead(this));
    } catch (Exception e) {
        reportError(null, e, ErrorManager.OPEN_FAILURE);
        writer = null;
    }

}
项目:monarch    文件:GemFireHandler.java   
@Override
public void publish(LogRecord record) {
  if (isLoggable(record)) {
    try {
      if (this.logWriter instanceof LogWriterLogger) {
        ((LogWriterLogger) this.logWriter).log(record.getLevel().intValue(), getMessage(record),
            record.getThrown());
      } else {
        ((LogWriterImpl) this.logWriter).put(record.getLevel().intValue(), getMessage(record),
            record.getThrown());
      }
    } catch (GemFireException ex) {
      reportError(null, ex, ErrorManager.WRITE_FAILURE);
    }
  }
}
项目:apache-tomcat-7.0.73-with-comment    文件:FileHandler.java   
protected void closeWriter() {

    writerLock.writeLock().lock();
    try {
        if (writer == null)
            return;
        writer.write(getFormatter().getTail(this));
        writer.flush();
        writer.close();
        writer = null;
        date = "";
    } catch (Exception e) {
        reportError(null, e, ErrorManager.CLOSE_FAILURE);
    } finally {
        writerLock.writeLock().unlock();
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:FileHandler.java   
/**
 * Flush the writer.
 */
@Override
public void flush() {

    writerLock.readLock().lock();
    try {
        if (writer == null)
            return;
        writer.flush();
    } catch (Exception e) {
        reportError(null, e, ErrorManager.FLUSH_FAILURE);
    } finally {
        writerLock.readLock().unlock();
    }

}
项目:lazycat    文件:FileHandler.java   
protected void closeWriter() {

        writerLock.writeLock().lock();
        try {
            if (writer == null)
                return;
            writer.write(getFormatter().getTail(this));
            writer.flush();
            writer.close();
            writer = null;
            date = "";
        } catch (Exception e) {
            reportError(null, e, ErrorManager.CLOSE_FAILURE);
        } finally {
            writerLock.writeLock().unlock();
        }
    }
项目:lazycat    文件:FileHandler.java   
/**
 * Flush the writer.
 */
@Override
public void flush() {

    writerLock.readLock().lock();
    try {
        if (writer == null)
            return;
        writer.flush();
    } catch (Exception e) {
        reportError(null, e, ErrorManager.FLUSH_FAILURE);
    } finally {
        writerLock.readLock().unlock();
    }

}
项目:yajsw    文件:MyFileHandler.java   
private synchronized void rotate()
{
    Level oldLevel = getLevel();
    setLevel(Level.OFF);

    super.close();
    if (desc)
        rotateDesc();
    else
        rotateAsc();
    try
    {
        open(files[0], false);
    }
    catch (IOException ix)
    {
        // We don't want to throw an exception here, but we
        // report the exception to any registered ErrorManager.
        reportError(null, ix, ErrorManager.OPEN_FAILURE);

    }
    setLevel(oldLevel);
}
项目:yajsw    文件:MyFileHandler.java   
void findNextGeneration()
{
    super.close();
    for (int i = count - 1; i > 0; i--)
    {
        if (files[i].exists())
        {
            files[i].delete();
        }
        files[i - 1].renameTo(files[i]);
    }
    try
    {
        output = new MeasureOutputStream(new BufferedOutputStream(
                new FileOutputStream(files[0])));
    }
    catch (FileNotFoundException e1)
    {
        this.getErrorManager().error("Error opening log file", e1,
                ErrorManager.OPEN_FAILURE);
    }
    setOutputStream(output);
}
项目:ibm-performance-monitor    文件:BatchedAsynchronousFileHandler.java   
private void findNextGeneration() {
    super.close();
    for ( int i = count - 1; i > 0; i-- ) {
        if ( files[i].exists() ) {
            files[i].delete();
        }
        files[i - 1].renameTo( files[i] );
    }
    try {
        // $ANALYSIS-IGNORE
        output = new MeasureOutputStream( new BufferedOutputStream( new FileOutputStream( files[0] ) ) );
    } catch ( FileNotFoundException e1 ) {
        // logging.1A=Error happened when open log file.
        this.getErrorManager().error( "BatchedAsynchronousFileHandler Output stream open failure. ", //$NON-NLS-1$
            e1, ErrorManager.OPEN_FAILURE );
    }
    setOutputStream( output );
}
项目:sematext-logsene-android    文件:LogseneHandler.java   
@Override
public void publish(LogRecord record) {
  // first check if this record should be logged (log level and filters are checked)
  if (!isLoggable(record)) {
    return;
  }
  JSONObject obj = new JSONObject();
  try {
    obj.put("@timestamp", Utils.iso8601(record.getMillis()));
    obj.put("level", record.getLevel().toString());
    obj.put("message", getFormatter().formatMessage(record));
    obj.put("logger", record.getLoggerName());
    obj.put("seqNum", record.getSequenceNumber());
    obj.put("threadId", record.getThreadID());
    obj.put("sourceClass", record.getSourceClassName());
    obj.put("sourceMethod", record.getSourceMethodName());
    if (record.getThrown() != null) {
      obj.put("stacktrace", Utils.getStackTrace(record.getThrown()));
    }
    logsene.event(obj);
  } catch (JSONException e) {
    // should never happen, as exception is thrown when key in put() is null
    reportError("Unable to construct json object", e, ErrorManager.GENERIC_FAILURE);
  }
}
项目:j2objc    文件:HandlerTest.java   
public void testConstructor_Properties() throws Exception {
    Properties p = new Properties();
    p.put("java.util.logging.MockHandler.level", "FINE");
    p
            .put("java.util.logging.MockHandler.filter", className
                    + "$MockFilter");
    p.put("java.util.logging.Handler.formatter", className
            + "$MockFormatter");
    p.put("java.util.logging.MockHandler.encoding", "utf-8");
    LogManager.getLogManager().readConfiguration(
            EnvironmentHelper.PropertiesToInputStream(p));

    assertEquals(LogManager.getLogManager().getProperty(
            "java.util.logging.MockHandler.level"), "FINE");
    assertEquals(LogManager.getLogManager().getProperty(
            "java.util.logging.MockHandler.encoding"), "utf-8");
    MockHandler h = new MockHandler();
    assertSame(h.getLevel(), Level.ALL);
    assertNull(h.getFormatter());
    assertNull(h.getFilter());
    assertNull(h.getEncoding());
    assertTrue(h.getErrorManager() instanceof ErrorManager);
    LogManager.getLogManager().reset();
}
项目:wildfly-logstash    文件:SocketHandler.java   
private String createFormattedMessage(final ExtLogRecord record) {
  final Formatter formatter = getFormatter();
  try {
    return formatter.format(record);
  } catch (Exception e) {
    reportError("Could not format message", e, ErrorManager.FORMAT_FAILURE);
    return null;
  }
}
项目:wildfly-logstash    文件:SocketHandler.java   
private OutputStream createOutputStream() {
  if (address != null || port >= 0) {
    try {
      switch (protocol) {
      case SSL_TCP:
        SslTcpOutputStream sos = new SslTcpOutputStream(address, port);
        if (sos.isConnected()) {
          return sos;
        }
        break;
      case UDP:
        return new UdpOutputStream(address, port);
      case TCP:
      default:
        TcpOutputStream tos = new TcpOutputStream(address, port);
        if (tos.isConnected()) {
          return tos;
        }
        break;
      }
    } catch (IOException e) {
      reportError("Failed to create socket output stream", e, ErrorManager.OPEN_FAILURE);
    }
  }
  return null;
}
项目:class-guard    文件:FileHandler.java   
protected void closeWriter() {

    writerLock.writeLock().lock();
    try {
        if (writer == null)
            return;
        writer.write(getFormatter().getTail(this));
        writer.flush();
        writer.close();
        writer = null;
        date = "";
    } catch (Exception e) {
        reportError(null, e, ErrorManager.CLOSE_FAILURE);
    } finally {
        writerLock.writeLock().unlock();
    }
}
项目:class-guard    文件:FileHandler.java   
/**
 * Flush the writer.
 */
@Override
public void flush() {

    writerLock.readLock().lock();
    try {
        if (writer == null)
            return;
        writer.flush();
    } catch (Exception e) {
        reportError(null, e, ErrorManager.FLUSH_FAILURE);
    } finally {
        writerLock.readLock().unlock();
    }

}
项目:cn1    文件:HandlerTest.java   
public void testConstructor_Properties() throws Exception {
    Properties p = new Properties();
    p.put("java.util.logging.MockHandler.level", "FINE");
    p
            .put("java.util.logging.MockHandler.filter", className
                    + "$MockFilter");
    p.put("java.util.logging.Handler.formatter", className
            + "$MockFormatter");
    p.put("java.util.logging.MockHandler.encoding", "utf-8");
    LogManager.getLogManager().readConfiguration(
            EnvironmentHelper.PropertiesToInputStream(p));

    assertEquals(LogManager.getLogManager().getProperty(
            "java.util.logging.MockHandler.level"), "FINE");
    assertEquals(LogManager.getLogManager().getProperty(
            "java.util.logging.MockHandler.encoding"), "utf-8");
    MockHandler h = new MockHandler();
    assertSame(h.getLevel(), Level.ALL);
    assertNull(h.getFormatter());
    assertNull(h.getFilter());
    assertNull(h.getEncoding());
    assertTrue(h.getErrorManager() instanceof ErrorManager);
    LogManager.getLogManager().reset();
}
项目:apache-tomcat-7.0.57    文件:FileHandler.java   
protected void closeWriter() {

    writerLock.writeLock().lock();
    try {
        if (writer == null)
            return;
        writer.write(getFormatter().getTail(this));
        writer.flush();
        writer.close();
        writer = null;
        date = "";
    } catch (Exception e) {
        reportError(null, e, ErrorManager.CLOSE_FAILURE);
    } finally {
        writerLock.writeLock().unlock();
    }
}
项目:apache-tomcat-7.0.57    文件:FileHandler.java   
/**
 * Flush the writer.
 */
@Override
public void flush() {

    writerLock.readLock().lock();
    try {
        if (writer == null)
            return;
        writer.flush();
    } catch (Exception e) {
        reportError(null, e, ErrorManager.FLUSH_FAILURE);
    } finally {
        writerLock.readLock().unlock();
    }

}
项目:apache-tomcat-7.0.57    文件:FileHandler.java   
protected void closeWriter() {

    writerLock.writeLock().lock();
    try {
        if (writer == null)
            return;
        writer.write(getFormatter().getTail(this));
        writer.flush();
        writer.close();
        writer = null;
        date = "";
    } catch (Exception e) {
        reportError(null, e, ErrorManager.CLOSE_FAILURE);
    } finally {
        writerLock.writeLock().unlock();
    }
}
项目:apache-tomcat-7.0.57    文件:FileHandler.java   
/**
 * Flush the writer.
 */
@Override
public void flush() {

    writerLock.readLock().lock();
    try {
        if (writer == null)
            return;
        writer.flush();
    } catch (Exception e) {
        reportError(null, e, ErrorManager.FLUSH_FAILURE);
    } finally {
        writerLock.readLock().unlock();
    }

}
项目:appengine-java-vm-runtime    文件:VmRuntimeLogHandler.java   
@Override
public void publish(LogRecord record) {
  if (!isLoggable(record)) {
    return;
  }

  // The formatter isn't necessarily thread-safe, so we synchronize around it.
  String message;
  synchronized (this) {
    try {
      message = getFormatter().format(record);
    } catch (Exception ex) {
      // We don't want to throw an exception here, but we
      // report the exception to any registered ErrorManager.
      reportError(null, ex, ErrorManager.FORMAT_FAILURE);
      return;
    }
  }

  VmApiProxyEnvironment environment = getThreadLocalEnvironment();
  if (environment != null) {
    environment.addLogRecord(convertLogRecord(record, message));
  }
}
项目:freeVM    文件:HandlerTest.java   
public void testConstructor_Properties() throws Exception {
    Properties p = new Properties();
    p.put("java.util.logging.MockHandler.level", "FINE");
    p
            .put("java.util.logging.MockHandler.filter", className
                    + "$MockFilter");
    p.put("java.util.logging.Handler.formatter", className
            + "$MockFormatter");
    p.put("java.util.logging.MockHandler.encoding", "utf-8");
    LogManager.getLogManager().readConfiguration(
            EnvironmentHelper.PropertiesToInputStream(p));

    assertEquals(LogManager.getLogManager().getProperty(
            "java.util.logging.MockHandler.level"), "FINE");
    assertEquals(LogManager.getLogManager().getProperty(
            "java.util.logging.MockHandler.encoding"), "utf-8");
    MockHandler h = new MockHandler();
    assertSame(h.getLevel(), Level.ALL);
    assertNull(h.getFormatter());
    assertNull(h.getFilter());
    assertNull(h.getEncoding());
    assertTrue(h.getErrorManager() instanceof ErrorManager);
    LogManager.getLogManager().reset();
}
项目:freeVM    文件:HandlerTest.java   
public void testConstructor_Properties() throws Exception {
    Properties p = new Properties();
    p.put("java.util.logging.MockHandler.level", "FINE");
    p
            .put("java.util.logging.MockHandler.filter", className
                    + "$MockFilter");
    p.put("java.util.logging.Handler.formatter", className
            + "$MockFormatter");
    p.put("java.util.logging.MockHandler.encoding", "utf-8");
    LogManager.getLogManager().readConfiguration(
            EnvironmentHelper.PropertiesToInputStream(p));

    assertEquals(LogManager.getLogManager().getProperty(
            "java.util.logging.MockHandler.level"), "FINE");
    assertEquals(LogManager.getLogManager().getProperty(
            "java.util.logging.MockHandler.encoding"), "utf-8");
    MockHandler h = new MockHandler();
    assertSame(h.getLevel(), Level.ALL);
    assertNull(h.getFormatter());
    assertNull(h.getFilter());
    assertNull(h.getEncoding());
    assertTrue(h.getErrorManager() instanceof ErrorManager);
    LogManager.getLogManager().reset();
}
项目:WBSAirback    文件:FileHandler.java   
protected void closeWriter() {

    writerLock.writeLock().lock();
    try {
        if (writer == null)
            return;
        writer.write(getFormatter().getTail(this));
        writer.flush();
        writer.close();
        writer = null;
        date = "";
    } catch (Exception e) {
        reportError(null, e, ErrorManager.CLOSE_FAILURE);
    } finally {
        writerLock.writeLock().unlock();
    }
}
项目:WBSAirback    文件:FileHandler.java   
/**
 * Flush the writer.
 */
@Override
public void flush() {

    writerLock.readLock().lock();
    try {
        if (writer == null)
            return;
        writer.flush();
    } catch (Exception e) {
        reportError(null, e, ErrorManager.FLUSH_FAILURE);
    } finally {
        writerLock.readLock().unlock();
    }

}
项目:tomee    文件:LocalFileHandler.java   
@Override
public void close() {
    closed = true;

    writerLock.writeLock().lock();
    try {
        if (writer == null) {
            return;
        }
        writer.write(getFormatter().getTail(this));
        writer.flush();
        writer.close();
        writer = null;
    } catch (final Exception e) {
        reportError(null, e, ErrorManager.CLOSE_FAILURE);
    } finally {
        writerLock.writeLock().unlock();
    }

    // wait for bg tasks if running
    backgroundTaskLock.lock();
    backgroundTaskLock.unlock();
}
项目:tomee    文件:FileHandler.java   
protected void closeWriter() {

        writerLock.writeLock().lock();
        try {
            if (writer == null) {
                return;
            }
            writer.write(getFormatter().getTail(this));
            writer.flush();
            writer.close();
            writer = null;
            date = "";
        } catch (final Exception e) {
            reportError(null, e, ErrorManager.CLOSE_FAILURE);
        } finally {
            writerLock.writeLock().unlock();
        }
    }
项目:tomee    文件:FileHandler.java   
/**
 * Flush the writer.
 */
@Override
public void flush() {

    writerLock.readLock().lock();
    try {
        if (writer == null) {
            return;
        }
        writer.flush();
    } catch (final Exception e) {
        reportError(null, e, ErrorManager.FLUSH_FAILURE);
    } finally {
        writerLock.readLock().unlock();
    }

}
项目:incubator-netbeans    文件:ProjectHelper.java   
public static void disableCoS(Project p, final boolean enable) {
    final AntProjectHelper helper = getAntProjectHelper(p);
    if (helper == null) {
        if (enable) {
            StatusDisplayer.getDefault().setStatusText(
                    NbBundle.getMessage(ProjectHelper.class, "WARN_couldNotEnableCoS"),
                    StatusDisplayer.IMPORTANCE_ERROR_HIGHLIGHT);
        }
        return;
    }
    try {
        ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
            @Override
            public Void run() throws Exception {
                EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
                if (enable) {
                    ep.setProperty(JAXB_COMPILE_ON_SAVE, Boolean.TRUE.toString());
                } else {
                    ep.remove(JAXB_COMPILE_ON_SAVE);
                }
                helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);

                return null;
            }
        });
    } catch (MutexException ex) {
        org.openide.ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, ex);
    }
}
项目:lams    文件:FileHandler.java   
/**
 * Flush the writer.
 */
public void flush() {

    try {
        writer.flush();
    } catch (Exception e) {
        reportError(null, e, ErrorManager.FLUSH_FAILURE);
    }

}
项目:DIA-Umpire-Maven    文件:DocumentHandler.java   
/**
 *
 */
public void publish(LogRecord record) {
    if (!isLoggable(record)) {
        return;
    }

    String message;

    try {
        message = getFormatter().format(record);
    } catch (Exception exception) {
        reportError(null, exception, ErrorManager.FORMAT_FAILURE);
        return;
    }

    synchronized (textPane) {
        if (textPane.getDocument().getLength() >= MAXIMUM_DOCUMENT_SIZE) {
            // Delete the contents of the text pane.
            textPane.setText("");
        }

        try {
            if (record.getLevel() == Level.SEVERE) {
                textPane.getDocument().insertString(textPane.getDocument().getLength(), message, severStyle);
            } else {
                textPane.getDocument().insertString(textPane.getDocument().getLength(), message, infoStyle);
            }
            textPane.setCaretPosition(textPane.getDocument().getLength());
        } catch (Exception ex) {
            reportError(null, ex, ErrorManager.WRITE_FAILURE);
        }
    }

}
项目:ibm-performance-monitor    文件:BatchedAsynchronousFileHandler.java   
private void printInvalidPropertyMessage( String key, String value, Exception e ) {
    // logging.12=Invalid property value for
    String msg = new StringBuilder().append( "Invalid property." ) //$NON-NLS-1$
        .append( prefix ).append( ":" ).append( key ).append( "/" ).append( //$NON-NLS-1$//$NON-NLS-2$
            value ).toString();

    reportError( msg, e, ErrorManager.GENERIC_FAILURE );
}
项目:wildfly-swarm    文件:FluentdHandler.java   
@Override
protected void doPublish(ExtLogRecord record) {

    synchronized (this) {
        if (!initialized) {
            try {
                initialize();
            } catch (Exception e) {
                reportError("Error creating fluentd connection", e, ErrorManager.OPEN_FAILURE);
                setEnabled(false);
            }
        }
    }

    if (initialized) {
        Map<String, Object> entries = new HashMap<>();

        entries.put(Key.SEQUENCE.getKey(), record.getSequenceNumber());
        entries.put(Key.LEVEL.getKey(), record.getLevel().getName());
        entries.put(Key.THREAD_NAME.getKey(), record.getThreadName());
        entries.put(Key.MESSAGE.getKey(), record.getFormattedMessage());
        entries.put(Key.THREAD_ID.getKey(), record.getThreadID());
        entries.put(Key.MDC.getKey(), record.getMdcCopy());
        entries.put(Key.NDC.getKey(), record.getNdc());

        this.sender.emit(this.tag, record.getMillis(), entries);
    }

}
项目:wildfly-swarm    文件:FluentdHandler.java   
private void safeClose(RawSocketSender c) {
    try {
        if (c != null) {
            c.close();
        }
    } catch (Exception e) {
        reportError("Error closing resource", e, ErrorManager.CLOSE_FAILURE);
    } catch (Throwable ignored) {
    }
}
项目:achmed    文件:LoggingConsoleHandler.java   
@Override
public void publish(LogRecord record) {
    try {
        String message = this.formatter.format(record);
        if (record.getLevel().intValue() >= Level.WARNING.intValue()) {
            System.err.write(message.getBytes());                       
        } else {
            System.out.write(message.getBytes());
        }
    } catch (Exception exception) {
        super.reportError(null, exception, ErrorManager.FORMAT_FAILURE);
    }
}
项目:triplea    文件:ConsoleHandler.java   
private Optional<String> formatRecord(final LogRecord record) {
  try {
    return Optional.of(getFormatter().format(record));
  } catch (final RuntimeException e) {
    reportError(null, e, ErrorManager.FORMAT_FAILURE);
    return Optional.empty();
  }
}
项目:triplea    文件:ConsoleHandler.java   
private void writeMessage(final Level level, final String message) {
  final PrintStream stream = getStreamFor(level);
  try {
    stream.print(message);
    stream.flush();
  } catch (final RuntimeException e) {
    reportError(null, e, ErrorManager.WRITE_FAILURE);
  }
}