Package org.apache.log4j

Examples of org.apache.log4j.PatternLayout


            // send log output to a file
            String filename = commandLine.getOptionValue('f');
           
            try
            {
              Appender newAppender = new FileAppender(new PatternLayout("%d{ISO8601} %c{1}-%p: %m%n"), filename, true);
              newAppender.setName("ConsoleAppender");
              Logger.getRootLogger().removeAppender(con);
              Logger.getRootLogger().addAppender(newAppender);
              ci.out.println("> Logging to filename: " + filename);
            } catch (IOException e)
            {
              ci.out.println("> Unable to log to file: " + filename + ": " + e);
            }         
          }
          else
          {
            if( ! (con instanceof ConsoleAppender) )
            {
              Logger.getRootLogger().removeAppender(con);
              con = new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN));
              con.setName("ConsoleAppender");
                Logger.getRootLogger().addAppender(con);
            }
            // switch back to console appender
            ci.out.println("> Console logging on");
View Full Code Here


  }
 
  public static void initRootLogger() {
    if (Logger.getRootLogger().getAppender("ConsoleAppender")==null) {
      Appender app;
      app = new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN));
      app.setName("ConsoleAppender");
      app.addFilter( new DenyAllFilter() )//'log off' by default
      Logger.getRootLogger().addAppender(app);
    }
  }
View Full Code Here

    this.controlling   = false;
    this.br       = new CommandReader( new InputStreamReader( new ByteArrayInputStream(new byte[0])));
       
    if (Logger.getRootLogger().getAppender("ConsoleAppender")==null) {
        Appender app;
        app = new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN));
        app.setName("ConsoleAppender");
        app.addFilter( new DenyAllFilter() )//'log off' by default
        Logger.getRootLogger().addAppender(app);
      }
   
View Full Code Here

    super(arg0);
  }

  protected void setUp() throws Exception {
    super.setUp();
    fileAppender = new FileAppender(new PatternLayout("%r [%t] %p %c %x - %m%n"), "target/test-output/toto.log");

    existingHandlers = julRootLogger.getHandlers();
    for (int i = 0; i < existingHandlers.length; i++) {
      julRootLogger.removeHandler(existingHandlers[i]);
    }
View Full Code Here

     */
    private void initLogger(String pluginName) throws IOException
    {
        logger = AndroMDALogger.getNamespaceLogger(pluginName);
        logger.setAdditivity(false);
        FileAppender appender = new FileAppender(new PatternLayout("%-5p %d - %m%n"), AndroMDALogger
                .getNamespaceLogFileName(pluginName), true);
        logger.addAppender(appender);
    }
View Full Code Here

        logger = AndroMDALogger.getNamespaceLogger(pluginName);
        logger.setAdditivity(false);

        final FileAppender appender =
            new FileAppender(
                new PatternLayout("%-5p %d - %m%n"),
                AndroMDALogger.getNamespaceLogFileName(pluginName),
                true);
        logger.addAppender(appender);
    }
View Full Code Here

      PropertyConfigurator.configure(logConfigFileName);
    } else {
      ApplicationFiles appFiles = new ApplicationFiles();
     
      String logMessagePattern = "%-4r [%t] %-5p %c %x - %m%n";
      Layout layout = new PatternLayout(logMessagePattern);
     
      File logsDir = new File(appFiles.getUserSettingsDirectory(), "logs");
      File updateLogFile = new File(logsDir, "updater.log");
     
      FileAppender appender = new FileAppender(layout, updateLogFile.getAbsolutePath());
View Full Code Here

   * user-settings-dir launch option, this Appender hard-codes the location of the file so that it doesn't
   * need to be configured in two different places (squirrel-sql.sh and log4j.properties
   */
  public SquirrelFileSizeRollingAppender() throws IOException
  {
    super(new PatternLayout("%-4r [%t] %-5p %c %x - %m%n"),
        getLogFile().getAbsolutePath(), true);
    super.setMaxFileSize("1MB");
    super.setMaxBackupIndex(10);
  }
View Full Code Here

  /**
   * Default ctor.
   */
  public SquirrelAppender() throws IOException
  {
    super(new PatternLayout("%-4r [%t] %-5p %c %x - %m%n"),
        getLogFile().getAbsolutePath(), "'.'yyyy-ww");
  }
View Full Code Here

                consoleAppender.setThreshold(consoleThreshold);
                LOG.debug("Console LOG level set to " + consoleThreshold);
            }

            if (fileName != null) {
                PatternLayout layout = new PatternLayout("%d{ABSOLUTE} %-5p %x %m%n");
                FileAppender fileAppender = new FileAppender(layout, fileName, false);
                fileAppender.setName(FILE_APPENDER_NAME);
                Level fileThreshold = Level.toLevel(fileLevel, Level.DEBUG);
                fileAppender.setThreshold(fileThreshold);
                Logger.getRootLogger().addAppender(fileAppender);
View Full Code Here

TOP

Related Classes of org.apache.log4j.PatternLayout

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.