Java Code Examples for org.apache.log4j.Logger

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project big-data-plugin, under directory /src/org/pentaho/di/job/entries/pig/.

Source file: JobEntryPigScriptExecutor.java

  19 
vote

protected void removeAppender(Log4jFileAppender appender,WriterAppender pigToKettleAppender){
  if (appender != null) {
    LogWriter.getInstance().removeAppender(appender);
    appender.close();
  }
  Logger pigLogger=Logger.getLogger("org.apache.pig");
  if (pigLogger != null && pigToKettleAppender != null) {
    pigLogger.removeAppender(pigToKettleAppender);
    pigToKettleAppender.close();
  }
}
 

Example 2

From project bpelunit, under directory /tycho/net.bpelunit.framework.client.eclipse/src/net/bpelunit/framework/client/eclipse/.

Source file: EclipseBPELUnitRunner.java

  18 
vote

public void configureLogging(Level level,Appender appender){
  Logger rootLogger=Logger.getRootLogger();
  rootLogger.removeAllAppenders();
  rootLogger.addAppender(appender);
  rootLogger.setLevel(level);
}
 

Example 3

From project candlepin, under directory /src/test/java/org/candlepin/config/.

Source file: LoggingConfigTest.java

  18 
vote

@Test public void configure(){
  Logger l=Logger.getLogger(LoggingConfigTest.class);
  assertNotNull(l);
  assertNull(l.getLevel());
  Map<String,String> loglevels=new HashMap<String,String>();
  loglevels.put(LoggingConfigTest.class.getName(),"DEBUG");
  when(config.configurationWithPrefix(LoggingConfig.PREFIX)).thenReturn(loglevels);
  lc.configure(config);
  assertNotNull(l.getLevel());
  assertEquals(Level.DEBUG,l.getLevel());
}
 

Example 4

From project Carolina-Digital-Repository, under directory /admin/src/main/java/edu/unc/lib/dl/util/.

Source file: Log4JManager.java

  18 
vote

/** 
 * Gets the names of the the currently active loggers.
 * @return an array of the names of the currently active loggers.
 */
public String[] getCurrentLoggers(){
  List<String> loggers=new ArrayList<String>();
  Enumeration en=LogManager.getLoggerRepository().getCurrentLoggers();
  while (en.hasMoreElements()) {
    Logger l=(Logger)en.nextElement();
    loggers.add(l.getName());
  }
  Collections.sort(loggers);
  return loggers.toArray(new String[loggers.size()]);
}
 

Example 5

From project chililog-server, under directory /src/test/java/org/chililog/server/engine/.

Source file: InternalLog4JAppenderTest.java

  18 
vote

@Test public void testNull() throws ChiliLogException, InterruptedException {
  Logger logger=Logger.getLogger(InternalLog4JAppenderTest.class.getName() + "_TestNull");
  logger.addAppender(new InternalLog4JAppender());
  logger.setLevel(Level.DEBUG);
  logger.debug(null);
  DBCollection coll=_db.getCollection(InternalLog4JAppender.MONGODB_COLLECTION_NAME);
  assertEquals(0,coll.find().count());
  return;
}
 

Example 6

From project commons-logging, under directory /src/test/org/apache/commons/logging/log4j/log4j12/.

Source file: Log4j12StandardTests.java

  18 
vote

public void setUpTestAppender(List logEvents){
  TestAppender appender=new TestAppender(logEvents);
  Logger rootLogger=Logger.getRootLogger();
  rootLogger.removeAllAppenders();
  rootLogger.addAppender(appender);
  rootLogger.setLevel(Level.INFO);
}
 

Example 7

From project components-ness-logging, under directory /src/test/java/com/nesscomputing/log4j/.

Source file: TestMultipleAppenders.java

  18 
vote

@Test public void testRootLog(){
  Assert.assertEquals("",r1.getContents());
  Assert.assertEquals("",r2.getContents());
  final Logger logger=Logger.getRootLogger();
  logger.info("Hello, World!");
  Assert.assertEquals("Hello, World!\n",r1.getContents());
  Assert.assertEquals("",r2.getContents());
}
 

Example 8

From project components-ness-tracking, under directory /src/test/java/com/nesscomputing/tracking/.

Source file: TestLogging.java

  18 
vote

@Before public void setup(){
  final URL log4jFile=TestLogging.class.getResource("/log4j.xml");
  DOMConfigurator.configure(log4jFile);
  final Logger root=Logger.getRootLogger();
  recordingAppender=new RecordingAppender("%X{track} - %m%n");
  root.addAppender(recordingAppender);
  log=Log.forName("tracker");
  req=new MockedHttpServletRequest();
  value=UUID.randomUUID();
  res=mockSupport.createMock(HttpServletResponse.class);
  res.setHeader(TrackingFilter.X_NESS_TRACK,value.toString());
  EasyMock.expectLastCall().once();
  mockSupport.replayAll();
}
 

