java.util.logging.Logger.throwing()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中java.util.logging.Logger.throwing()方法的一些代码示例,展示了Logger.throwing()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.throwing()方法的具体详情如下:
包路径:java.util.logging.Logger
类名称:Logger
方法名:throwing

Logger.throwing介绍

[英]Log throwing an exception.

This is a convenience method to log that a method is terminating by throwing an exception. The logging is done using the FINER level.

If the logger is currently enabled for the given message level then the given arguments are stored in a LogRecord which is forwarded to all registered output handlers. The LogRecord's message is set to "THROW".

Note that the thrown argument is stored in the LogRecord thrown property, rather than the LogRecord parameters property. Thus is it processed specially by output Formatters and is not treated as a formatting parameter to the LogRecord message property.
[中]

代码示例

代码示例来源:origin: jersey/jersey

public void throwing(final String sourceClass, final String sourceMethod, final Throwable thrown) {
  logger.throwing(sourceClass, sourceMethod, thrown);
}

代码示例来源:origin: jersey/jersey

public void throwing(final String sourceClass, final String sourceMethod, final Throwable thrown) {
  logger.throwing(sourceClass, sourceMethod, thrown);
}

代码示例来源:origin: hankcs/HanLP

/**
 * 快速保存
 *
 * @param path
 * @param content
 * @return
 */
public static boolean saveTxt(String path, String content)
{
  try
  {
    FileChannel fc = new FileOutputStream(path).getChannel();
    fc.write(ByteBuffer.wrap(content.getBytes()));
    fc.close();
  }
  catch (Exception e)
  {
    logger.throwing("IOUtil", "saveTxt", e);
    logger.warning("IOUtil saveTxt 到" + path + "失败" + e.toString());
    return false;
  }
  return true;
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Override
  protected T initialValue(){
    try {
      T obj = type.newInstance();
      if (path != null) {
        ((AssetLocator)obj).setRootPath(path);
      }
      return obj;
    } catch (InstantiationException ex) {
      logger.log(Level.SEVERE,"Cannot create locator of type {0}, does"
            + " the class have an empty and publically accessible"+
             " constructor?", type.getName());
      logger.throwing(type.getName(), "<init>", ex);
    } catch (IllegalAccessException ex) {
      logger.log(Level.SEVERE,"Cannot create locator of type {0}, "
            + "does the class have an empty and publically "
            + "accessible constructor?", type.getName());
      logger.throwing(type.getName(), "<init>", ex);
    }
    return null;
  }
}

代码示例来源:origin: org.codehaus.groovy/groovy

/**
 * Convenience method that calls {@link #getMetaPropertyValues(java.lang.Object)}(self)
 * and provides the data in form of simple key/value pairs, i.e. without
 * type() information.
 *
 * @param self the receiver object
 * @return meta properties as Map of key/value pairs
 * @since 1.0
 */
public static Map getProperties(Object self) {
  List<PropertyValue> metaProps = getMetaPropertyValues(self);
  Map<String, Object> props = new LinkedHashMap<String, Object>(metaProps.size());
  for (PropertyValue mp : metaProps) {
    try {
      props.put(mp.getName(), mp.getValue());
    } catch (Exception e) {
      LOG.throwing(self.getClass().getName(), "getProperty(" + mp.getName() + ")", e);
    }
  }
  return props;
}

代码示例来源:origin: geotools/geotools

AppSchemaDataAccessConfigurator.LOGGER.throwing(
    getClass().getName(), "resolveRelativePaths", e);
throw new RuntimeException(e);

代码示例来源:origin: c3p0/c3p0

public void throwing(String srcClass, String srcMeth, Throwable t)
{ 
  if (! logger.isLoggable( Level.FINER )) return;
  logger.throwing( srcClass, srcMeth, t ); 
}

代码示例来源:origin: com.mchange/mchange-commons-java

public void throwing(String srcClass, String srcMeth, Throwable t)
{ 
  if (! logger.isLoggable( Level.FINER )) return;
  logger.throwing( srcClass, srcMeth, t ); 
}

