Java Code Examples for org.apache.log4j.Logger

The following are top voted examples for showing how to use org.apache.log4j.Logger. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: voicemenu   File: Command_TransformationMenu.java   Source Code and License 6 votes vote down vote up
@Nullable
protected TransformationMenuItem createItem(TransformationMenuContext context) {
  Command_TransformationMenu.TMP_SubMenu_8e2zmm_a0.TMP_Action_8e2zmm_b0a.Item item = new Command_TransformationMenu.TMP_SubMenu_8e2zmm_a0.TMP_Action_8e2zmm_b0a.Item(context);
  String description;
  try {
    description = "single item: " + item.getLabelText("");
  } catch (Throwable t) {
    Logger.getLogger(getClass()).error("Exception while executing getText of the item " + item, t);
    return null;
  }
  context.getEditorMenuTrace().pushTraceInfo();
  try {
    context.getEditorMenuTrace().setDescriptor(new EditorMenuDescriptorBase(description, new SNodePointer("r:7c1e5bbb-2d18-4cf3-a11d-502be6b13261(jetbrains.mps.samples.VoiceMenu.editor)", "7229855446159341697")));
    item.setTraceInfo(context.getEditorMenuTrace().getTraceInfo());
  } finally {
    context.getEditorMenuTrace().popTraceInfo();
  }
  return item;
}
 
Example 2
Project: SPLGroundControl   File: SPLGroungControlTest.java   Source Code and License 6 votes vote down vote up
@BeforeClass
public static void setUpClass() throws Exception {
    //Configure log4j
    ConsoleAppender console = new ConsoleAppender(); 
    String PATTERN = "%d [%p|%c|%C{1}] %m%n";
    console.setLayout(new PatternLayout(PATTERN)); 
    console.setThreshold(Level.DEBUG);
    console.activateOptions();

    Logger.getRootLogger().addAppender(console);

    System.out.println("SETUP: Starting SPLGroundControl...");
    config.init(args);

    daemon.init(new SPLGroundControl.SPLDaemonContext(args));
    daemon.start();
}
 
Example 3
Project: Drones-Simulator   File: RuleProcessors.java   Source Code and License 6 votes vote down vote up
@Override
public void run() {
    Logger.getLogger(RuleProcessors.class).info("Started RuleProcessors");
    while(!this.isInterrupted()) {
        GameEngineEvent msg;
        try {
            msg = incomingEvents.take();
        } catch (InterruptedException e) {
            Logger.getLogger(RuleProcessors.class).error("Interrupted while waiting for incoming event");
            this.interrupt();
            break;
        }

        if(msg != null) {
            this.processEventsForRules(Collections.singletonList(msg));
        } else {
            Logger.getLogger(RuleProcessors.class).error("Received event on incoming queue but was null!");
        }
    }

    Logger.getLogger(RuleProcessors.class).info("Ruleprocessors is shut down!");
}
 
Example 4
Project: voicemenu   File: Command_TransformationMenu.java   Source Code and License 6 votes vote down vote up
@Nullable
protected TransformationMenuItem createItem(TransformationMenuContext context) {
  Command_TransformationMenu.TMP_SubMenu_8e2zmm_a2.TMP_Action_8e2zmm_g0c.Item item = new Command_TransformationMenu.TMP_SubMenu_8e2zmm_a2.TMP_Action_8e2zmm_g0c.Item(context);
  String description;
  try {
    description = "single item: " + item.getLabelText("");
  } catch (Throwable t) {
    Logger.getLogger(getClass()).error("Exception while executing getText of the item " + item, t);
    return null;
  }
  context.getEditorMenuTrace().pushTraceInfo();
  try {
    context.getEditorMenuTrace().setDescriptor(new EditorMenuDescriptorBase(description, new SNodePointer("r:7c1e5bbb-2d18-4cf3-a11d-502be6b13261(jetbrains.mps.samples.VoiceMenu.editor)", "4660170996528419196")));
    item.setTraceInfo(context.getEditorMenuTrace().getTraceInfo());
  } finally {
    context.getEditorMenuTrace().popTraceInfo();
  }
  return item;
}
 
Example 5
Project: Rubus   File: GraphOutput.java   Source Code and License 6 votes vote down vote up
/**
   * Convenience method for outputting graph for a method to a given file.
   *
   * @param method  Method to output.
   * @param file    File for output.
   */
  public static void outputMethod(Method method, File file) {
    if(method.getImplementation() != null) {
      try {
        PrintStream outPS = new PrintStream(file);
        GraphOutput cfo = new GraphOutput(outPS);


        DebugUtil.printProperties(outPS);
//        DebugUtil.printNodeDiscription(outPS);

        method.getImplementation().accept(cfo);
        cfo.end();

        Logger.getLogger("diagrams").info("Diagram for " + method + " outputed to " + file + ".");
      } catch(IOException io) {
        Logger.getLogger("diagrams").warn("Could not output diagram to " + file + ".");
      }
    }
  }
 