Example 9

From project crunch, under directory /crunch/src/main/java/org/apache/crunch/impl/mr/.

Source file: MRPipeline.java

  18 
vote

@Override public void enableDebug(){
  getConfiguration().setBoolean(RuntimeParameters.DEBUG,true);
  Logger crunchInfoLogger=LogManager.getLogger("org.apache.crunch");
  Appender console=crunchInfoLogger.getAppender("A");
  if (console != null) {
    Logger hadoopLogger=LogManager.getLogger("org.apache.hadoop");
    hadoopLogger.setLevel(Level.WARN);
    hadoopLogger.addAppender(console);
  }
 else {
    LOG.warn("Could not find console appender named 'A' for writing Hadoop warning logs");
  }
}
 

Example 10

From project des, under directory /daemon/lib/apache-log4j-1.2.16/src/main/java/org/apache/log4j/jmx/.

Source file: HierarchyDynamicMBean.java

  18 
vote

public ObjectName addLoggerMBean(String name){
  Logger cat=LogManager.exists(name);
  if (cat != null) {
    return addLoggerMBean(cat);
  }
 else {
    return null;
  }
}
 

Example 11

From project EMF-IncQuery, under directory /plugins/org.eclipse.viatra2.emf.incquery.runtime/src/org/eclipse/viatra2/emf/incquery/runtime/api/.

Source file: IncQueryEngine.java

  18 
vote

/** 
 * Provides a static default logger.
 */
public static Logger getDefaultLogger(){
  if (defaultRuntimeLogger == null) {
    final Injector injector=XtextInjectorProvider.INSTANCE.getInjector();
    if (injector == null)     throw new AssertionError("Configuration error: EMF-IncQuery injector not initialized.");
    Logger parentLogger=injector.getInstance(Logger.class);
    if (parentLogger == null)     throw new AssertionError("Configuration error: EMF-IncQuery logger not found.");
    defaultRuntimeLogger=Logger.getLogger(parentLogger.getName() + ".runtime");
    if (defaultRuntimeLogger == null)     throw new AssertionError("Configuration error: unable to create default EMF-IncQuery runtime logger.");
  }
  return defaultRuntimeLogger;
}
 

Example 12

From project ALP, under directory /workspace/alp-selenium/src/main/java/com/lohika/alp/selenium/.

Source file: AlpWebDriverFactory.java

  17 
vote

/** 
 * Create WebDriver object wrapped with ALP logging that allow implements autologging
 * @param SeleniumUrl - represent target Selenium standalone server for WebDriver that will be created 
 * @param capabilities - DesiredCapabilities for WebDriver that will be created  
 * @return created WebDriver instance 
 * @throws MalformedURLException the malformed url exception
 */
public static WebDriver getDriver(String SeleniumUrl,DesiredCapabilities capabilities) throws MalformedURLException {
  Logger alpSeleniumLogger=Logger.getLogger("com.lohika.alp.selenium");
  if (alpSeleniumLogger.getLevel() == null)   alpSeleniumLogger.setLevel(Level.DEBUG);
  URL remoteAddress=new URL(SeleniumUrl);
  CommandExecutor commandExecutor=new HttpCommandExecutor(remoteAddress);
  WebDriver driver;
  String name=capabilities.getBrowserName();
  WebDriverConfigurator webDriverConfigurator=new WebDriverConfigurator(name);
  capabilities=webDriverConfigurator.configure(capabilities);
  driver=new RemoteWebDriverTakeScreenshotFix(commandExecutor,capabilities);
  LogElementsSeleniumFactory logObjectsFactory=new LogElementsSeleniumFactoryJAXB();
  LogElementsSeleniumFactory elementsFactory=new LogElementsSeleniumFactoryJAXB();
  WebDriverEventListener listener=new LoggingWebDriverListener(elementsFactory);
  driver=new EventFiringWebDriver(driver);
  ((EventFiringWebDriver)driver).register(listener);
  driver=new LoggingWebDriver(driver,name,logObjectsFactory);
  Logger seleniumLogger=Logger.getLogger("selenium-logging");
  if (seleniumLogger != null)   try {
    String levelStr=seleniumLogger.getLevel().toString();
    log.debug("java.util.logging.Level for selenium: " + levelStr);
    java.util.logging.Level level=java.util.logging.Level.parse(levelStr);
    RemoteWebDriverTakeScreenshotFix.setLogLevel(level);
  }
 catch (  IllegalArgumentException e) {
    log.warn("Unable turn off native selenium logging");
  }
catch (  NullPointerException e) {
    log.warn("Unable to get log level for native selenium logging");
  }
  return driver;
}
 

Example 13

From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/aladdin/test/.

Source file: ApacheLog.java

  17 
vote

