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

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

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

Logger.log介绍

[英]Log a message, with no arguments.

If the logger is currently enabled for the given message level then the given message is forwarded to all the registered output Handler objects.
[中]记录消息,不带参数。
如果记录器当前已针对给定消息级别启用,则给定消息将转发到所有已注册的输出处理程序对象。

代码示例

代码示例来源:origin: jenkinsci/jenkins

private void _cleanUpPluginServletFilters(List<Throwable> errors) {
  LOGGER.log(Level.FINE, "Stopping filters");
  try {
    PluginServletFilter.cleanUp();
  } catch (OutOfMemoryError e) {
    // we should just propagate this, no point trying to log
    throw e;
  } catch (LinkageError e) {
    LOGGER.log(SEVERE, "Failed to stop filters", e);
    // safe to ignore and continue for this one
  } catch (Throwable e) {
    LOGGER.log(SEVERE, "Failed to stop filters", e);
    // save for later
    errors.add(e);
  }
}

代码示例来源:origin: jenkinsci/jenkins

/**
   * Called when a plugin is installed, but there was already a plugin installed which optionally depended on that plugin.
   * The class loader of the existing depending plugin should be updated
   * to load classes from the newly installed plugin.
   * @param depender plugin depending on dependee.
   * @param dependee newly loaded plugin.
   * @since 1.557
   */
  // TODO an @Abstract annotation with a matching processor could make it a compile-time error to neglect to override this, without breaking binary compatibility
  default void updateDependency(PluginWrapper depender, PluginWrapper dependee) {
    Logger.getLogger(PluginStrategy.class.getName()).log(Level.WARNING, "{0} does not yet implement updateDependency", getClass());
  }
}

代码示例来源:origin: jenkinsci/jenkins

private void notifyRejected(@CheckForNull Class<?> clazz, @CheckForNull String clazzName, String message) {
    Throwable cause = null;
    if (LOGGER.isLoggable(Level.FINE)) {
      cause = new SecurityException("Class rejected by the class filter: " +
          (clazz != null ? clazz.getName() : clazzName));
    }
    LOGGER.log(Level.WARNING, message, cause);

    // TODO: add a Telemetry implementation (JEP-304)
  }
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Gets the information about the queue item for the given project.
 *
 * @return null if the project is not in the queue.
 * @since 1.607
 */
