Package org.apache.log4j

Examples of org.apache.log4j.PatternLayout


    setupLogging(true, "", logLevel);
  }

  public static void setupLogging(boolean logToConsole, String fileLogPath, Level logLevel)
  {
    PatternLayout defaultLayout = new PatternLayout("%d{ISO8601} [%t] (%p) {%c{1}} %m%n");
    Logger.getRootLogger().removeAllAppenders();

    if (logToConsole)
    {
      ConsoleAppender defaultAppender = new ConsoleAppender(defaultLayout);
View Full Code Here


     * withheld log output
     */
    public static WithholdingAppender install() {
        LogManager.getRootLogger().removeAllAppenders();
        final WithholdingAppender withholdingAppender = new WithholdingAppender(
                new PatternLayout("%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m\n"));
        LogManager.getRootLogger().addAppender(withholdingAppender);
        return withholdingAppender;
    }
View Full Code Here

    protected Kernel kernel;

    protected void setUp() throws Exception {
        Logger.getRootLogger().setLevel(Level.WARN);
        Logger.getRootLogger().addAppender(new ConsoleAppender(new PatternLayout("%p [%t] %m %n")));
        super.setUp();
        kernel = KernelFactory.newInstance().createKernel(DOMAIN);
        kernel.boot();

        ClassLoader classLoader = getClass().getClassLoader();
View Full Code Here

  public static void main(String[] args) throws Exception
  {
    parseArgs(args);

    PatternLayout defaultLayout = new PatternLayout("%d{ISO8601} +%r [%t] (%p) {%c{1}} %m%n");
    ConsoleAppender defaultAppender = new ConsoleAppender(defaultLayout);

    Logger.getRootLogger().removeAllAppenders();
    Logger.getRootLogger().addAppender(defaultAppender);
View Full Code Here

        PropertyConfigurator.configure(log4jPropFile);
        LOG.info("Using custom logging settings from file " + log4jPropFile);
      }
      else
      {
        PatternLayout defaultLayout = new PatternLayout("%d{ISO8601} +%r [%t] (%p) {%c{1}} %m%n");
        ConsoleAppender defaultAppender = new ConsoleAppender(defaultLayout);

        Logger.getRootLogger().removeAllAppenders();
        Logger.getRootLogger().addAppender(defaultAppender);
View Full Code Here

  // also (to save disk space and improve readability) - use simplified log format
  public void printVerboseString(Logger log, Level l)
  {
    // create a temp logger with simplified message
    //PatternLayout defaultLayout = new PatternLayout("%d{ISO8601} +%r [%t] (%p) {%c} %m%n");
    PatternLayout defaultLayout = new PatternLayout("%m%n");
    ConsoleAppender defaultAppender = new ConsoleAppender(defaultLayout);
    Logger newLog = Logger.getLogger("Simple");
    newLog.removeAllAppenders();
    newLog.addAppender(defaultAppender);
    newLog.setAdditivity(false);
View Full Code Here

      PropertyConfigurator.configure(log4jPropFile);
      LOG.info("Using custom logging settings from file " + log4jPropFile);
    }
    else
    {
      PatternLayout defaultLayout = new PatternLayout("%d{ISO8601} +%r [%t] (%p) {%c} %m%n");
      ConsoleAppender defaultAppender = new ConsoleAppender(defaultLayout);

      Logger.getRootLogger().removeAllAppenders();
      Logger.getRootLogger().addAppender(defaultAppender);
View Full Code Here

        PropertyConfigurator.configure(log4jPropFile);
        LOG.info("Using custom logging settings from file " + log4jPropFile);
      }
      else
      {
        PatternLayout defaultLayout = new PatternLayout("%d{ISO8601} +%r [%t] (%p) {%c} %m%n");
        ConsoleAppender defaultAppender = new ConsoleAppender(defaultLayout);

        Logger.getRootLogger().removeAllAppenders();
        Logger.getRootLogger().addAppender(defaultAppender);
View Full Code Here

        PropertyConfigurator.configure(log4jPropFile);
        LOG.info("Using custom logging settings from file " + log4jPropFile);
      }
      else
      {
        PatternLayout defaultLayout = new PatternLayout("%d{ISO8601} +%r [%t] (%p) {%c} %m%n");
        ConsoleAppender defaultAppender = new ConsoleAppender(defaultLayout);

        Logger.getRootLogger().removeAllAppenders();
        Logger.getRootLogger().addAppender(defaultAppender);
        Logger.getRootLogger().setLevel(Level.INFO)//using info as the default log level
View Full Code Here

        PropertyConfigurator.configure(log4jPropFile);
        LOG.info("Using custom logging settings from file " + log4jPropFile);
      }
      else
      {
        PatternLayout defaultLayout = new PatternLayout("%d{ISO8601} +%r [%t] (%p) {%c} %m%n");
        ConsoleAppender defaultAppender = new ConsoleAppender(defaultLayout);

        Logger.getRootLogger().removeAllAppenders();
        Logger.getRootLogger().addAppender(defaultAppender);
        Logger.getRootLogger().setLevel(Level.INFO)//using info as the default log level
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.