public static void main(String args[]){
  Logger logger=Logger.getLogger(ApacheLog.class);
  SimpleLayout layout=new SimpleLayout();
  FileAppender appender=null;
  try {
    appender=new FileAppender(layout,"myApacheLog.log",false);
  }
 catch (  Exception e) {
  }
  logger.addAppender(appender);
  logger.setLevel(Level.INFO);
  logger.debug("This is debug.");
  logger.info("This is an info.");
  logger.warn("This is a warning.");
  logger.error("This is an error.");
  logger.fatal("This is a fatal error.");
}
 

Example 14

From project chukwa, under directory /src/main/java/org/apache/hadoop/chukwa/inputtools/log4j/.

Source file: Log4JMetricsContext.java

  17 
vote

@Override protected void emitRecord(String contextName,String recordName,OutputRecord outRec) throws IOException {
synchronized (lock) {
    if (out == null) {
      PatternLayout layout=new PatternLayout("%d{ISO8601} %p %c: %m%n");
      org.apache.log4j.net.SocketAppender appender=new org.apache.log4j.net.SocketAppender(host,port);
      appender.setName("chukwa.metrics." + contextName);
      appender.setLayout(layout);
      Logger logger=Logger.getLogger("chukwa.metrics." + contextName);
      logger.setAdditivity(false);
      logger.addAppender(appender);
      appender.activateOptions();
      out=logger;
    }
    JSONObject json=new JSONObject();
    try {
      json.put("contextName",contextName);
      json.put("recordName",recordName);
      json.put("chukwa_timestamp",System.currentTimeMillis());
      json.put("period",period);
      for (      String tagName : outRec.getTagNames()) {
        json.put(tagName,outRec.getTag(tagName));
      }
      for (      String metricName : outRec.getMetricNames()) {
        json.put(metricName,outRec.getMetric(metricName));
      }
    }
 catch (    Exception e) {
      log.warn("exception in Log4jMetricsContext:",e);
    }
    out.info(json.toString());
  }
}
 

Example 15

From project common_1, under directory /src/main/java/org/powertac/util/.

Source file: MessageDispatcher.java

  17 
vote

/** 
 * Dispatches a call to methodName inside target based on the type of message. Allows polymorphic method dispatch without the use of visitor or double dispatch schemes, which produce nasty couplings with domain types. <p> Note that this scheme finds only exact matches between types of arguments and declared types of formal parameters for declared or inherited methods. So it will not call a method with formal parameter types of  (Transaction, List) if the actual arguments are (Transaction, ArrayList). </p>
 */
static public Object dispatch(Object target,String methodName,Object... args){
  Logger log=Logger.getLogger(target.getClass().getName());
  Object result=null;
  try {
    Class[] classes=new Class[args.length];
    for (int index=0; index < args.length; index++) {
      classes[index]=(args[index].getClass());
    }
    Method method=target.getClass().getMethod(methodName,classes);
    log.debug("found method " + method);
    result=method.invoke(target,args);
  }
 catch (  NoSuchMethodException nsm) {
    log.debug("Could not find exact match: " + nsm.toString());
  }
catch (  InvocationTargetException ite) {
    Throwable thr=ite.getTargetException();
    log.error("Cannot call " + methodName + ": "+ thr+ "\n  ..at "+ thr.getStackTrace()[0]+ "\n  ..at "+ thr.getStackTrace()[1]+ "\n  ..at "+ thr.getStackTrace()[2]+ "\n  ..at "+ thr.getStackTrace()[3]+ "\n  ..at ");
  }
catch (  Exception ex) {
    log.error("Exception calling message processor: " + ex.toString());
  }
  return result;
}
 

Example 16

From project dragon, under directory /hadoop-dragon-core/src/main/java/org/apache/hadoop/realtime/job/.

Source file: TaskLog.java

  17 
vote

@SuppressWarnings("unchecked") public synchronized static void syncLogs(String logLocation,TaskAttemptId taskid,boolean isCleanup) throws IOException {
  System.out.flush();
  System.err.flush();
  Enumeration<Logger> allLoggers=LogManager.getCurrentLoggers();
  while (allLoggers.hasMoreElements()) {
    Logger l=allLoggers.nextElement();
    Enumeration<Appender> allAppenders=l.getAllAppenders();
    while (allAppenders.hasMoreElements()) {
      Appender a=allAppenders.nextElement();
      if (a instanceof TaskLogAppender) {
        ((TaskLogAppender)a).flush();
      }
    }
  }
  if (currentTaskid != taskid) {
    currentTaskid=taskid;
    resetPrevLengths(logLocation);
  }
  writeToIndexFile(logLocation,isCleanup);
}
 

Example 17

From project flume, under directory /flume-ng-clients/flume-ng-log4jappender/src/test/java/org/apache/flume/clients/log4jappender/.

Source file: TestLog4jAppender.java

  17 
vote