private List<Item> liveGetItems(Task t) {
  lock.lock();
  try {
    List<Item> result = new ArrayList<Item>();
    result.addAll(blockedProjects.getAll(t));
    result.addAll(buildables.getAll(t));
    // Do not include pendings—we have already finalized WorkUnitContext.actions.
    if (LOGGER.isLoggable(Level.FINE)) {
      List<BuildableItem> thePendings = pendings.getAll(t);
      if (!thePendings.isEmpty()) {
        LOGGER.log(Level.FINE, "ignoring {0} during scheduleInternal", thePendings);
      }
    }
    for (Item item : waitingList) {
      if (item.task.equals(t)) {
        result.add(item);
      }
    }
    return result;
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: 4thline/cling

protected void addParsedValue(DLNAHeader.Type type, UpnpHeader value) {
  log.log(Level.FINE, "Adding parsed header: {0}", value);
  List<UpnpHeader> list = parsedDLNAHeaders.get(type);
  if (list == null) {
    list = new LinkedList<>();
    parsedDLNAHeaders.put(type, list);
  }
  list.add(value);
}

代码示例来源:origin: google/guava

/** Causes teardown to execute. */
 public final void runTearDown() {
  List<Throwable> exceptions = new ArrayList<>();
  List<TearDown> stackCopy;
  synchronized (stack) {
   stackCopy = Lists.newArrayList(stack);
   stack.clear();
  }
  for (TearDown tearDown : stackCopy) {
   try {
    tearDown.tearDown();
   } catch (Throwable t) {
    if (suppressThrows) {
     logger.log(Level.INFO, "exception thrown during tearDown", t);
    } else {
     exceptions.add(t);
    }
   }
  }
  if (!suppressThrows && (exceptions.size() > 0)) {
   throw ClusterException.create(exceptions);
  }
 }
}

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

/**
 *  Directly registers a class for a specific ID.  Generally, use the regular
 *  registerClass() method.  This method is intended for framework code that might
 *  be maintaining specific ID maps across client and server.
 */
public static SerializerRegistration registerClassForId( short id, Class cls, Serializer serializer ) {
  if( locked ) {
    throw new RuntimeException("Serializer registry locked trying to register class:" + cls);
  }
  SerializerRegistration reg = new SerializerRegistration(serializer, cls, id);        
  idRegistrations.put(id, reg);
  classRegistrations.put(cls, reg);
  
  log.log( Level.FINE, "Registered class[" + id + "]:{0} to:" + serializer, cls );
  serializer.initialize(cls);
  // Add the class after so that dependency order is preserved if the
  // serializer registers its own classes.
  registrations.add(reg);
  return reg;    
}

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

private List<TextureOptionValue> parseTextureOptions(final List<String> values) {
  final List<TextureOptionValue> matchList = new ArrayList<TextureOptionValue>();
  if (values.isEmpty() || values.size() == 1) {
    return matchList;
  }
  // Loop through all but the last value, the last one is going to be the path.
  for (int i = 0; i < values.size() - 1; i++) {
    final String value = values.get(i);
    final TextureOption textureOption = TextureOption.getTextureOption(value);
    if (textureOption == null && !value.contains("\\") && !value.contains("/") && !values.get(0).equals("Flip") && !values.get(0).equals("Repeat")) {
      logger.log(Level.WARNING, "Unknown texture option \"{0}\" encountered for \"{1}\" in material \"{2}\"", new Object[]{value, key, material.getKey().getName()});
    } else if (textureOption != null){
      final String option = textureOption.getOptionValue(value);
      matchList.add(new TextureOptionValue(textureOption, option));
    }
  }
  return matchList;
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * See {@link #acquire(FilePath,boolean)}
 *
 * @param context
 *      Threads that share the same context can re-acquire the same lock (which will just increment the lock count.)
 *      This allows related executors to share the same workspace.
 */
public synchronized Lease acquire(@Nonnull FilePath p, boolean quick, Object context) throws InterruptedException {
  Entry e;
  Thread t = Thread.currentThread();
  String oldName = t.getName();
  t.setName("Waiting to acquire "+p+" : "+t.getName());
  try {
    while (true) {
      e = inUse.get(p);
      if (e==null || e.context==context)
        break;
      wait();
    }
  } finally {
    t.setName(oldName);
  }
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "acquired " + p + (e == null ? "" : " with lock count " + e.lockCount), new Throwable("from " + this));
  }
  
  if (e!=null)    e.lockCount++;
  else            inUse.put(p,new Entry(p,quick,context));
  return lease(p);
}

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

public Joystick[] loadJoysticks(InputManager inputManager){
  ControllerEnvironment ce =
    ControllerEnvironment.getDefaultEnvironment();
  Controller[] cs = ce.getControllers();
  
  List<Joystick> list = new ArrayList<Joystick>();
  for( Controller c : ce.getControllers() ) {
    if (c.getType() == Controller.Type.KEYBOARD
     || c.getType() == Controller.Type.MOUSE)
      continue;
    logger.log(Level.FINE, "Attempting to create joystick for: \"{0}\"", c);        
    // Try to create it like a joystick
    JInputJoystick stick = new JInputJoystick(inputManager, this, c, list.size(), c.getName()); 
    for( Component comp : c.getComponents() ) {
      stick.addComponent(comp);                   
    }
    // If it has no axes then we'll assume it's not
    // a joystick
    if( stick.getAxisCount() == 0 ) {
      logger.log(Level.FINE, "Not a joystick: {0}", c);
      continue;
    }
    joystickIndex.put(c, stick);
    list.add(stick);                      
  }
  joysticks = list.toArray( new JInputJoystick[list.size()] );
  
  return joysticks;
}

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

/**
 * Register a DetectorFactory.
 */
void registerDetector(DetectorFactory factory) {
  if (FindBugs.DEBUG) {
    System.out.println("Registering detector: " + factory.getFullName());
  }
  String detectorName = factory.getShortName();
  if(!factoryList.contains(factory)) {
    factoryList.add(factory);
  } else {
    LOGGER.log(Level.WARNING, "Trying to add already registered factory: " + factory +
        ", " + factory.getPlugin());
  }
  factoriesByName.put(detectorName, factory);
  factoriesByDetectorClassName.put(factory.getFullName(), factory);
}

代码示例来源:origin: jenkinsci/jenkins

args = args.subList(1, args.size());
    continue;
    args = args.subList(1, args.size());
    continue;
    args = args.subList(1, args.size());
    continue;
    for (Logger logger : new Logger[] {LOGGER, FullDuplexHttpStream.LOGGER, PlainCLIProtocol.LOGGER, Logger.getLogger("org.apache.sshd")}) { // perhaps also Channel
      logger.setLevel(level);
if(args.isEmpty())
  args = Arrays.asList("help"); // default to help
LOGGER.log(FINE, "using connection mode {0}", mode);
  factory = factory.basicAuth(userInfo);
} else if (auth != null) {
  factory = factory.basicAuth(auth.startsWith("@") ? FileUtils.readFileToString(new File(auth.substring(1))).trim() : auth);
        LOGGER.log(WARNING, null, e);
        return -1;
      LOGGER.log(FINE, null, e);

代码示例来源:origin: org.netbeans.api/org-openide-util

/**
 * Adds a <code>ChangeListener</code> to the listener list. The same
 * listener object may be added more than once, and will be called
 * as many times as it is added. If <code>listener</code> is null,
 * no exception is thrown and no action is taken.
 *
 * @param  listener the <code>ChangeListener</code> to be added.
 */
public void addChangeListener(ChangeListener listener) {
  if (listener == null) {
    return;
  }
  if (LOG.isLoggable(Level.FINE) && listeners.contains(listener)) {
    LOG.log(Level.FINE, "diagnostics for #167491", new IllegalStateException("Added " + listener + " multiply"));
  }
  listeners.add(listener);
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Releases an allocated or acquired workspace.
 */
private synchronized void _release(@Nonnull FilePath p) {
  Entry old = inUse.get(p);
  if (old==null)
    throw new AssertionError("Releasing unallocated workspace "+p);
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "releasing " + p + " with lock count " + old.lockCount, new Throwable("from " + this));
  }
  old.lockCount--;
  if (old.lockCount==0)
    inUse.remove(p);
  notifyAll();
}

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

public static void compile() {

  // Let's just see what they are here
  List<Registration> list = new ArrayList<Registration>();
  for( SerializerRegistration reg : Serializer.getSerializerRegistrations() ) {
    Class type = reg.getType();
    if( ignore.contains(type) )
      continue;
    if( type.isPrimitive() )
      continue;
    list.add(new Registration(reg));
  }
    
  if( log.isLoggable(Level.FINE) ) {
    log.log( Level.FINE, "Number of registered classes:{0}", list.size());
    for( Registration reg : list ) { 
      log.log( Level.FINE, "    {0}", reg);
    }
  }
  compiled = list.toArray(new Registration[list.size()]);
  
  INSTANCE = new SerializerRegistrationsMessage(compiled);  
  
  Serializer.setReadOnly(true);                              
}

代码示例来源:origin: jenkinsci/jenkins

warning = FormValidation.warning(e,String.format("Certificate %s is not yet valid in %s",cert.toString(),name));
    LOGGER.log(Level.FINE, "Add certificate found in json doc: \r\n\tsubjectDN: {0}\r\n\tissuer: {1}", new Object[]{c.getSubjectDN(), c.getIssuerDN()});
    certs.add(c);
if (certs.isEmpty()) {
  return FormValidation.error("No certificate found in %s. Cannot verify the signature", name);
      return resultSha512;
    case WARNING:
      LOGGER.log(Level.INFO, "JSON data source '" + name + "' does not provide a SHA-512 content checksum or signature. Looking for SHA-1.");
      break;
    case OK:
  LOGGER.log(Level.WARNING, "Failed to verify potential SHA-512 digest/signature, falling back to SHA-1", nsa);

代码示例来源:origin: jenkinsci/jenkins

continue; // taken care of by DependencyGraph
  jobs.add(job);
if (!jobs.isEmpty() && build.getResult().isBetterOrEqualTo(threshold)) {
  PrintStream logger = listener.getLogger();
  for (Job<?, ?> downstream : jobs) {
    if (Jenkins.getInstance().getItemByFullName(downstream.getFullName()) != downstream) {
      LOGGER.log(Level.WARNING, "Running as {0} cannot even see {1} for trigger from {2}", new Object[] {Jenkins.getAuthentication().getName(), downstream, build.getParent()});
      continue;
      listener.getLogger().println(Messages.BuildTrigger_you_have_no_permission_to_build_(ModelHyperlinkNote.encodeTo(downstream)));
      continue;
      logger.println(Messages.BuildTrigger_NotBuildable(ModelHyperlinkNote.encodeTo(downstream)));
      continue;
      logger.println(Messages.BuildTrigger_Disabled(ModelHyperlinkNote.encodeTo(downstream)));
      continue;

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

public void onAction(String name, boolean pressed, float tpf) {
    if (name.equals("save") && !pressed) {
      FileOutputStream fos = null;
      try {
        long start = System.currentTimeMillis();
        fos = new FileOutputStream(new File("terrainsave.jme"));
        // we just use the exporter and pass in the terrain
        BinaryExporter.getInstance().save((Savable)terrain, new BufferedOutputStream(fos));
        fos.flush();
        float duration = (System.currentTimeMillis() - start) / 1000.0f;
        System.out.println("Save took " + duration + " seconds");
      } catch (IOException ex) {
        Logger.getLogger(TerrainTestReadWrite.class.getName()).log(Level.SEVERE, null, ex);
      } finally {
        try {
          if (fos != null) {
            fos.close();
          }
        } catch (IOException e) {
          Logger.getLogger(TerrainTestReadWrite.class.getName()).log(Level.SEVERE, null, e);
        }
      }
    }
  }
};

代码示例来源:origin: jenkinsci/jenkins

/**
 * Just record that this workspace is being used, without paying any attention to the synchronization support.
 */
public synchronized Lease record(@Nonnull FilePath p) {
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "recorded " + p, new Throwable("from " + this));
  }
  Entry old = inUse.put(p, new Entry(p, false));
  if (old!=null)
    throw new AssertionError("Tried to record a workspace already owned: "+old);
  return lease(p);
}

代码示例来源:origin: javaee-samples/javaee7-samples

@Override
public String greet(String name) {
  try {
    System.out.println("context path (HttpServletRequest): " + httpServletRequest.getContextPath());
    System.out.println("session id: " + httpSession.getId());
    System.out.println("context path (ServletContext): " + servletContext.getContextPath());
    System.out.println("user transaction status: " + ut.getStatus());
    System.out.println("security principal: " + principal.getName());
  } catch (SystemException ex) {
    Logger.getLogger(SimpleGreeting.class.getName()).log(Level.SEVERE, null, ex);
  }
  return "Hello " + name;
}

相关文章