Exemplo n.º 1
0
 /**
  * Sets the Luntbuild HTML log.
  *
  * @param installDir the luntbuild installation directory
  * @throws IOException from {@link FileAppender#FileAppender(org.apache.log4j.Layout,
  *     java.lang.String, boolean)}
  */
 public final void setLuntbuildHtmlLog(Appender app) {
   if (app != null) {
     ((FileAppender) app)
         .setFile(
             new File(Luntbuild.installDir + "/logs/" + Luntbuild.log4jFileName)
                 .getAbsolutePath());
     ((FileAppender) app).activateOptions();
   } else {
     logger.warn("Can not find luntbuild_logfile appender, creating...");
     HTMLLayout layout = new HTMLLayout();
     layout.setTitle("Luntbuild System Log");
     layout.setLocationInfo(true);
     try {
       app =
           new FileAppender(
               layout,
               new File(Luntbuild.installDir + "/logs/" + Luntbuild.log4jFileName)
                   .getAbsolutePath(),
               true);
       ((FileAppender) app).setAppend(false);
       Logger log = LogManager.getLogger("com.luntsys.luntbuild");
       log.setLevel(Level.INFO);
       log.addAppender(app);
       ((FileAppender) app).activateOptions();
     } catch (Exception e) {
       logger.error("Can not create luntbuild_logfile appender");
     }
   }
 }
Exemplo n.º 2
0
  private static void initialize() {
    if (initialized) {
      return;
    }
    try {
      logger = Logger.getLogger("SE450");
      HTMLLayout layout = new HTMLLayout();
      layout.setTitle("Application Log File");
      FileOutputStream output = new FileOutputStream("AppLogFile.html");

      // Create the first Appender - for HTML file output
      WriterAppender htmlFileAppender = new WriterAppender(layout, output);
      String pattern = "%d{ISO8601}  %-5p %m %n";
      PatternLayout layout2 = new PatternLayout(pattern);

      // Create the second Appender - for Console file output
      ConsoleAppender consoleAppender = new ConsoleAppender(layout2);

      logger.addAppender(consoleAppender);
      logger.addAppender(htmlFileAppender);

    } catch (FileNotFoundException e) {
      e.printStackTrace();
      System.exit(0);
    }
    initialized = true;
  }