@Test public void testLog4jAppender() throws IOException {
  File TESTFILE=new File(TestLog4jAppender.class.getClassLoader().getResource("flume-log4jtest.properties").getFile());
  FileReader reader=new FileReader(TESTFILE);
  Properties props=new Properties();
  props.load(reader);
  PropertyConfigurator.configure(props);
  Logger logger=LogManager.getLogger(TestLog4jAppender.class);
  for (int count=0; count <= 1000; count++) {
    int level=count % 5;
    String msg="This is log message number" + String.valueOf(count);
    logger.log(Level.toLevel(level),msg);
    Transaction transaction=ch.getTransaction();
    transaction.begin();
    Event event=ch.take();
    Assert.assertNotNull(event);
    Assert.assertEquals(new String(event.getBody(),"UTF8"),msg);
    Map<String,String> hdrs=event.getHeaders();
    Assert.assertNotNull(hdrs.get(Log4jAvroHeaders.TIMESTAMP.toString()));
    Assert.assertEquals(Level.toLevel(level),Level.toLevel(hdrs.get(Log4jAvroHeaders.LOG_LEVEL.toString())));
    Assert.assertEquals(logger.getName(),hdrs.get(Log4jAvroHeaders.LOGGER_NAME.toString()));
    Assert.assertEquals("UTF8",hdrs.get(Log4jAvroHeaders.MESSAGE_ENCODING.toString()));
    System.out.println("Got body: " + new String(event.getBody(),"UTF8"));
    transaction.commit();
    transaction.close();
  }
}
 

Example 18

From project Flume-Hive, under directory /src/javatest/com/cloudera/flume/agent/.

Source file: TestEndToEndAckFailureRecovery.java

  17 
vote

/** 
 * Setup mock clock, mock rpc master and a node that writes to a temp directory.
 */
@Before public void setUp(){
  System.out.println("=====");
  Logger log=Logger.getRootLogger();
  log.setLevel(Level.DEBUG);
  File tmpdir=null;
  try {
    tmpdir=FileUtil.mktempdir();
  }
 catch (  IOException e) {
    fail("unable to create temp dir");
  }
  FlumeConfiguration.get().set(FlumeConfiguration.AGENT_LOG_DIR_NEW,tmpdir.getAbsolutePath());
  System.out.println("Writing out tempdir: " + tmpdir.getAbsolutePath());
  master=new FlumeMaster(FlumeConfiguration.get());
  mock=new DirectMasterRPC(master);
  node=new FlumeNode(mock,false,false);
}
 

Example 19

From project flume_1, under directory /flume-core/src/test/java/com/cloudera/flume/agent/.

Source file: TestEndToEndAckFailureRecovery.java

  17 
vote

/** 
 * Setup mock clock, mock rpc master and a node that writes to a temp directory.
 */
@Before public void setUp(){
  System.out.println("=====");
  Logger log=Logger.getRootLogger();
  log.setLevel(Level.DEBUG);
  File tmpdir=null;
  try {
    tmpdir=FileUtil.mktempdir();
  }
 catch (  IOException e) {
    fail("unable to create temp dir");
  }
  FlumeConfiguration.get().set(FlumeConfiguration.AGENT_LOG_DIR_NEW,tmpdir.getAbsolutePath());
  System.out.println("Writing out tempdir: " + tmpdir.getAbsolutePath());
  master=new FlumeMaster(FlumeConfiguration.get());
  mock=new DirectMasterRPC(master);
  node=new FlumeNode(mock,false,false);
}
 

Example 20

From project Aion-Extreme, under directory /AE-go_DataPack/gameserver/data/scripts/system/database/mysql5/.

Source file: MySQL5GameTimeDAO.java

  16 
vote

/** 
 * {@inheritDoc}
 */
@Override public int load(){
  PreparedStatement ps=DB.prepareStatement("SELECT `value` FROM `server_variables` WHERE `key`='time'");
  try {
    ResultSet rs=ps.executeQuery();
    if (rs.next())     return Integer.parseInt(rs.getString("value"));
  }
 catch (  SQLException e) {
    Logger.getLogger(MySQL5GameTimeDAO.class).error("Error loading last saved server time",e);
  }
 finally {
    DB.close(ps);
  }
  return 0;
}
 

Example 21

From project clutter, under directory /src/clutter/.

Source file: Log.java

  16 
vote

private static Logger getLogger(Object source){
  if ("true".equals(System.getProperty("ashcroft"))) {
    return new Logger("dumb"){
      @Override public void info(      Object message){
      }
      @Override public void info(      Object message,      Throwable t){
      }
      @Override public void debug(      Object message){
      }
      @Override public void error(      Object message,      Throwable t){
      }
      @Override public void error(      Object message){
      }
      @Override public void fatal(      Object message,      Throwable t){
      }
    }
;
  }
  if (source instanceof Class) {
    return Logger.getLogger((Class)source);
  }
  return Logger.getLogger(source.getClass());
}
 

