Package java.util.logging

Examples of java.util.logging.Logger


*/
public class JavaLogger implements org.teiid.logging.Logger {
 
  @Override
  public boolean isEnabled(String context, int msgLevel) {
    Logger logger = Logger.getLogger(context);
     
      Level javaLevel = convertLevel(msgLevel);
      return logger.isLoggable(javaLevel);
  }
View Full Code Here


      Level javaLevel = convertLevel(msgLevel);
      return logger.isLoggable(javaLevel);
  }

    public void log(int level, String context, Object msg) {
      Logger logger = Logger.getLogger(context);
     
      Level javaLevel = convertLevel(level);
    logger.log(javaLevel, msg.toString());
    }
View Full Code Here

      Level javaLevel = convertLevel(level);
    logger.log(javaLevel, msg.toString());
    }
   
    public void log(int level, String context, Throwable t, Object msg) {
      Logger logger = Logger.getLogger(context);
     
      Level javaLevel = convertLevel(level);
    logger.log(javaLevel, msg != null ? msg.toString() : null, t);
    }
View Full Code Here

     * @param sourceclass    the class that logs the message
     * @param sourcemethod  the method that logs the message
     * @param message    the message to print
     */
    public void log(Level level, String sourceclass, String sourcemethod, String message) {
      Logger  logger;
     
      logger = getLogger();
     
      if (logger != null)
        logger.logp(level, sourceclass, sourcemethod, message);
      else
  System.out.println(message);
    }
View Full Code Here

  {
    try
    {
      BufferedReader rd = new BufferedReader(
          new InputStreamReader(conn.getInputStream(), "UTF-8"));
      Logger logger = LogManager.getLogger();

      while(!stop)
      {
        AbstractCommand cmd = readNextCommand(rd);

        // If there is nothing to be read, wait for some time and then retry.
        if(cmd == null)
        {
          Thread.sleep(500);
          continue;
        }

        String msg = "Server: " + cmd.toString();
        if(!msg.endsWith("\n"))
          msg += '\n';
        logger.logp(Level.INFO, this.getClass().getName(), "run", msg);

        synchronized(buff)
        {
          buff.add(cmd);
          buff.notify();
View Full Code Here

   */
  public void run()
  {
    try
    {
      Logger logger = LogManager.getLogger();
      while(!stop)
      {
        AbstractCommand cmd;

        synchronized(buff)
        {
          if(buff.size() > 0)
            cmd = (AbstractCommand) buff.remove(0);
          else
          {
            buff.wait(500);
            continue;
          }
        }

        String msg = "Client: " + cmd.toString();
        if(!msg.endsWith("\n"))
          msg += '\n';
        logger.logp(Level.INFO, this.getClass().getName(), "run", msg);
        conn.write(cmd.toString().getBytes("UTF-8"));
        conn.flush();
      }
    }
    catch(IOException e)
View Full Code Here

  /**
   * The thread starts here.
   */
  public void run()
  {
    Logger logger = LogManager.getLogger();
    while(!quit)
    {
      Packet pack = null;

      try
      {
        pack = new Packet(conn);
      }
      catch(IOException e)
      {
        protocol.shutdown(e);
        return;
      }
      catch(IllegalArgumentException e)
      {
        /* very much unlikely that you will get this */
        continue;
      }

      String msg = "Server: " + pack.toString();
      logger.logp(Level.INFO, this.getClass().getName(), "run", msg);

      synchronized(buffer)
      {
        if(pack != null)
        {
View Full Code Here

  /**
   * The thread starts here.
   */
  public void run()
  {
    Logger logger = LogManager.getLogger();
    while(!quit)
    {
      Packet pack = null;

      synchronized(buffer)
      {
        try
        {
          if(buffer.size() > 0)
            pack = (Packet) buffer.remove(0);
          else
            buffer.wait(15000);
        }
        catch(InterruptedException e)
        {
          /* nothing to do here */
        }
      }

      try
      {
        if(pack != null)
        {
          String msg = "Client: " + pack.toString();
          logger.logp(Level.INFO, this.getClass().getName(), "run", msg);
       
          conn.write(pack.toBytes());
        }
      }
      catch(IOException e)
View Full Code Here

               Map map = this.property.getPropertiesForContextNode(this.contextNode, ContextNode.LOGGING_MARKER_TAG, "__default");
               String defVal = (String)map.get("__default");
               if (defVal != null) {
                  try {
                     Level defaultLevel = Level.parse(defVal);
                     Logger defLogger = logManager.getLogger("");
                     if (defLogger != null) {
                        defLogger.setLevel(defaultLevel);
                        log.info("Setting default log level to '" + defaultLevel.getName() + "'");
                     }
                     else
                        log.warning("Setting default log level to '" + defaultLevel.getName() + "' failed since default log level is null");
                  }
                  catch (Throwable ex) {
                     log.warning("An exception occured when parsing '" + defVal + "' as a log level");
                  }
               }
               Iterator iter = map.entrySet().iterator();

               Logger defLogger = logManager.getLogger("");
               // Handler[] tmpHandlers = defLogger.getHandlers();
               // Handler[] refHandlers = new Handler[tmpHandlers.length];
               Handler[] refHandlers = defLogger.getHandlers();
               for (int i=0; i < refHandlers.length; i++) {
                  refHandlers[i].setLevel(Level.FINEST);
                  Formatter formatter = refHandlers[i].getFormatter();
                  if (formatter instanceof XbFormatter) {
                     XbFormatter xb = (XbFormatter)formatter;
                     xb.setGlobal(this);
                  }
               }

               while (iter.hasNext()) {
                  Map.Entry entry = (Map.Entry)iter.next();
                  String key = (String)entry.getKey();
                  String val = (String)entry.getValue();
                  try {
                     Level level = Level.parse(val);
                     Logger tmpLogger = Logger.getLogger(key);
                     if (tmpLogger != null) {
                        tmpLogger.setLevel(level);
                        tmpLogger.setUseParentHandlers(false);
                        for (int i=0; i < refHandlers.length; i++) {
                           // handlers[i].setLevel(level);
                           tmpLogger.addHandler(refHandlers[i]);
                        }
                        log.info("Setting log level for '" + key + "' to '" + level.getName() + "'");
                     }
                     else
                        log.info("Setting log level for '" + key + "' to '" + level.getName() + "' failed since logger was null");
View Full Code Here

     * @param level For example "FINE"
     * @return The set level
     * @exception XmlBlasterException if your bool is strange
     */
   public Level changeLogLevel(String loggerName, Level level) throws XmlBlasterException {
      Logger logger = Logger.getLogger(loggerName);
      logger.setLevel(level);
      return level;
   }
View Full Code Here

TOP

Related Classes of java.util.logging.Logger

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.