Example 6
Project: hadoop   File: TaskLog.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static synchronized void syncLogs() {
  // flush standard streams
  //
  System.out.flush();
  System.err.flush();

  // flush flushable appenders
  //
  final Logger rootLogger = Logger.getRootLogger();
  flushAppenders(rootLogger);
  final Enumeration<Logger> allLoggers = rootLogger.getLoggerRepository().
    getCurrentLoggers();
  while (allLoggers.hasMoreElements()) {
    final Logger l = allLoggers.nextElement();
    flushAppenders(l);
  }
}
 
Example 7
Project: voicemenu   File: Activity_TransformationMenu.java   Source Code and License 6 votes vote down vote up
@Nullable
protected TransformationMenuItem createItem(TransformationMenuContext context) {
  Activity_TransformationMenu.TMP_SubMenu_rgk9zw_a2.TMP_Action_rgk9zw_a0c.Item item = new Activity_TransformationMenu.TMP_SubMenu_rgk9zw_a2.TMP_Action_rgk9zw_a0c.Item(context);
  String description;
  try {
    description = "single item: " + item.getLabelText("");
  } catch (Throwable t) {
    Logger.getLogger(getClass()).error("Exception while executing getText of the item " + item, t);
    return null;
  }
  context.getEditorMenuTrace().pushTraceInfo();
  try {
    context.getEditorMenuTrace().setDescriptor(new EditorMenuDescriptorBase(description, new SNodePointer("r:7c1e5bbb-2d18-4cf3-a11d-502be6b13261(jetbrains.mps.samples.VoiceMenu.editor)", "8720745441970485769")));
    item.setTraceInfo(context.getEditorMenuTrace().getTraceInfo());
  } finally {
    context.getEditorMenuTrace().popTraceInfo();
  }
  return item;
}
 
Example 8
Project: worm   File: HbaseConnectionWarehouse.java   Source Code and License 6 votes vote down vote up
private HbaseConnectionWarehouse() {
	conns = new LinkedList<>();
	logger = Logger.getLogger(HbaseConnectionWarehouse.class);  // logger
	conf = HBaseConfiguration.create();							// configuration
	
	Properties properties = new Properties();
	try {
		properties.load(new FileInputStream("/home/xwtech/configuration/configuration.properties"));
	} catch (Exception e) {
		logger.error("读取properties文件出错!\n"+e.getMessage());
	} 
	maxSize = Integer.parseInt(properties.getProperty("hbaseConnectionMaxsize", "5"));
	String quorum = properties.getProperty("hbaseZookeeperQuorum", "n1.cluster,n2.cluster,n3.cluster");
	
	conf.set("hbase.zookeeper.quorum", quorum);
	
	currentSize = 0;
	usableSize = 0;
}
 
Example 9
Project: ats-framework   File: StartCheckpointEvent.java   Source Code and License 6 votes vote down vote up
public StartCheckpointEvent( String fqnOfCategoryClass,
                             Logger logger,
                             String name,
                             String transferUnit,
                             String threadName,
                             long startTimestamp ) {

    super(fqnOfCategoryClass,
          logger,
          "Start checkpoint '" + name + "'",
          LoggingEventType.START_CHECKPOINT);

    this.startTimestamp = startTimestamp;
    this.name = name;
    this.transferUnit = transferUnit;
    this.threadName = threadName;
}
 
Example 10
Project: DIA-Umpire-Maven   File: UmpireSpecLibMatch.java   Source Code and License 6 votes vote down vote up
@Override
public void run() {
    if (fragmentLib != null) {
        if (IdentifiedPeptideIon) {
            IDPeak();
        } else {
            Target();
            if (decoyfragmentLib != null) {
                Decoy();
            } else {
                Logger.getRootLogger().error("decoy spectrum is null : " + pepIonID.GetKey());
            }
        }
    } else {
        Logger.getRootLogger().warn("lib spectrum is null : " + pepIonID.GetKey());
    }
}
 
Example 11
Project: ibench   File: iBenchDriver.java   Source Code and License 6 votes vote down vote up
private static void setUpConfigLogger(File pathF, String configName) throws IOException {
	Logger.getRootLogger().removeAllAppenders();
	
	String nameSuffix = configName.replace(".txt", "");
	
	PropertyConfigurator.configure("resource/log4jproperties.txt");	
	
	FileAppender logFileAppender = new FileAppender(
			new PatternLayout("%-4r [%t] %-5p %c %x - %m%n"),
			new File(pathF, "log_" + nameSuffix + ".txt").toString(), false);
	Logger.getRootLogger().addAppender(logFileAppender);
	
	if (opt.logToConsole)
		Logger.getRootLogger().addAppender(new ConsoleAppender(
				new PatternLayout("%-4r [%t] %-5p %c %x - %m%n")));
}
 