Example 22

From project artimate, under directory /artimate-model/src/main/java/fr/loria/parole/artimate/model/.

Source file: PosConcatenator.java

  15 
vote

/** 
 * Concatenate all <tt>*.pos</tt> files in directory <code>arg[0]</code> to a single target <tt>.pos</tt> file <code>args[1]</code>.
 * @param args source directory, target file
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
  String inputDirectoryName=args[0];
  String outputFileName=args[1];
  String logFormat=System.getProperty("log.format");
  String logLevel=System.getProperty("log.level");
  if (logFormat == null || logFormat.isEmpty()) {
    logFormat="[%c{1}] [%p] %m%n";
  }
  ConsoleAppender consoleAppender=new ConsoleAppender(new PatternLayout(logFormat));
  BasicConfigurator.configure(consoleAppender);
  Level level=Level.toLevel(logLevel);
  Logger.getRootLogger().setLevel(level);
  File inputDirectory=new File(inputDirectoryName);
  PatternFilenameFilter posFileFilter=new PatternFilenameFilter(".*\\.pos");
  File[] inputFiles=inputDirectory.listFiles(posFileFilter);
  if (inputFiles == null) {
    logger.error("Could not find input *.pos files in " + inputDirectoryName);
    throw new IOException();
  }
  logger.debug("Found " + inputFiles.length + " input files");
  File outputFile=new File(outputFileName);
  Files.createParentDirs(outputFile);
  FileOutputStream output=Files.newOutputStreamSupplier(outputFile).getOutput();
  logger.info("Appending to " + outputFileName);
  for (  File input : inputFiles) {
    Files.copy(input,output);
    logger.debug("Appended " + input.getName());
  }
}
 

Example 23

From project asterisk-java, under directory /src/main/java/org/asteriskjava/util/internal/.

Source file: Log4JLogger.java

  15 
vote

/** 
 * Return the native Logger instance we are using.
 */
public final Logger getLogger(){
  if (logger == null) {
    logger=Logger.getLogger(name);
  }
  return (this.logger);
}
 

Example 24

From project aws-tasks, under directory /src/it/java/datameer/awstasks/aws/emr/.

Source file: EmrClusterTest.java

  15 
vote

@Before public void before(){
  Logger.getLogger("datameer.awstasks").setLevel(Level.DEBUG);
  _s3Service=_ec2Conf.createS3Service();
  _s3Bucket=_s3Service.createBucket(S3BucketTest.AWS_TEST_BUCKET);
  List<S3ObjectSummary> s3Objects=_s3Service.listObjects(_s3Bucket.getName()).getObjectSummaries();
  for (  S3ObjectSummary s3ObjectSummary : s3Objects) {
    _s3Service.deleteObject(_s3Bucket.getName(),s3ObjectSummary.getKey());
  }
  _emrCluster=createEmrCluster();
}
 

Example 25

From project azkaban, under directory /azkaban/src/java/azkaban/app/.

Source file: AzkabanApplication.java

  15 
vote

private VelocityEngine configureVelocityEngine(final boolean devMode){
  VelocityEngine engine=new VelocityEngine();
  engine.setProperty("resource.loader","classpath");
  engine.setProperty("classpath.resource.loader.class",ClasspathResourceLoader.class.getName());
  engine.setProperty("classpath.resource.loader.cache",!devMode);
  engine.setProperty("classpath.resource.loader.modificationCheckInterval",5L);
  engine.setProperty("resource.manager.logwhenfound",false);
  engine.setProperty("input.encoding","UTF-8");
  engine.setProperty("output.encoding","UTF-8");
  engine.setProperty("directive.foreach.counter.name","idx");
  engine.setProperty("directive.foreach.counter.initial.value",0);
  engine.setProperty("directive.set.null.allowed",true);
  engine.setProperty("resource.manager.logwhenfound",false);
  engine.setProperty("velocimacro.permissions.allow.inline",true);
  engine.setProperty("velocimacro.library.autoreload",devMode);
  engine.setProperty("velocimacro.library","/azkaban/web/macros.vm");
  engine.setProperty("velocimacro.permissions.allow.inline.to.replace.global",true);
  engine.setProperty("velocimacro.context.localscope",true);
  engine.setProperty("velocimacro.arguments.strict",true);
  engine.setProperty("runtime.log.invalid.references",devMode);
  engine.setProperty("runtime.log.logsystem.class",Log4JLogChute.class);
  engine.setProperty("runtime.log.logsystem.log4j.logger",Logger.getLogger("org.apache.velocity.Logger"));
  engine.setProperty("parser.pool.size",3);
  return engine;
}
 

Example 26

From project bdd-security, under directory /src/main/java/net/continuumsecurity/web/drivers/.

Source file: BurpHtmlUnitDriver.java

  15 
vote