代码示例来源:origin: com.mchange.c3p0/com.springsource.com.mchange.v2.c3p0

public void throwing(String srcClass, String srcMeth, Throwable t)
{ 
  if (! logger.isLoggable( Level.FINER )) return;
  logger.throwing( srcClass, srcMeth, t ); 
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-team-commons

private static String getPath(File file) {
  try {
    return file.getCanonicalPath();
  } catch (IOException ex) {
    LOG.throwing(FileToRepoMappingStorage.class.getCanonicalName(),
           "storeMappingToPrefs",                         //NOI18N
           ex);
    return null;
  }
}

代码示例来源:origin: entando/entando-core

@Override
public void info(Object arg0, Throwable arg1) {
  _log.throwing(null, null, arg1);
  _log.info(arg0.toString());
}

代码示例来源:origin: entando/entando-core

@Override
public void fatal(Object arg0, Throwable arg1) {
  _log.throwing(null, null, arg1);
  _log.severe(arg0.toString());
}

代码示例来源:origin: org.talend.esb.job/org.talend.esb.job.controller

private void putPoison() {
  boolean success = false;
  while (!success) {
    try {
      requests.put(POISON);
      success = true;
    } catch (InterruptedException e) {
      LOG.throwing(this.getClass().getName(), "stop", e);
    }
  }
}

代码示例来源:origin: com.yammer.telemetry/telemetry-lib

@Override
  public void run() {
    try (PrintWriter writer = new PrintWriter(writerProvider.getWriter())) {
      writer.println(objectMapper.writeValueAsString(object));
      writer.flush();
    } catch (IOException e) {
      LOG.throwing(LogJob.class.getName(), "run", e);
    }
  }
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * PUBLIC:
 * <p>
 * Log a throwable.
 * </p><p>
 * @param throwable a throwable
 * </p>
 */
@Override
public void throwing(Throwable throwable) {
  getLogger(null).throwing(null, null, throwable);
}

代码示例来源:origin: org.apache.myfaces.extensions.cdi.core/myfaces-extcdi-core-impl

/**
 * {@inheritDoc}
 */
public void throwing(String s, String s1, Throwable throwable)
{
  getWrapped().throwing(s, s1, throwable);
}

代码示例来源:origin: Talend/tesb-rt-se

public void bind() {
  LOG.fine("bind calling, creating and opening ServiceTracker...");
  Filter filter = null;
  try {
    filter = context.createFilter(FILTER);
  } catch (InvalidSyntaxException e) {
    LOG.throwing(this.getClass().getName(), "bind", e);
    
  }
  tracker = new ServiceTracker(context, filter, new Customizer());
  tracker.open();
}

代码示例来源:origin: org.jboss.arquillian.testenricher/arquillian-testenricher-ejb

public void enrich(Object testCase) {
  if (SecurityActions.isClassPresent(ANNOTATION_NAME)) {
    try {
      if (createContext() != null) {
        injectClass(testCase);
      }
    } catch (Exception e) {
      log.throwing(EJBInjectionEnricher.class.getName(), "enrich", e);
    }
  }
}

代码示例来源:origin: org.jinterop/j-interop

public Object deserializeData(NetworkDataRepresentation ndr,List defferedPointers, Map additionalData, int FLAG)
{
  UUID ret = new UUID();
  try {
    ret.decode(ndr,ndr.getBuffer());
  } catch (NdrException e) {
    JISystem.getLogger().throwing("UUIDImpl","deserializeData",e);  
    ret = null;
  }
  return ret;
}

代码示例来源:origin: com.diffplug.matsim/matconsolectl

private void invoke(VoidThrowingInvocation invocation) throws MatlabInvocationException {
  LOGGER.entering(CLASS_NAME, invocation.name, invocation.args);
  try {
    invocation.invoke();
    LOGGER.exiting(CLASS_NAME, invocation.name);
  } catch (MatlabInvocationException e) {
    LOGGER.throwing(CLASS_NAME, invocation.name, e);
    LOGGER.exiting(CLASS_NAME, invocation.name);
    throw e;
  }
}

相关文章