當前位置: 首頁>>代碼示例>>Java>>正文


Java ErrorManager類代碼示例

本文整理匯總了Java中java.util.logging.ErrorManager的典型用法代碼示例。如果您正苦於以下問題:Java ErrorManager類的具體用法?Java ErrorManager怎麽用?Java ErrorManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ErrorManager類屬於java.util.logging包,在下文中一共展示了ErrorManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: closeWriter

import java.util.logging.ErrorManager; //導入依賴的package包/類
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();
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:18,代碼來源:FileHandler.java

示例2: flush

import java.util.logging.ErrorManager; //導入依賴的package包/類
/**
 * 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();
    }
    
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:19,代碼來源:FileHandler.java

示例3: close

import java.util.logging.ErrorManager; //導入依賴的package包/類
/**
 * 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);
    }
    
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:19,代碼來源:FileHandler.java

示例4: open

import java.util.logging.ErrorManager; //導入依賴的package包/類
/**
 * 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;
    }

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:FileHandler.java

示例5: publish

import java.util.logging.ErrorManager; //導入依賴的package包/類
@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);
    }
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:17,代碼來源:GemFireHandler.java

示例6: closeWriter

import java.util.logging.ErrorManager; //導入依賴的package包/類
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();
		}
	}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:18,代碼來源:FileHandler.java

示例7: flush

import java.util.logging.ErrorManager; //導入依賴的package包/類
/**
 * 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();
	}

}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:19,代碼來源:FileHandler.java

示例8: rotate

import java.util.logging.ErrorManager; //導入依賴的package包/類
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);
}
 
開發者ID:yajsw,項目名稱:yajsw,代碼行數:24,代碼來源:MyFileHandler.java

示例9: findNextGeneration

import java.util.logging.ErrorManager; //導入依賴的package包/類
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);
}
 
開發者ID:yajsw,項目名稱:yajsw,代碼行數:24,代碼來源:MyFileHandler.java

示例10: findNextGeneration

import java.util.logging.ErrorManager; //導入依賴的package包/類
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 );
}
 
開發者ID:dd00f,項目名稱:ibm-performance-monitor,代碼行數:19,代碼來源:BatchedAsynchronousFileHandler.java

示例11: publish

import java.util.logging.ErrorManager; //導入依賴的package包/類
@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);
  }
}
 
開發者ID:sematext,項目名稱:sematext-logsene-android,代碼行數:26,代碼來源:LogseneHandler.java

示例12: testConstructor_Properties

import java.util.logging.ErrorManager; //導入依賴的package包/類
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();
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:25,代碼來源:HandlerTest.java

示例13: createFormattedMessage

import java.util.logging.ErrorManager; //導入依賴的package包/類
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;
  }
}
 
開發者ID:kifj,項目名稱:wildfly-logstash,代碼行數:10,代碼來源:SocketHandler.java

示例14: createOutputStream

import java.util.logging.ErrorManager; //導入依賴的package包/類
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;
}
 
開發者ID:kifj,項目名稱:wildfly-logstash,代碼行數:27,代碼來源:SocketHandler.java

示例15: publish

import java.util.logging.ErrorManager; //導入依賴的package包/類
@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));
  }
}
 
開發者ID:GoogleCloudPlatform,項目名稱:appengine-java-vm-runtime,代碼行數:25,代碼來源:VmRuntimeLogHandler.java


注:本文中的java.util.logging.ErrorManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。