public BurpHtmlUnitDriver(){
  super();
  log=Logger.getLogger(this.getClass().getName());
  log.debug("Constructing BurpHtmlUnitDriver");
  getWebClient().setThrowExceptionOnScriptError(false);
  setProxy(Config.getBurpHost(),Config.getBurpPort());
}
 

Example 27

From project cascading, under directory /src/hadoop/cascading/flow/hadoop/util/.

Source file: HadoopUtil.java

  15 
vote

public static void initLog4j(JobConf jobConf){
  String values=jobConf.get("log4j.logger",null);
  if (values == null || values.length() == 0)   return;
  String[] elements=values.split(",");
  for (  String element : elements) {
    String[] logger=element.split("=");
    Logger.getLogger(logger[0]).setLevel(Level.toLevel(logger[1]));
  }
}
 

Example 28

From project caseconductor-platform, under directory /utest-domain-services/src/main/java/com/utest/domain/service/util/.

Source file: FileUploadUtil.java

  15 
vote

public static void uploadFile(final File targetFile,final String targetURL,final String targerFormFieldName_) throws Exception {
  final PostMethod filePost=new PostMethod(targetURL);
  filePost.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE,true);
  filePost.addRequestHeader("X-Atlassian-Token","no-check");
  try {
    final FilePart fp=new FilePart(targerFormFieldName_,targetFile);
    fp.setTransferEncoding(null);
    final Part[] parts={fp};
    filePost.setRequestEntity(new MultipartRequestEntity(parts,filePost.getParams()));
    final HttpClient client=new HttpClient();
    client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
    final int status=client.executeMethod(filePost);
    if (status == HttpStatus.SC_OK) {
      Logger.getLogger(FileUploadUtil.class).info("Upload complete, response=" + filePost.getResponseBodyAsString());
    }
 else {
      Logger.getLogger(FileUploadUtil.class).info("Upload failed, response=" + HttpStatus.getStatusText(status));
    }
  }
 catch (  final Exception ex) {
    Logger.getLogger(FileUploadUtil.class).error("ERROR: " + ex.getClass().getName() + " "+ ex.getMessage(),ex);
    throw ex;
  }
 finally {
    Logger.getLogger(FileUploadUtil.class).debug(new String(filePost.getResponseBody()));
    filePost.releaseConnection();
  }
}
 

Example 29

From project cider, under directory /src/net/yacy/cider/util/.

Source file: Log.java

  15 
vote

private final static void enQueueLog(final Logger logger,final Level level,final String message){
  if (logRunnerThread == null || !logRunnerThread.isAlive()) {
    logger.log(level,message);
  }
 else {
    try {
      logQueue.put(new logEntry(logger,level,message));
    }
 catch (    InterruptedException e) {
      logger.log(level,message);
    }
  }
}
 

Example 30

From project Cinch, under directory /example/com/palantir/ptoss/cinch/example/.

Source file: Examples.java

  15 
vote

public static void initializeLogging(){
  Logger.getRootLogger().setLevel(Level.INFO);
  ConsoleAppender console=new ConsoleAppender();
  console.setWriter(new PrintWriter(System.out));
  console.setLayout(new PatternLayout("%d{ISO8601} %d %p [%t] %c - %m%n"));
  Logger.getRootLogger().addAppender(console);
}
 

Example 31

From project cleo, under directory /src/main/java/cleo/search/typeahead/.

Source file: AbstractTypeahead.java

  15 
vote

protected void log(Logger logger,int user,String[] terms,HitStats hitStats){
  StringBuilder sb=new StringBuilder();
  sb.append(getName()).append(" user=").append(user).append(" time=").append(hitStats.totalTime).append(" hits=").append(hitStats.numBrowseHits).append('|').append(hitStats.numFilterHits).append('|').append(hitStats.numResultHits);
  sb.append(" terms=").append('{');
  for (  String s : terms) {
    sb.append(s).append(',');
  }
  int lastIndex=sb.length() - 1;
  if (sb.charAt(lastIndex) == ',') {
    sb.deleteCharAt(lastIndex);
  }
  sb.append('}');
  logger.info(sb.toString());
}
 

Example 32

From project cloudify, under directory /USM/src/test/java/org/openspaces/usm/.

Source file: USMRollingFileAppenderTailerTest.java

  15 
vote

private StringHandler addHandlerToJavaUtilsLogger(){
  java.util.logging.Logger logger=java.util.logging.Logger.getLogger("");
  StringHandler sh=new StringHandler();
  logger.addHandler(sh);
  Handler[] handlers=logger.getHandlers();
  for (  Handler handler : handlers) {
    if (handler instanceof ConsoleHandler) {
      logger.removeHandler(handler);
      break;
    }
  }
  return sh;
}
 

Example 33

From project codjo-broadcast, under directory /codjo-broadcast-common/src/main/java/net/codjo/broadcast/common/diffuser/.

