Package org.apache.log4j

Examples of org.apache.log4j.WriterAppender$DefaultErrorHandler


        // setup the logger to capture all logs
        Layout layout =
            Logger.getRootLogger().getAppender("CONSOLE").getLayout();
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        WriterAppender appender = new WriterAppender(layout, os);
        appender.setThreshold(Level.WARN);
        Logger.getLogger(org.apache.zookeeper.server.quorum.QuorumPeer.class)
            .addAppender(appender);

        try {
            final int CLIENT_PORT_QP1 = 3181;
View Full Code Here


    {
      Logger log = Logger.getLogger("org.destecs.core.simulationengine.xmlrpc.client.CustomSAXParserTransportFactory$XmlRpcSun15HttpTransportCustomSAXReader");
      log.addAppender(new ConsoleAppender(new SimpleLayout()));
      try
      {
        log.addAppender(new WriterAppender(new SimpleLayout(), new FileWriter(new File(outputDirectory, "log_xmlrpc.txt"))));
      } catch (IOException e)
      {
      }

      log.setLevel(Level.DEBUG);
View Full Code Here

   * @param log the {@code Logger} to log to a stream
   * @param out {@code OutputStream} to which {@code AdWordsService}
   *     messages should be written
   */
  public static void logToStream(Logger log, OutputStream out) {
    WriterAppender appender = new WriterAppender(defaultPatternLayout, out);
    appender.setThreshold(Level.ALL);
    log.addAppender(appender);
  }
View Full Code Here

   * @param out {@code OutputStream} to which {@code AdWordsService}
   *     messages should be written
   * @param threshold the threshold for this stream
   */
  public static void logToStream(Logger log, OutputStream out, Level threshold) {
    WriterAppender appender = new WriterAppender(defaultPatternLayout, out);
    appender.setThreshold(threshold);
    log.addAppender(appender);
  }
View Full Code Here

  protected synchronized void run(WGACore core, Map customOptions, JobExecutionContext quartzContext, String executor) {

    Logger logger = Logger.getLogger("wga.job." + _name);
        logger.setLevel(Level.INFO);
    _currentLog = new StringWriter();
    WriterAppender tempAppender = new WriterAppender(JOBLOG_LAYOUT, _currentLog);
        logger.addAppender(tempAppender);
    _failed = false;
    _exception = null;
        _running = true;

    try {
      // Prepare logging
      _lastRun = new Date();

      if (_scheduler.getLoggingDir() != null) {
        initPermanentLog(logger);
      }

      // Prepare jobContext
      JobContext jobContext = new JobContext(this, quartzContext, core, logger);
      if (customOptions != null) {
        jobContext.getCustomOptions().putAll(customOptions);
      }

      // Run tasks
            if (executor != null) {
                logger.info("Starting job " + _name + " started by admin account '" + executor + "'");
            }
            else {
                logger.info("Starting job " + _name + " triggered by WGA Scheduler");
            }
      runTasks(logger, jobContext);

      logger.info("Job execution finished");
      if (jobContext.getResult() != null) {
        logger.info("End result: " + String.valueOf(jobContext.getResult()));
        _lastResult = jobContext.getResult();
      }
    }
    catch (Exception e) {
      logger.error("Exception executing job", e);
      _exception = e;
      _failed = true;
    }
    catch (Error e) {
      logger.error("Error executing job", e);
      _exception = e;
      _failed = true;
    }
    finally {

     
      // We switch off stats on the currently registered job of this name
      Job currentJob = _scheduler.getJob(_name);
      closeStats(logger, currentJob);
      if (currentJob != this) {
          closeStats(logger, this);
      }
            if (tempAppender != null) {
                tempAppender.close();
                logger.removeAppender(tempAppender);
            }
    }

  }
View Full Code Here

    private WriterAppender _appender;

    public AppLogTailHandler(WGACore core) {
        _core = core;
        _listWriter = new LineBufferWriter();
        _appender = new WriterAppender(WGACore.LAYOUT_APPLOG, _listWriter);
        _core.getLog().addAppender(_appender);
    }
View Full Code Here

   * @param log the {@code Logger} to log to a stream
   * @param out {@code OutputStream} to which {@code DfpService}
   *            messages should be written
   */
  public static void logToStream(Logger log, OutputStream out) {
    WriterAppender appender = new WriterAppender(defaultPatternLayout, out);
    appender.setThreshold(Level.ALL);
    log.addAppender(appender);
  }
View Full Code Here

   * @param out {@code OutputStream} to which {@code DfpService}
   *            messages should be written
   * @param threshold the threshold for this stream
   */
  public static void logToStream(Logger log, OutputStream out, Level threshold) {
    WriterAppender appender = new WriterAppender(defaultPatternLayout, out);
    appender.setThreshold(threshold);
    log.addAppender(appender);
  }
View Full Code Here

    // Default log4j configuration
    {
      Logger rootLogger = Logger.getRootLogger();
      rootLogger.setLevel(Level.ERROR);
      rootLogger.addAppender(new WriterAppender(new PatternLayout("%d{ISO8601}[%-5p]: %m%n"),globalSettings.getErrStream()));
    }
   
    // Compute needed file paths
    {
      File installDir = PathComputer.computeInstallDir();
View Full Code Here

    // Default log4j configuration
    {
      Logger rootLogger = Logger.getRootLogger();
      rootLogger.setLevel(Level.ERROR);
      rootLogger.addAppender(new WriterAppender(new PatternLayout("%d{ISO8601}[%-5p]: %m%n"),globalSettings.getErrStream()));
    }
   
    // Compute needed file paths
    {
      File installDir = PathComputer.computeInstallDir();
View Full Code Here

TOP

Related Classes of org.apache.log4j.WriterAppender$DefaultErrorHandler

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.