Example 12
Project: DIA-Umpire-Maven   File: LCMSPeakDIAMS2.java   Source Code and License 6 votes vote down vote up
private boolean FSCluster2CurveUnfragRead() {
    if (!new File(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_UnfClus2Cur.serFS").exists()) {
        return false;
    }
    try {
        Logger.getRootLogger().debug("Reading UnfragPrecursorFragCorr serialization from file:" + FilenameUtils.getBaseName(ScanCollectionName) + "_UnfClus2Cur.serFS...");
        FileInputStream fileIn = new FileInputStream(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_UnfClus2Cur.serFS");
        FSTObjectInput in = new FSTObjectInput(fileIn);
        UnFragIonClu2Cur = (HashMap<Integer, ArrayList<PrecursorFragmentPairEdge>>) in.readObject();
        in.close();
        fileIn.close();

    } catch (Exception ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
        return false;
    }
    return true;
}
 
Example 13
Project: ats-framework   File: UpdateTestcaseEvent.java   Source Code and License 6 votes vote down vote up
public UpdateTestcaseEvent( String loggerFQCN, Logger logger, int testcaseId, String suiteFullName,
                            String suiteSimpleName, String scenarioName, String inputArguments,
                            String scenarioDescription, String userNote, int testcaseResult,
                            long timestamp ) {

    super(loggerFQCN, logger,
          "Update testcase with id '" + testcaseId + "'",
          suiteFullName, suiteSimpleName, scenarioName, inputArguments, scenarioDescription,
          LoggingEventType.UPDATE_TEST_CASE);

    this.testcaseId = testcaseId;
    this.testcaseResult = testcaseResult;
    this.userNote = userNote;

    if (StringUtils.isNullOrEmpty(scenarioName) || StringUtils.isNullOrEmpty(inputArguments)) {

        this.testcaseName = null;
    }

}
 
Example 14
Project: voicemenu   File: Timeout_TransformationMenu.java   Source Code and License 6 votes vote down vote up
@Nullable
protected TransformationMenuItem createItem(TransformationMenuContext context) {
  Timeout_TransformationMenu.TMP_SubMenu_4a1v5f_b0.TMP_Action_4a1v5f_b1a.Item item = new Timeout_TransformationMenu.TMP_SubMenu_4a1v5f_b0.TMP_Action_4a1v5f_b1a.Item(context);
  String description;
  try {
    description = "single item: " + item.getLabelText("");
  } catch (Throwable t) {
    Logger.getLogger(getClass()).error("Exception while executing getText of the item " + item, t);
    return null;
  }
  context.getEditorMenuTrace().pushTraceInfo();
  try {
    context.getEditorMenuTrace().setDescriptor(new EditorMenuDescriptorBase(description, new SNodePointer("r:7c1e5bbb-2d18-4cf3-a11d-502be6b13261(jetbrains.mps.samples.VoiceMenu.editor)", "8455589616271350507")));
    item.setTraceInfo(context.getEditorMenuTrace().getTraceInfo());
  } finally {
    context.getEditorMenuTrace().popTraceInfo();
  }
  return item;
}
 
Example 15
Project: voicemenu   File: Event_TransformationMenu.java   Source Code and License 6 votes vote down vote up
@Nullable
protected TransformationMenuItem createItem(TransformationMenuContext context) {
  Event_TransformationMenu.TMP_SubMenu_8shh52_a4.TMP_Action_8shh52_b0e.Item item = new Event_TransformationMenu.TMP_SubMenu_8shh52_a4.TMP_Action_8shh52_b0e.Item(context);
  String description;
  try {
    description = "single item: " + item.getLabelText("");
  } catch (Throwable t) {
    Logger.getLogger(getClass()).error("Exception while executing getText of the item " + item, t);
    return null;
  }
  context.getEditorMenuTrace().pushTraceInfo();
  try {
    context.getEditorMenuTrace().setDescriptor(new EditorMenuDescriptorBase(description, new SNodePointer("r:7c1e5bbb-2d18-4cf3-a11d-502be6b13261(jetbrains.mps.samples.VoiceMenu.editor)", "5283568769195041136")));
    item.setTraceInfo(context.getEditorMenuTrace().getTraceInfo());
  } finally {
    context.getEditorMenuTrace().popTraceInfo();
  }
  return item;
}
 
Example 16
Project: ibench   File: iBenchDriver.java   Source Code and License 6 votes vote down vote up
private static void setUpExperimentalLogger(File pathF) throws IOException {
	
	Logger.getRootLogger().removeAllAppenders();
	log.removeAllAppenders();
	
	PropertyConfigurator.configure("resource/log4jproperties.txt");
	
	FileAppender resultAppender = new FileAppender(
			new PatternLayout("%m"),
			new File(pathF, "result.txt").toString(), false);
	
	LevelRangeFilter infoFilter = new LevelRangeFilter();
	infoFilter.setLevelMin(Level.INFO);
	infoFilter.setLevelMax(Level.FATAL);
	infoFilter.setAcceptOnMatch(true);
	resultAppender.addFilter(infoFilter);
	log.addAppender(resultAppender);
	Logger.getLogger(iBench.class).addAppender(resultAppender);
	
}
 
Example 17
Project: voicemenu   File: Activity_TransformationMenu.java   Source Code and License 6 votes vote down vote up
@Nullable
protected TransformationMenuItem createItem(TransformationMenuContext context) {
  Activity_TransformationMenu.TMP_SubMenu_rgk9zw_a0.TMP_Action_rgk9zw_b0a.Item item = new Activity_TransformationMenu.TMP_SubMenu_rgk9zw_a0.TMP_Action_rgk9zw_b0a.Item(context);
  String description;
  try {
    description = "single item: " + item.getLabelText("");
  } catch (Throwable t) {
    Logger.getLogger(getClass()).error("Exception while executing getText of the item " + item, t);
    return null;
  }
  context.getEditorMenuTrace().pushTraceInfo();
  try {
    context.getEditorMenuTrace().setDescriptor(new EditorMenuDescriptorBase(description, new SNodePointer("r:7c1e5bbb-2d18-4cf3-a11d-502be6b13261(jetbrains.mps.samples.VoiceMenu.editor)", "8720745441960649988")));
    item.setTraceInfo(context.getEditorMenuTrace().getTraceInfo());
  } finally {
    context.getEditorMenuTrace().popTraceInfo();
  }
  return item;
}
 
Example 18
Project: Babler   File: LanguageClassifier.java   Source Code and License 5 votes vote down vote up
/**
 * Generates a list of support languages by this classifier
 * @param langs a list of language names (not codes). For example English, Hebrew, Spanish
 */
protected void buildListOfSupportedLanguageCodesFromLanguageNames(String [] langs){
    this.supportedLanguages = new ArrayList<>();
     Logger log = Logger.getLogger(LanguageClassifier.class);
    for(String lang : langs){
        try {
            supportedLanguages.add(LanguageCode.convertLanguageNameToCode(lang));
        } catch (Exception e) {
            log.error(e);
        }
    }
}
 
Example 19
Project: Rubus   File: AnnotationImporter.java   Source Code and License 5 votes vote down vote up
/**
 * Sets the value for enum methods/values.
 *
 * @param key    Method to set.
 * @param type   Name of the enum class type.
 * @param value  Value for method.
 */
@Override
public void visitEnum(String key, String type, String value) {
  try {
    annotation.set(key, Enum.valueOf(
      (Class<? extends Enum>) Class.forName(Type.getType(type).getClassName()),
      value
    ));
  } catch (ClassNotFoundException ex) {
    Logger.getLogger("annotation").log(Level.FATAL, null, ex);
  }
}
 
Example 20
Project: hadoop   File: TestYarnClient.java   Source Code and License 5 votes vote down vote up
@Test(timeout = 30000)
public void testApplicationType() throws Exception {
  Logger rootLogger = LogManager.getRootLogger();
  rootLogger.setLevel(Level.DEBUG);
  MockRM rm = new MockRM();
  rm.start();
  RMApp app = rm.submitApp(2000);
  RMApp app1 =
      rm.submitApp(200, "name", "user",
        new HashMap<ApplicationAccessType, String>(), false, "default", -1,
        null, "MAPREDUCE");
  Assert.assertEquals("YARN", app.getApplicationType());
  Assert.assertEquals("MAPREDUCE", app1.getApplicationType());
  rm.stop();
}
 
Example 21
Project: incubator-servicecomb-java-chassis   File: Log4JMetricsFileWriter.java   Source Code and License 5 votes vote down vote up
@Override
public void write(String loggerName, String filePrefix, String content) {
  RollingFileAppender logger = fileAppenders.computeIfAbsent(loggerName, f -> initLogger(loggerName, filePrefix));
  LoggingEvent event = new LoggingEvent(loggerName, Logger.getLogger(loggerName), Level.ALL,
      content, null);
  logger.append(event);
}
 
Example 22
Project: ditb   File: LogMonitoring.java   Source Code and License 5 votes vote down vote up
public static Set<File> getActiveLogFiles() throws IOException {
  Set<File> ret = Sets.newHashSet();
  Appender a;
  @SuppressWarnings("unchecked")
  Enumeration<Appender> e = Logger.getRootLogger().getAllAppenders();
  while (e.hasMoreElements()) {
    a = e.nextElement();
    if (a instanceof FileAppender) {
      FileAppender fa = (FileAppender) a;
      String filename = fa.getFile();
      ret.add(new File(filename));
    }
  }
  return ret;
}
 
Example 23
Project: siddhi-map-json   File: JsonSourceMapperTestCase.java   Source Code and License 5 votes vote down vote up
@Test
public void jsonSourceMapper20() throws InterruptedException {
    log.info("test JsonSourceMapper with test Test values type boolean");
    log = Logger.getLogger(JsonSourceMapper.class);
    UnitTestAppender appender = new UnitTestAppender();
    log.addAppender(appender);
    String streams = "" +
            "@App:name('TestSiddhiApp')" +
            "@source(type='inMemory', topic='stock', @map(type='json')) " +
            "define stream FooStream (symbol Bool, price double, volume int); " +
            "define stream BarStream (symbol Bool, price double, volume int); ";
    String query = "" +
            "from FooStream " +
            "select * " +
            "insert into BarStream; ";
    SiddhiManager siddhiManager = new SiddhiManager();
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);

    siddhiAppRuntime.start();
    InMemoryBroker.publish("stock", " {\n" +
            "      \"event\":{\n" +
            "         \"symbol\":\"true\",\n" +
            "         \"price\":55,\n" +
            "         \"volume\":100.0\n" +
            "      }\n" +
            " }");
    AssertJUnit.assertTrue(appender.getMessages().contains("contains incompatible attribute types and values"));
    siddhiAppRuntime.shutdown();
}
 
Example 24
Project: DIA-Umpire-Maven   File: DIA_Setting.java   Source Code and License 5 votes vote down vote up
public void WriteDIASettingSerialization(String mzXMLFileName) {
    try {
        Logger.getRootLogger().info("Writing DIA setting to file:" + FilenameUtils.getFullPath(mzXMLFileName) + FilenameUtils.getBaseName(mzXMLFileName) + "_diasetting.ser...");
        FileOutputStream fout = new FileOutputStream(FilenameUtils.getFullPath(mzXMLFileName) + FilenameUtils.getBaseName(mzXMLFileName) + "_diasetting.ser", false);
        ObjectOutputStream oos = new ObjectOutputStream(fout);
        oos.writeObject(this);
        oos.close();
        fout.close();
    } catch (Exception ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
    }
}
 
Example 25
Project: ibench   File: iBench.java   Source Code and License 5 votes vote down vote up
/**
 *  read log4j properties from user defined location or default location
 * @throws FileNotFoundException 
 */
public void reconfigLog() throws FileNotFoundException {
	File location = _configuration.getLogConfig();
	Level llevel = _configuration.loglevel;
	Logger.getRootLogger().removeAllAppenders();
	progressAndResultLog.setAdditivity(false);
	
	// user provided log location?
	if (location != null) {
		if (!location.exists())
		{
			System.err.printf("User provided log location does not exist: %s", location);
			System.exit(1);
		}
		PropertyConfigurator.configure(new FileInputStream(location));
		log.info("user has provided log level location: " +  location);
	}
	// user has given a global log level
	else if (llevel != null) {
		ConsoleAppender c = new ConsoleAppender();
		c.setLayout(new PatternLayout("%-4r [%t] %-5p %l - %m%n"));
		c.setThreshold(llevel);
		c.activateOptions();
		Logger.getRootLogger().addAppender(c);			
	
		log.info("user set log level to " + llevel.toString());
	}
	// do we have a log file at the default location
	else if (new File(LOG4JPROPERIES_DEFAULT_LOCATION).exists())
	{
		defaultLogPropertyFileConfig();
		log.info("use default log properties location " + LOG4JPROPERIES_DEFAULT_LOCATION);
	}
	// just set everything to error log level
	else {
		defaultLogConfig();
	}
	
	outputLog(llevel == null ? Level.INFO : llevel);	
}
 
Example 26
Project: ripme   File: AbstractRipper.java   Source Code and License 5 votes vote down vote up
/**
 * Notifies observers and updates state if all files have been ripped.
 */
void checkIfComplete() {
    if (observer == null) {
        logger.debug("observer is null");
        return;
    }

    if (!completed) {
        completed = true;
        logger.info("   Rip completed!");

        RipStatusComplete rsc = new RipStatusComplete(workingDir, getCount());
        RipStatusMessage msg = new RipStatusMessage(STATUS.RIP_COMPLETE, rsc);
        observer.update(this, msg);

        Logger rootLogger = Logger.getRootLogger();
        FileAppender fa = (FileAppender) rootLogger.getAppender("FILE");
        if (fa != null) {
            logger.debug("Changing log file back to 'ripme.log'");
            fa.setFile("ripme.log");
            fa.activateOptions();
        }
        if (Utils.getConfigBoolean("urls_only.save", false)) {
            String urlFile = this.workingDir + File.separator + "urls.txt";
            try {
                Desktop.getDesktop().open(new File(urlFile));
            } catch (IOException e) {
                logger.warn("Error while opening " + urlFile, e);
            }
        }
    }
}
 
Example 27
Project: gmusic-java   File: Utils.java   Source Code and License 5 votes vote down vote up
/**
 * Singleton pattern for logger
 * Adds a <code>ConsoleAppender</code> on initialization
 * @return <code>Logger</code>
 */
public static Logger getLogger() {
    if(logger == null) {
        logger = Logger.getRootLogger();
        ConsoleAppender appender = new ConsoleAppender();

        appender.setLayout(new PatternLayout("[%-5p] %d{HH:mm:ss.SSS} [%t] - %m %n"));
        appender.setThreshold(Level.ALL);
        appender.activateOptions();
        logger.addAppender(appender);
    }
    return logger;
}
 
Example 28
Project: s-store   File: RingBufferAppender.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static Collection<String> getLoggingMessages(LoggerRepository repo) {
    Set<RingBufferAppender> appenders = new HashSet<RingBufferAppender>();
    for (Object o : CollectionUtil.iterable(repo.getCurrentLoggers())) {
        Logger logger = (Logger)o;
        RingBufferAppender rba = getRingBufferAppender(logger);
        if (rba != null) {
             if (LOG.isDebugEnabled())
                LOG.debug(logger.getName() + " => " + rba + " / " + rba.getLayout());
            appenders.add(rba);
        }
    } // FOR
    if (appenders.isEmpty()) return (Collections.emptyList());
    return (getLoggingMessages(appenders.toArray(new RingBufferAppender[0]))); 
}
 
Example 29
Project: ats-framework   File: RememberLoadQueueStateEvent.java   Source Code and License 5 votes vote down vote up
public RememberLoadQueueStateEvent( String loggerFQCN, Logger logger, String name, int loadQueueId,
                                    String threadingPattern, int numberThreads ) {

    super(loggerFQCN, logger, "Remember load queue '" + name + "' state",
          LoggingEventType.REMEMBER_LOADQUEUE_STATE);

    this.name = name;
    this.loadQueueId = loadQueueId;
    this.threadingPattern = threadingPattern;
    this.numberThreads = numberThreads;
}
 
Example 30
Project: convertigo-engine   File: LogStep.java   Source Code and License 5 votes vote down vote up
@Override
protected boolean stepExecute(Context javascriptContext, Scriptable scope) throws EngineException {
	if (isEnabled()) {
		if (super.stepExecute(javascriptContext, scope)) {
			Logger log = null;
			if(logger.equals(Engine.logEngine.getName())) 
				log = Engine.logEngine;
			else if(logger.equals(Engine.logContext.getName()))
				log = Engine.logContext;
			else if(logger.equals(Engine.logUser.getName()))
				log = Engine.logUser;
			else if(logger.equals(Engine.logAudit.getName())) 
				log = Engine.logAudit;
			if(level.equals(Level.WARN.toString()) && log.isEnabledFor(Level.WARN))
				log.warn(getEvalString(javascriptContext, scope));
			else if(level.equals(Level.INFO.toString()) && log.isInfoEnabled())
				log.info(getEvalString(javascriptContext, scope));
			else if(level.equals(Level.DEBUG.toString()) && log.isDebugEnabled())
				log.debug(getEvalString(javascriptContext, scope));
			else if(level.equals(Level.TRACE.toString()) && log.isTraceEnabled())
				log.trace(getEvalString(javascriptContext, scope));
			else if(level.equals(Level.ERROR.toString()) && log.isEnabledFor(Level.ERROR))
				log.error(getEvalString(javascriptContext, scope));
			return true;
		}
	}
	return false;
}
 
Example 31
Project: belling-admin   File: LoggerUtils.java   Source Code and License 5 votes vote down vote up
/**
 * Error 输出
 * @param clazz  	目标.Class
 * @param message	输出信息
 * @param e			异常类
 */
public static void error(Class<? extends Object> clazz ,String message,Exception e){
	Logger logger = Logger.getLogger(clazz);
	if(null == e){
		logger.error(message);
		return ;
	}
	logger.error(message, e);
}
 
Example 32
Project: LightSIP   File: LogWriter.java   Source Code and License 5 votes vote down vote up
/**
 * Log an error message.
 *
 * @param message --
 *            error message to log.
 */
public void logFatalError(String message) {
    Logger logger = this.getLogger();
    String newMsg = this.enhanceMessage(message);
    countLines(newMsg);
    logger.fatal(newMsg);

}
 
Example 33
Project: zipkin-sparkstreaming   File: LogInitializer.java   Source Code and License 5 votes vote down vote up
@Override public void run() {
  Logger zipkinLogger = LogManager.getLogger("zipkin");
  if (!log4Jlevel().equals(zipkinLogger.getLevel())) {
    zipkinLogger.setLevel(log4Jlevel());
    if (zipkinLogger.getAdditivity()) {
      addLogAppendersFromRoot(zipkinLogger);
    }
  }
  java.util.logging.Logger.getLogger("zipkin").setLevel(julLevel());
}
 
Example 34
Project: flume-release-1.7.0   File: TestLog4jAppender.java   Source Code and License 5 votes vote down vote up
@Test
public void testLog4jAppenderFailureUnsafeMode() throws Throwable {
  configureSource();
  props.setProperty("log4j.appender.out2.UnsafeMode", String.valueOf(true));
  PropertyConfigurator.configure(props);
  Logger logger = LogManager.getLogger(TestLog4jAppender.class);
  source.stop();
  sendAndAssertFail(logger);

}
 
Example 35
Project: WeiXing_xmu-2016-MrCode   File: BaseServiceImpl.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("unchecked")
public BaseServiceImpl() {
	ParameterizedType type = (ParameterizedType) this.getClass()
			.getGenericSuperclass();
	clazz = (Class<T>) type.getActualTypeArguments()[0];
	log = Logger.getLogger(clazz);
}
 
Example 36
Project: ats-framework   File: ActionClassOne.java   Source Code and License 5 votes vote down vote up
@Action( name = "action array")
public int action1(
                    @Parameter( name = "valueToMatch", validation = ValidationType.NUMBER_CONSTANT, args = { "VALID_CONSTANTS" }) int[] values ) {

    ACTION_VALUE = values[values.length - 1];
    Logger.getLogger(ActionClassOne.class).info("Method action array has been executed");

    return ACTION_VALUE;
}
 
Example 37
Project: sstore-soft   File: LoggerUtil.java   Source Code and License 5 votes vote down vote up
public void run() {
    if (PROPERTIES_FILE == null) setupLogging();
    Thread self = Thread.currentThread();
    self.setName(HStoreConstants.THREAD_NAME_LOGGING);
    
    while (!self.isInterrupted()) {
        try {
            Thread.sleep(this.interval);
        } catch (InterruptedException ex) {
            break;
        }
        
        // HACK: Look for an HStoreSite so that we can set our name properly
        // This probably doesn't need to be synchronized
        if (THREAD_MANAGER == null) {
            synchronized (LoggerUtil.class) {
                if (THREAD_MANAGER == null) {
                    HStoreSite hstore_site = HStore.instance();
                    if (hstore_site != null) {
                        String name = HStoreThreadManager.getThreadName(hstore_site, HStoreConstants.THREAD_NAME_LOGGING);
                        self.setName(name);
                        THREAD_MANAGER = hstore_site.getThreadManager();
                        THREAD_MANAGER.registerProcessingThread();
                    }
                }
            } // SYNCH
        }
        
        // Refresh our configuration if the file has changed
        if (PROPERTIES_FILE != null && LAST_TIMESTAMP != PROPERTIES_FILE.lastModified()) {
            loadConfiguration(PROPERTIES_FILE);
            assert(PROPERTIES_FILE != null);
            Logger.getRootLogger().info("Refreshed log4j configuration [" + PROPERTIES_FILE.getAbsolutePath() + "]");
            LoggerUtil.OBSERVABLE.notifyObservers();
        }
    }
}
 
Example 38
Project: LightSIP   File: WebsocketSelfTest.java   Source Code and License 5 votes vote down vote up
public void setUp() {
  	System.setProperty( "javax.net.ssl.keyStore",  TlsTest.class.getResource("testkeys").getPath() );
System.setProperty( "javax.net.ssl.trustStore", TlsTest.class.getResource("testkeys").getPath() );
System.setProperty( "javax.net.ssl.keyStorePassword", "passphrase" );
System.setProperty( "javax.net.ssl.keyStoreType", "jks" );
  	ConsoleAppender console = new ConsoleAppender();
  	console.setName("Console app");
  	String PATTERN = "%d [%p|%c|%C{1}] %m%n";
  	console.setLayout(new PatternLayout(PATTERN)); 
  	console.setThreshold(Level.DEBUG);
  	console.activateOptions();
  	Logger.getRootLogger().addAppender(console);
  	this.websocketServer = new WebsocketServer();
  	this.websocketBrowser = new WebsocketBrowser();
  }
 
Example 39
Project: unitimes   File: Loggers.java   Source Code and License 5 votes vote down vote up
@Override
@PreAuthorize("checkPermission('ApplicationConfig')")
public SimpleEditInterface load(SessionContext context, Session hibSession) {
	List<ListItem> levels = new ArrayList<ListItem>();
	levels.add(new ListItem(String.valueOf(Level.ALL_INT), MESSAGES.levelAll()));
	levels.add(new ListItem(String.valueOf(Level.TRACE_INT), MESSAGES.levelTrace()));
	levels.add(new ListItem(String.valueOf(Level.DEBUG_INT), MESSAGES.levelDebug()));
	levels.add(new ListItem(String.valueOf(Level.INFO_INT), MESSAGES.levelInfo()));
	levels.add(new ListItem(String.valueOf(Level.WARN_INT), MESSAGES.levelWarning()));
	levels.add(new ListItem(String.valueOf(Level.ERROR_INT), MESSAGES.levelError()));
	levels.add(new ListItem(String.valueOf(Level.FATAL_INT), MESSAGES.levelFatal()));
	levels.add(new ListItem(String.valueOf(Level.OFF_INT), MESSAGES.levelOff()));
	
	SimpleEditInterface data = new SimpleEditInterface(
			new Field(MESSAGES.fieldLogger(), FieldType.text, 400, 1024, Flag.UNIQUE),
			new Field(MESSAGES.fieldLevel(), FieldType.list, 100, levels, Flag.NOT_EMPTY));
	data.setSortBy(0, 1);
	
	long id = 0;
	SimpleEditInterface.Record root = data.addRecord(id++, false);
	root.setField(0, " root", false);
	root.setField(1, String.valueOf(LogManager.getRootLogger().getLevel().toInt()));
	
	for (Enumeration e = LogManager.getCurrentLoggers(); e.hasMoreElements(); ) {
		Logger logger = (Logger)e.nextElement();
		if (logger.getLevel() == null) continue;
		ApplicationConfig config = ApplicationConfig.getConfig("log4j.logger." + logger.getName());
		SimpleEditInterface.Record record = data.addRecord(id++, ApplicationProperties.getDefaultProperties().getProperty("log4j.logger." + logger.getName()) == null && config != null);
		record.setField(0, logger.getName(), false);
		record.setField(1, String.valueOf(logger.getLevel().toInt()));
	}

	data.setEditable(context.hasPermission(Right.ApplicationConfig));
	return data;
}
 
Example 40
Project: metacherchant   File: IOUtils.java   Source Code and License 5 votes vote down vote up
public static BigLong2ShortHashMap loadReads(File[] files, int k, int minSeqLen,
                                             int availableProcessors, Logger logger)
        throws ExecutionFailedException {
    BigLong2ShortHashMap hm = new BigLong2ShortHashMap(
            (int) (Math.log(availableProcessors) / Math.log(2)) + 4, 12, true);

    ReadsLoadWorker[] workers = new ReadsLoadWorker[availableProcessors];
    for (int i = 0; i < workers.length; ++i) {
        workers[i] = new ReadsLoadWorker(hm, k, minSeqLen);
    }

    run(files, workers, hm, logger);

    // calculating statistics...
    int totalSeq = 0, goodSeq = 0;
    long totalLen = 0, goodLen = 0;
    for (ReadsLoadWorker worker : workers) {
        totalSeq += worker.totalSeq;
        goodSeq += worker.goodSeq;
        totalLen += worker.totalLen;
        goodLen += worker.goodLen;
    }
    Tool.debug(logger,
            "Good/Total sequences count = " + NumUtils.groupDigits(goodSeq) + "/" + NumUtils.groupDigits(totalSeq)
            + " (" + String.format("%.1f", goodSeq * 100.0 / totalSeq) + "%)");
    Tool.debug(logger,
            "Good/Total sequences length = " + NumUtils.groupDigits(goodLen) + "/" + NumUtils.groupDigits(totalLen)
                    + " (" + String.format("%.1f", goodLen * 100.0 / totalLen) + "%)");
    logger.debug("k-mers HM size = " + NumUtils.groupDigits(hm.size()));

    return hm;
}