Source file: DiffuserManager.java

  15 
vote

public DiffuserManager(){
  diffuserMap.put("NONE",null);
  try {
    declareDiffuser("CFT",CFTDiffuser.class);
  }
 catch (  NoSuchMethodException ex) {
    Logger.getLogger(DiffuserManager.class).info("Impossible de d?larer le diffuseur CFT",ex);
  }
}
 

Example 34

From project core_1, under directory /common/src/main/java/org/switchyard/common/version/.

Source file: Versions.java

  15 
vote

/** 
 * Logs each Version returned by  {@link #getSwitchYardVersions()}.
 * @param logger the Logger to log to
 * @param level the Level to log at
 */
public static void logSwitchYardVersions(Logger logger,Level level){
  if (logger.isEnabledFor(level)) {
    for (    Version version : getSwitchYardVersions()) {
      logger.log(level,version);
    }
  }
}
 

Example 35

From project core_7, under directory /src/main/java/io/s4/adapter/.

Source file: Adapter.java

  15 
vote

public void processEvent(EventWrapper eventWrapper){
  try {
synchronized (this) {
      if (!init) {
        return;
      }
      rawEventCount++;
      eventCount++;
    }
    dispatcher.dispatchEvent(eventWrapper.getStreamName(),eventWrapper.getEvent());
  }
 catch (  Exception e) {
    Logger.getLogger("dispatcher").info("Exception adapting event",e);
  }
}
 

Example 36

From project couchdb-lucene, under directory /src/main/java/com/github/rnewson/couchdb/lucene/.

Source file: DatabaseIndexer.java

  15 
vote

public DatabaseIndexer(final HttpClient client,final File root,final Database database,final HierarchicalINIConfiguration ini) throws IOException, JSONException {
  this.client=client;
  this.root=root;
  this.database=database;
  this.ini=ini;
  this.logger=Logger.getLogger(DatabaseIndexer.class.getName() + "." + database.getInfo().getName());
}
 

Example 37

From project crammer, under directory /src/main/java/uk/ac/ebi/ena/sra/cram/.

Source file: CramTools.java

  15 
vote

public static void main(String[] args) throws Exception {
  Params params=new Params();
  JCommander jc=new JCommander(params);
  jc.setProgramName("cramtools");
  Cram2Bam.Params cram2BamParams=new Cram2Bam.Params();
  Bam2Cram.Params bam2CramParams=new Bam2Cram.Params();
  CramIndexer.Params cramIndexerParams=new CramIndexer.Params();
  jc.addCommand(CRAM2BAM_COMMAND,cram2BamParams);
  jc.addCommand(BAM2CRAM_COMMAND,bam2CramParams);
  jc.addCommand(CRAMINDEX_COMMAND,cramIndexerParams);
  jc.parse(args);
  if (params.logLevel != null) {
    Logger.getRootLogger().setLevel(params.logLevel);
    String[] newArgs=new String[args.length - 2];
    System.arraycopy(args,2,newArgs,0,newArgs.length);
    args=newArgs;
  }
  String command=jc.getParsedCommand();
  if (command == null || params.help) {
    StringBuilder sb=new StringBuilder();
    sb.append("\n");
    jc.usage(sb);
    System.out.println("Version " + CramTools.class.getPackage().getImplementationVersion());
    System.out.println(sb.toString());
    return;
  }
  String[] commandArgs=new String[args.length - 1];
  System.arraycopy(args,1,commandArgs,0,commandArgs.length);
  if (CRAM2BAM_COMMAND.equals(command))   Cram2Bam.main(commandArgs);
 else   if (BAM2CRAM_COMMAND.equals(command))   Bam2Cram.main(commandArgs);
 else   if (CRAMINDEX_COMMAND.equals(command))   CramIndexer.main(commandArgs);
}
 

Example 38

From project edna-rcp, under directory /org.edna.datamodel.language.ui/src-gen/org/edna/datamodel/ui/internal/.

Source file: DatamodelActivator.java

  15 
vote

@Override public void start(BundleContext context) throws Exception {
  super.start(context);
  INSTANCE=this;
  try {
    registerInjectorFor("org.edna.datamodel.Datamodel");
  }
 catch (  Exception e) {
    Logger.getLogger(getClass()).error(e.getMessage(),e);
    throw e;
  }
}
 

Example 39

From project elephant-twin, under directory /com.twitter.elephanttwin.lucene/src/main/java/com/twitter/elephanttwin/lucene/indexing/.

Source file: AbstractLuceneIndexingJob.java

  15 
vote

@Override public int run(String[] args) throws Exception {
  LOG=Logger.getLogger(this.getClass());
  params=newIndexConfig();
  LOG.info("Starting up indexer...");
  LOG.info(" - input: " + Joiner.on(" ").join(IndexConfig.input.get()));
  LOG.info(" - index: " + IndexConfig.index);
  LOG.info(" - number of shards: " + IndexConfig.numPartitions.get());
  Configuration conf=getConf();
  conf.set(AbstractLuceneIndexingReducer.HDFS_INDEX_LOCATION,IndexConfig.index.get());
  conf.set(AbstractLuceneIndexingReducer.ANALYZER,IndexConfig.analyzer.get());
  conf.set(AbstractLuceneIndexingReducer.SIMILARITY,IndexConfig.similarity.get());
  conf.setInt(AbstractSamplingIndexingMapper.SAMPLE_PERCENTAGE,IndexConfig.samplePercentage.get());
  conf.setBoolean("mapred.map.tasks.speculative.execution",false);
  conf.setBoolean("mapred.reduce.tasks.speculative.execution",false);
  Job job=new Job(conf,getJobName(params));
  conf=job.getConfiguration();
  job.setJarByClass(this.getClass());
  job.setNumReduceTasks(IndexConfig.numPartitions.get());
  for (  String s : IndexConfig.input.get()) {
    Path spath=new Path(s);
    FileSystem fs=spath.getFileSystem(getConf());
    List<FileStatus> stats=Lists.newArrayList();
    addInputPathRecursively(stats,fs,spath,HdfsUtils.HIDDEN_FILE_FILTER);
    for (    FileStatus foundStat : stats) {
      FileInputFormat.addInputPath(job,foundStat.getPath());
    }
  }
  FileOutputFormat.setOutputPath(job,new Path(IndexConfig.index.get()));
  setupJob(job);
  Path outputDir=new Path(IndexConfig.index.get());
  FileSystem.get(conf).delete(outputDir,true);
  long startTime=System.currentTimeMillis();
  LOG.info("Job " + getJobName(params) + " started.");
  job.waitForCompletion(true);
  LOG.info("Job " + getJobName(params) + " Finished in "+ (System.currentTimeMillis() - startTime) / 1000.0 + " seconds");
  if (job.isSuccessful()) {
    writeIndexDescriptors(getIndexDescriptor());
  }
  return job.isSuccessful() ? 0 : 1;
}
 

Example 40

From project eucalyptus, under directory /clc/modules/axis2-transport/src/edu/ucsb/eucalyptus/transport/.

Source file: Axis2Connector.java

  15 
vote

public void doInitialise() throws InitialisationException {
  try {
    this.axisConfig=ConfigurationContextFactory.createConfigurationContextFromFileSystem(this.deployPath,this.defaultConf);
  }
 catch (  AxisFault axisFault) {
    Logger.getLogger(Axis2Connector.class).error(axisFault.getMessage(),axisFault);
  }
}
 

Example 41

From project examples_5, under directory /twittertopiccount/src/main/java/io/s4/example/twittertopiccount/.

Source file: DirectToFilePersister.java

  15 
vote

@Override public void set(String key,Object value,int persistTime) throws InterruptedException {
  FileWriter fw=null;
  try {
    fw=new FileWriter(outputFilename);
    fw.write(String.valueOf(value));
  }
 catch (  IOException e) {
    Logger.getLogger("s4").error(e);
  }
 finally {
    if (fw != null) {
      try {
        fw.close();
      }
 catch (      Exception e) {
      }
    }
  }
}
 

Example 42

From project faces, under directory /Proyectos/upcdew-deportivoapp/src/java/com/upc/deportivo/util/.

Source file: AppSqlConfig.java

  15 
vote

private static void init(){
  try {
    Reader reader=Resources.getResourceAsReader("SqlMapConfig.xml");
    sqlMap=SqlMapClientBuilder.buildSqlMapClient(reader);
    reader.close();
  }
 catch (  Exception e) {
    Logger.getLogger(AppSqlConfig.class.getName()).fatal(e.getMessage(),e);
  }
}
 

Example 43

From project factored-customer, under directory /src/main/java/org/powertac/factoredcustomer/.

Source file: AdaptiveCapacityOriginator.java

  15 
vote

AdaptiveCapacityOriginator(CapacityStructure capacityStructure,DefaultCapacityBundle bundle){
  super(capacityStructure,bundle);
  log=Logger.getLogger(AdaptiveCapacityOriginator.class.getName());
  randomSeedRepo=(RandomSeedRepo)SpringApplicationContext.getBean("randomSeedRepo");
  optimizerStructure=getParentBundle().getOptimizerStructure();
  recommendationHandler=new Random(randomSeedRepo.getRandomSeed("factoredcustomer.AdaptiveCapacityOriginator",this.hashCode(),"RecommendationHandler").getValue());
}
 

Example 44

From project fairy, under directory /fairy-core/src/main/java/com/mewmew/fairy/v1/book/.

Source file: Esper.java

  15 
vote

@Override public void before(){
  super.before();
  if (verbose) {
    Logger.getRootLogger().setLevel(Level.DEBUG);
  }
}