Java Code Examples for org.apache.commons.logging.Log

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 slf4j_1, under directory /jcl-over-slf4j/src/test/java/org/apache/commons/logging/impl/.

Source file: SerializationTest.java

  34 
vote

public void verify() throws IOException, ClassNotFoundException {
  ByteArrayInputStream bis=new ByteArrayInputStream(baos.toByteArray());
  ois=new ObjectInputStream(bis);
  Log resuscitatedLog=(Log)ois.readObject();
  resuscitatedLog.debug("");
  resuscitatedLog.isDebugEnabled();
}
 

Example 2

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

Source file: JobEntryUtilsTest.java

  32 
vote

@Test public void findLogger(){
  String loggerName="testLogger";
  Log log=LogFactory.getLog(loggerName);
  assertTrue(log instanceof org.apache.commons.logging.impl.Log4JLogger);
  Log4JLogger log4jLogger=(org.apache.commons.logging.impl.Log4JLogger)log;
  Logger logger=log4jLogger.getLogger();
  assertNotNull(logger);
  assertNotNull(JobEntryUtils.findLogger(loggerName));
}
 

Example 3

From project commons-logging, under directory /src/java/org/apache/commons/logging/impl/.

Source file: LogFactoryImpl.java

  32 
vote

/** 
 * <p>Construct (if necessary) and return a <code>Log</code> instance, using the factory's current set of configuration attributes.</p> <p><strong>NOTE</strong> - Depending upon the implementation of the <code>LogFactory</code> you are using, the <code>Log</code> instance you are returned may or may not be local to the current application, and may or may not be returned again on a subsequent call with the same name argument.</p>
 * @param name Logical name of the <code>Log</code> instance to bereturned (the meaning of this name is only known to the underlying logging implementation that is being wrapped)
 * @exception LogConfigurationException if a suitable <code>Log</code>instance cannot be returned
 */
public Log getInstance(String name) throws LogConfigurationException {
  Log instance=(Log)instances.get(name);
  if (instance == null) {
    instance=newInstance(name);
    instances.put(name,instance);
  }
  return (instance);
}
 

Example 4

From project Hphoto, under directory /src/java/com/hphoto/util/.

Source file: ThreadPool.java

  32 
vote

/** 
 * Creates a pool of numThreads size. These threads sit around waiting for jobs to be posted to the list.
 */
public ThreadPool(int numThreads){
  this.numThreads=numThreads;
  jobs=new Vector(37);
  running=true;
  for (int i=0; i < numThreads; i++) {
    TaskThread t=new TaskThread();
    t.start();
  }
  Log l=LogFactory.getLog(ThreadPool.class.getName());
  l.fatal("ThreadPool created with " + numThreads + " threads.");
}
 

Example 5

From project JGlobus, under directory /jsse/src/main/java/org/globus/gsi/jsse/.

Source file: GlobusSSLHelper.java

  32 
vote

/** 
 * Create a store of Certificate Revocation Lists. Java requires that this be a java.security.certificates.CertStore. As such, the store can hold both CRL's and non-trusted certs. For the purposes of this method, we assume that only crl's will be loaded. This can only be used with the Globus provided Certificate Store.
 * @param crlPattern The pattern which defines the locations of the CRL's
 * @return A configured Java CertStore containing the specified CRL's
 * @throws GlobusSSLConfigurationException if the store cannot be loaded.
 */
public static CertStore findCRLStore(String crlPattern) throws GlobusSSLConfigurationException {
  ResourceCertStoreParameters crlStoreParams=new ResourceCertStoreParameters(null,crlPattern);
  try {
    return CertStore.getInstance(GlobusProvider.CERTSTORE_TYPE,crlStoreParams);
  }
 catch (  InvalidAlgorithmParameterException e) {
    throw new GlobusSSLConfigurationException(e);
  }
catch (  NoSuchAlgorithmException e) {
    Log logger=LogFactory.getLog(GlobusSSLHelper.class.getCanonicalName());
    logger.warn("Error Loading CRL store",e);
    throw new GlobusSSLConfigurationException(e);
  }
}
 

Example 6

From project Lily, under directory /global/util/src/main/java/org/lilyproject/util/io/.

Source file: Closer.java

  32 
vote

/** 
 * Closes anything  {@link Closeable}, catches any throwable that might occur during closing and logs it as an error.
 */
public static void close(Closeable closeable){
  if (closeable != null) {
    try {
      closeable.close();
    }
 catch (    Throwable t) {
      Log log=LogFactory.getLog(Closer.class);
      log.error("Error closing object of type " + closeable.getClass().getName(),t);
    }
  }
}
 

Example 7

From project platform_external_apache-http, under directory /src/org/apache/commons/logging/impl/.

Source file: LogFactoryImpl.java

  32 
vote

/** 
 * <p>Construct (if necessary) and return a <code>Log</code> instance, using the factory's current set of configuration attributes.</p> <p><strong>NOTE</strong> - Depending upon the implementation of the <code>LogFactory</code> you are using, the <code>Log</code> instance you are returned may or may not be local to the current application, and may or may not be returned again on a subsequent call with the same name argument.</p>
 * @param name Logical name of the <code>Log</code> instance to bereturned (the meaning of this name is only known to the underlying logging implementation that is being wrapped)
 * @exception LogConfigurationException if a suitable <code>Log</code>instance cannot be returned
 */
public Log getInstance(String name) throws LogConfigurationException {
  Log instance=(Log)instances.get(name);
  if (instance == null) {
    instance=newInstance(name);
    instances.put(name,instance);
  }
  return (instance);
}
 

Example 8

From project spring-gemfire-examples, under directory /basic/function/src/main/java/org/springframework/data/gemfire/examples/.

Source file: Client.java

  32 
vote

public static void main(String args[]) throws IOException {
  Log log=LogFactory.getLog(Client.class);
  ApplicationContext context=new ClassPathXmlApplicationContext("client/cache-config.xml");
  CalculateTotalSalesForProductInvoker calculateTotalForProduct=context.getBean(CalculateTotalSalesForProductInvoker.class);
  String[] products=new String[]{"Apple iPad","Apple iPod","Apple macBook"};
  for (  String productName : products) {
    BigDecimal total=calculateTotalForProduct.forProduct(productName);
    log.info("total sales for " + productName + " = $"+ total);
  }
}
 

Example 9

From project spring-insight-plugins, under directory /collection-plugins/logging/src/test/java/com/springsource/insight/plugin/logging/.

Source file: CommonsLoggingOperationCollectionAspectTest.java

  32 
vote

@Test public void testLogErrorMessage(){
  String msg="testLogErrorMessage";
  Log logger=LogFactory.getLog(getClass());
  logger.error(msg);
  assertLoggingOperation(Log.class,"ERROR",msg,null);
}
 

Example 10

From project spring-security, under directory /config/src/test/java/org/springframework/security/config/.

Source file: SecurityNamespaceHandlerTests.java

  32 
vote

@Test public void initDoesNotLogErrorWhenFilterChainProxyFailsToLoad() throws Exception {
  String className="javax.servlet.Filter";
  spy(ClassUtils.class);
  doThrow(new NoClassDefFoundError(className)).when(ClassUtils.class,"forName",eq(FILTER_CHAIN_PROXY_CLASSNAME),any(ClassLoader.class));
  Log logger=mock(Log.class);
  SecurityNamespaceHandler handler=new SecurityNamespaceHandler();
  WhiteboxImpl.setInternalState(handler,Log.class,logger);
  handler.init();
  verifyStatic();
  ClassUtils.forName(eq(FILTER_CHAIN_PROXY_CLASSNAME),any(ClassLoader.class));
  verifyZeroInteractions(logger);
}
 

Example 11

From project uaa, under directory /common/src/test/java/org/cloudfoundry/identity/uaa/scim/.

Source file: ScimUserEndpointsTests.java

  32 
vote

private void validateUserGroups(ScimUser user,String... gnm){
  Set<String> expectedAuthorities=new HashSet<String>();
  expectedAuthorities.addAll(Arrays.asList(gnm));
  expectedAuthorities.add("uaa.user");
  assertNotNull(user.getGroups());
  Log logger=LogFactory.getLog(getClass());
  logger.debug("user's groups: " + user.getGroups() + ", expecting: "+ expectedAuthorities);
  assertEquals(expectedAuthorities.size(),user.getGroups().size());
  for (  ScimUser.Group g : user.getGroups()) {
    assertTrue(expectedAuthorities.contains(g.getDisplay()));
  }
}
 

Example 12

From project amplafi-sworddance, under directory /src/test/java/com/sworddance/taskcontrol/.

Source file: TestDefaultDependentPrioritizedTask.java

  31 
vote

@Test public void testExceptionsPropagated() throws Exception {
  DefaultDependentPrioritizedTask task=new DefaultDependentPrioritizedTask(new ExceptionGenerator());
  try {
    task.call();
    fail("should have thrown an exception");
  }
 catch (  AssertionError e) {
    throw e;
  }
catch (  Throwable t) {
  }
  task=new DefaultDependentPrioritizedTask(new ExceptionGenerator());
  TaskGroup<?> taskGroup=new TaskGroup<Object>("Test");
  Log logger=LogFactory.getLog(this.getClass());
  taskGroup.setLog(logger);
  TaskControl taskControl=new TaskControl(logger);
  taskControl.setStayActive(false);
  taskControl.setLog(logger);
  taskGroup.addTask(task);
  taskControl.addTaskGroup(taskGroup);
  Thread t=new Thread(taskControl);
  t.start();
  t.join();
  assertNotNull(taskGroup.getException(),"Should throw Exception");
}
 

Example 13

From project arkadiko, under directory /bundles/bundle-log-adapter/src/com/liferay/arkadiko/bundle/log/adapter/.

Source file: LogListenerImpl.java

  31 
vote

public void logged(LogEntry entry){
  Bundle bundle=entry.getBundle();
  int level=entry.getLevel();
  ServiceReference<?> serviceReference=entry.getServiceReference();
  Log log=_logFactory.getInstance(bundle.getSymbolicName());
  StringBuilder sb=new StringBuilder(3);
  sb.append(entry.getMessage());
  if (serviceReference != null) {
    sb.append(" ");
    sb.append(serviceReference.toString());
  }
  if ((level == LogService.LOG_DEBUG) && log.isDebugEnabled()) {
    log.debug(sb.toString(),entry.getException());
  }
 else   if ((level == LogService.LOG_ERROR) && log.isErrorEnabled()) {
    log.error(sb.toString(),entry.getException());
  }
 else   if ((level == LogService.LOG_INFO) && log.isInfoEnabled()) {
    log.info(sb.toString(),entry.getException());
  }
 else   if ((level == LogService.LOG_WARNING) && log.isWarnEnabled()) {
    log.warn(sb.toString(),entry.getException());
  }
}
 

Example 14

From project datasalt-utils, under directory /src/contrib/java/org/apache/solr/hadoop/.

Source file: SolrRecordWriter.java

  31 
vote

static boolean setLogLevel(String packageName,String level){
  Log logger=LogFactory.getLog(packageName);
  if (logger == null) {
    return false;
  }
  LOG.warn("logger class:" + logger.getClass().getName());
  if (logger instanceof Log4JLogger) {
    process(((Log4JLogger)logger).getLogger(),level);
    return true;
  }
  if (logger instanceof Jdk14Logger) {
    process(((Jdk14Logger)logger).getLogger(),level);
    return true;
  }
  return false;
}
 

Example 15

From project entando-core-engine, under directory /src/main/java/com/agiletec/apsadmin/tags/util/.

Source file: ParamMap.java

  31 
vote

@Override public boolean end(Writer writer,String body){
  Log log=LogFactory.getLog(ParamMap.class);
  Component component=this.findAncestor(Component.class);
  if (null == this.getMap()) {
    log.warn("Attribute map is mandatory.");
    return super.end(writer,null);
  }
  Object object=findValue(this.getMap());
  if (null == object) {
    log.warn("Map not found in ValueStack");
    return super.end(writer,null);
  }
  if (!(object instanceof Map)) {
    log.warn("Error in JSP. Attribute map must evaluate to java.util.Map. Found type: " + object.getClass().getName());
    return super.end(writer,null);
  }
  component.addAllParameters((Map)object);
  return super.end(writer,null);
}
 

Example 16

From project Gemini-Blueprint, under directory /core/src/main/java/org/eclipse/gemini/blueprint/util/.

Source file: LogUtils.java

  31 
vote

private static Log doCreateLogger(Class<?> logName){
  Log logger;
  ClassLoader ccl=Thread.currentThread().getContextClassLoader();
  Thread.currentThread().setContextClassLoader(logName.getClassLoader());
  try {
    logger=LogFactory.getLog(logName);
  }
 catch (  Throwable th) {
    logger=new SimpleLogger();
    logger.fatal("logger infrastructure not properly set up. If commons-logging jar is used try switching to slf4j (see the FAQ for more info).",th);
  }
 finally {
    Thread.currentThread().setContextClassLoader(ccl);
  }
  return logger;
}
 

Example 17

From project httpClient, under directory /httpclient/src/test/java/org/apache/http/impl/conn/.

Source file: ConnPoolBench.java

  31 
vote

public static void newPool(int c,long reps) throws Exception {
  Log log=LogFactory.getLog(ConnPoolBench.class);
  HttpConnPool pool=new HttpConnPool(log,c,c * 10,-1,TimeUnit.MILLISECONDS);
  WorkerThread1[] workers=new WorkerThread1[c];
  for (int i=0; i < workers.length; i++) {
    workers[i]=new WorkerThread1(pool,reps);
  }
  long start=System.currentTimeMillis();
  for (int i=0; i < workers.length; i++) {
    workers[i].start();
  }
  for (int i=0; i < workers.length; i++) {
    workers[i].join();
  }
  long finish=System.currentTimeMillis();
  float totalTimeSec=(float)(finish - start) / 1000;
  System.out.print("Concurrency level:\t");
  System.out.println(c);
  System.out.print("Total operations:\t");
  System.out.println(c * reps);
  System.out.print("Time taken for tests:\t");
  System.out.print(totalTimeSec);
  System.out.println(" seconds");
}
 

Example 18

From project jAPS2, under directory /src/com/agiletec/apsadmin/tags/util/.

Source file: ParamMap.java

  31 
vote

@Override public boolean end(Writer writer,String body){
  Log log=LogFactory.getLog(ParamMap.class);
  Component component=this.findAncestor(Component.class);
  if (null == this.getMap()) {
    log.warn("Attribute map is mandatory.");
    return super.end(writer,null);
  }
  Object object=findValue(this.getMap());
  if (null == object) {
    log.warn("Map not found in ValueStack");
    return super.end(writer,null);
  }
  if (!(object instanceof Map)) {
    log.warn("Error in JSP. Attribute map must evaluate to java.util.Map. Found type: " + object.getClass().getName());
    return super.end(writer,null);
  }
  component.addAllParameters((Map)object);
  return super.end(writer,null);
}
 

Example 19

From project nuxeo-common, under directory /src/main/java/org/nuxeo/common/logging/.

Source file: JavaUtilLoggingHelper.java

  31 
vote

protected void doPublish(LogRecord record){
  Level level=record.getLevel();
  if (level == Level.FINER || level == Level.FINEST) {
    return;
  }
  String name=record.getLoggerName();
  Log log=cache.get(name);
  if (log == null) {
    log=LogFactory.getLog(name);
    cache.put(name,log);
  }
  if (level == Level.FINE) {
    log.trace(record.getMessage(),record.getThrown());
  }
 else   if (level == Level.CONFIG) {
    log.debug(record.getMessage(),record.getThrown());
  }
 else   if (level == Level.INFO) {
    log.info(record.getMessage(),record.getThrown());
  }
 else   if (level == Level.WARNING) {
    log.warn(record.getMessage(),record.getThrown());
  }
 else   if (level == Level.SEVERE) {
    log.error(record.getMessage(),record.getThrown());
  }
}
 

Example 20

From project nuxeo-tycho-osgi, under directory /nuxeo-common/src/main/java/org/nuxeo/common/logging/.

Source file: JavaUtilLoggingHelper.java

  31 
vote

protected void doPublish(LogRecord record){
  Level level=record.getLevel();
  if (level == Level.FINER || level == Level.FINEST) {
    return;
  }
  String name=record.getLoggerName();
  Log log=cache.get(name);
  if (log == null) {
    log=LogFactory.getLog(name);
    cache.put(name,log);
  }
  if (level == Level.FINE) {
    log.trace(record.getMessage(),record.getThrown());
  }
 else   if (level == Level.CONFIG) {
    log.debug(record.getMessage(),record.getThrown());
  }
 else   if (level == Level.INFO) {
    log.info(record.getMessage(),record.getThrown());
  }
 else   if (level == Level.WARNING) {
    log.warn(record.getMessage(),record.getThrown());
  }
 else   if (level == Level.SEVERE) {
    log.error(record.getMessage(),record.getThrown());
  }
}
 

Example 21

From project pangool, under directory /core/src/main/java/com/datasalt/pangool/solr/.

Source file: SolrRecordWriter.java

  31 
vote

static boolean setLogLevel(String packageName,String level){
  Log logger=LogFactory.getLog(packageName);
  if (logger == null) {
    return false;
  }
  LOG.warn("logger class:" + logger.getClass().getName());
  if (logger instanceof Log4JLogger) {
    process(((Log4JLogger)logger).getLogger(),level);
    return true;
  }
  if (logger instanceof Jdk14Logger) {
    process(((Jdk14Logger)logger).getLogger(),level);
    return true;
  }
  return false;
}
 

Example 22

From project spicy-stonehenge, under directory /common-library/src/main/java/nl/tudelft/stocktrader/dal/.

Source file: DAOFactory.java

  31 
vote

public static void loadProperties(){
  Log logger=LogFactory.getLog(DAOFactory.class);
  if (prop == null) {
    prop=new Properties();
    InputStream is=DAOFactory.class.getClassLoader().getResourceAsStream(StockTraderUtility.DB_PROPERRTIES_FILE);
    if (is != null) {
      try {
        prop.load(is);
      }
 catch (      IOException e) {
        logger.debug("Unable to load mysql-db properties file and using [jdbc:mysql://localhost/stocktraderdb?user=trade&password=trade] as the default connection",e);
      }
    }
 else {
      logger.debug("Unable to load mysql-db properties file and using [jdbc:mysql://localhost/stocktraderdb?user=trade&password=trade] as the default connection");
    }
  }
}
 

Example 23

From project spring-integration-extensions, under directory /spring-integration-smb/src/main/java/org/springframework/integration/smb/session/.

Source file: SmbSession.java

  31 
vote

/** 
 * Static configuration of the JCIFS library. The log level of this class is mapped to a suitable <code>jcifs.util.loglevel</code>
 */
static void configureJcifs(){
  final String sysPropLogLevel="jcifs.util.loglevel";
  if (jcifs.Config.getProperty(sysPropLogLevel) == null) {
    Log log=LogFactory.getLog(SmbSession.class);
    if (log.isTraceEnabled()) {
      jcifs.Config.setProperty(sysPropLogLevel,"N");
    }
 else     if (log.isDebugEnabled()) {
      jcifs.Config.setProperty(sysPropLogLevel,"3");
    }
 else {
      jcifs.Config.setProperty(sysPropLogLevel,"1");
    }
  }
}
 

Example 24

From project Blitz, under directory /src/com/laxser/blitz/util/.

Source file: TimeCostUtil.java

  29 
vote

/** 
 * ending a logger progress<br> if <code>begin &gt;0 && logger.isDebugEnabled()</code>, we will log something in the format:<br> <pre> 'Main'|clazz|method|cost|userid </pre> the cost is the costing time between <i>current time</i> and the <i>begin</i> <pre> Actually, the log4j can catch the class name and method name, but it costs more time and runs slower. </pre>
 * @param log the given logger
 * @param begin the starting time
 * @param clazz calling class
 * @param method calling method (or key and so on)
 * @param userid the user id if exist
 * @return the ending time (the current time in milliseconds) or<code>0</code> if the <i>begin &lt; 0</i>
 */
public static final long logEnd(Log log,long begin,String clazz,String method,int userid){
  if (begin > 0 && log.isDebugEnabled()) {
    long end=System.currentTimeMillis();
    final String f="%s|Main|%s|%s|%s|%s";
    log.debug(String.format(f,Thread.currentThread().getName(),clazz,method,(end - begin),userid));
    return end;
  }
  return 0;
}
 

Example 25

From project hama, under directory /core/src/main/java/org/apache/hama/bsp/.

Source file: Counters.java

  29 
vote

/** 
 * Logs the current counter values.
 * @param log The log to use.
 */
public void log(Log log){
  log.info("Counters: " + size());
  for (  Group group : this) {
    log.info("  " + group.getDisplayName());
    for (    Counter counter : group) {
      log.info("    " + counter.getDisplayName() + "="+ counter.getCounter());
    }
  }
}
 

Example 26

From project HBql, under directory /src/main/java/org/apache/hadoop/hbase/hbql/impl/.

Source file: Utils.java

  29 
vote

public static void logException(final Log log,final Exception e){
  final ByteArrayOutputStream baos=new ByteArrayOutputStream();
  final PrintWriter oos=new PrintWriter(baos);
  e.printStackTrace(oos);
  oos.flush();
  oos.close();
  log.debug(baos.toString());
}
 

Example 27

From project httpcore, under directory /httpcore-nio/src/test/java/org/apache/http/testserver/.

Source file: LoggingIOSession.java

  29 
vote

public LoggingIOSession(final IOSession session,final String id,final Log log,final Log wirelog){
  super();
  this.session=session;
  this.channel=new LoggingByteChannel();
  this.id=id;
  this.log=log;
  this.wirelog=new Wire(wirelog,this.id);
}
 

Example 28

From project james-hupa, under directory /client/src/test/java/org/apache/hupa/client/guice/.

Source file: GuiceClientTestModule.java

  29 
vote

@Override protected void configureHandlers(){
  Properties p=MockConstants.mockProperties;
  ConfigurationProperties.validateProperties(p);
  Names.bindProperties(binder(),p);
  bind(Session.class).toProvider(JavaMailSessionProvider.class);
  bind(HttpSession.class).toProvider(MockHttpSessionProvider.class);
  bind(Settings.class).toProvider(DefaultUserSettingsProvider.class).in(Singleton.class);
  bind(Log.class).toProvider(MockLogProvider.class).in(Singleton.class);
  bind(IMAPStore.class).to(MockIMAPStore.class);
  bind(IMAPStoreCache.class).to(DemoIMAPStoreCache.class).in(Singleton.class);
  bind(LoginUserHandler.class);
  bind(LogoutUserHandler.class);
  bind(IdleHandler.class);
  bind(FetchFoldersHandler.class);
  bind(CreateFolderHandler.class);
  bind(DeleteFolderHandler.class);
  bind(FetchMessagesHandler.class);
  bind(DeleteMessageByUidHandler.class);
  bind(GetMessageDetailsHandler.class);
  bind(AbstractSendMessageHandler.class).to(SendMessageHandler.class);
  bind(SendMessageHandler.class);
  bind(ReplyMessageHandler.class);
  bind(ForwardMessageHandler.class);
  bindHandler(Contacts.class,ContactsHandler.class);
  bindHandler(SendMessage.class,SendMessageHandler.class);
  bind(UserPreferencesStorage.class).to(InSessionUserPreferencesStorage.class);
  bind(User.class).to(TestUser.class).in(Singleton.class);
}
 

Example 29

From project Kairos, under directory /src/java/org/apache/nutch/util/.

Source file: LogUtil.java

  29 
vote

/** 
 * Returns a stream that, when written to, adds log lines. 
 */
private static PrintStream getLogStream(final Log logger,final Method method){
  return new PrintStream(new ByteArrayOutputStream(){
    private int scan=0;
    private boolean hasNewline(){
      for (; scan < count; scan++) {
        if (buf[scan] == '\n')         return true;
      }
      return false;
    }
    public void flush() throws IOException {
      if (!hasNewline())       return;
      try {
        method.invoke(logger,new Object[]{toString().trim()});
      }
 catch (      Exception e) {
        if (LOG.isFatalEnabled()) {
          LOG.fatal("Cannot log with method [" + method + "]",e);
        }
      }
      reset();
      scan=0;
    }
  }
,true);
}
 

Example 30

From project lenya, under directory /org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/file/.

Source file: FileItemManager.java

  29 
vote

/** 
 * Loads an item from a file.
 * @param file The file.
 * @return An item.
 * @throws AccessControlException when something went wrong.
 */
protected Item loadItem(File file) throws AccessControlException {
  Configuration config=getItemConfiguration(file);
  String fileName=file.getName();
  String id=fileName.substring(0,fileName.length() - getSuffix().length());
  Item item=(Item)this.items.get(id);
  String klass=ItemConfiguration.getItemClass(config);
  if (item == null) {
    try {
      Class[] paramTypes={ItemManager.class,Log.class};
      Constructor ctor=Class.forName(klass).getConstructor(paramTypes);
      Object[] params={this,getLogger()};
      item=(Item)ctor.newInstance(params);
    }
 catch (    Exception e) {
      String errorMsg="Exception when trying to instanciate: " + klass + " with exception: "+ e.fillInStackTrace();
      getLogger().error(errorMsg);
      throw new AccessControlException(errorMsg,e);
    }
  }
  try {
    item.configure(config);
  }
 catch (  ConfigurationException e) {
    String errorMsg="Exception when trying to configure: " + klass;
    throw new AccessControlException(errorMsg,e);
  }
  return item;
}
 

Example 31

From project license-maven-plugin, under directory /src/main/java/org/codehaus/mojo/license/model/.

Source file: LicenseStore.java

  29 
vote

public static LicenseStore createLicenseStore(org.apache.maven.plugin.logging.Log log,String... extraResolver) throws MojoExecutionException {
  LicenseStore store;
  try {
    store=new LicenseStore();
    store.addJarRepository();
    if (extraResolver != null) {
      for (      String s : extraResolver) {
        if (StringUtils.isNotEmpty(s)) {
          log.info("adding extra resolver " + s);
          store.addRepository(s);
        }
      }
    }
    store.init();
  }
 catch (  IllegalArgumentException ex) {
    throw new MojoExecutionException("could not obtain the license repository",ex);
  }
catch (  IOException ex) {
    throw new MojoExecutionException("could not obtain the license repository",ex);
  }
  return store;
}
 

Example 32

From project mwe, under directory /plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/.

Source file: WorkflowEngine.java

  29 
vote

private void logIssues(final Log logger,final Issues issues){
  final Diagnostic[] issueArray=issues.getIssues();
  for (  final Diagnostic issue : issueArray) {
    if (issue.getSeverity() == Diagnostic.ERROR) {
      logger.error(issue.toString());
    }
    if (issue.getSeverity() == Diagnostic.WARNING) {
      logger.warn(issue.toString());
    }
    if (issue.getSeverity() == Diagnostic.INFO) {
      logger.info(issue.toString());
    }
  }
}
 

Example 33

From project opencit, under directory /core/config/src/main/java/org/openengsb/opencit/core/config/.

Source file: OpenCitConfigurator.java

  29 
vote

private void addUtilImports() throws RuleBaseException {
  ruleManager.addImport(UUID.class.getCanonicalName());
  ruleManager.addImport(SimpleDateFormat.class.getCanonicalName());
  ruleManager.addImport(Date.class.getCanonicalName());
  ruleManager.addImport(WorkflowProcessInstance.class.getCanonicalName());
  ruleManager.addImport(List.class.getCanonicalName());
  ruleManager.addImport(Collection.class.getCanonicalName());
  ruleManager.addImport(ArrayList.class.getCanonicalName());
  ruleManager.addImport(Event.class.getCanonicalName());
  ruleManager.addImport(File.class.getCanonicalName());
  ruleManager.addImport(OpenEngSBFileModel.class.getCanonicalName());
  ruleManager.addImport(FileUtils.class.getCanonicalName());
  ruleManager.addImport(Log.class.getCanonicalName());
  ruleManager.addImport(LogFactory.class.getCanonicalName());
}
 

Example 34

From project org.ops4j.pax.logging, under directory /pax-logging-api/src/main/java/org/apache/commons/logging/.

Source file: LogFactory.java

  29 
vote

/** 
 * <p> Construct (if necessary) and return a <code>Log</code> instance, using the factory's current set of configuration attributes. </p> <p> <strong>NOTE</strong> - Depending upon the implementation of the <code>LogFactory</code> you are using, the <code>Log</code> instance you are returned may or may not be local to the current application, and may or may not be returned again on a subsequent call with the same name argument. </p>
 * @param name Logical name of the <code>Log</code> instance to be returned (the meaning of this name is only knownto the underlying logging implementation that is being wrapped)
 * @return the Log instance of the class with the given name.
 * @throws LogConfigurationException if a suitable <code>Log</code> instance cannot be returned
 */
public Log getInstance(String name) throws LogConfigurationException {
  PaxLogger logger;
  if (m_paxLogging == null) {
    logger=FallbackLogFactory.createFallbackLog(null,name);
  }
 else {
    logger=m_paxLogging.getLogger(name,JclLogger.JCL_FQCN);
  }
  JclLogger jclLogger=new JclLogger(logger);
synchronized (m_loggers) {
    m_loggers.put(jclLogger,name);
  }
  return jclLogger;
}
 

Example 35

From project perf4j, under directory /src/main/java/org/perf4j/commonslog/.

Source file: CommonsLogStopWatch.java

  29 
vote

/** 
 * This constructor is mainly used for creation of StopWatch instances from logs and for testing. Users should normally not call this constructor in client code.
 * @param startTime         The start time in milliseconds
 * @param elapsedTime       The elapsed time in milliseconds
 * @param tag               The tag used to group timing logs of the same code block
 * @param message           Additional message text
 * @param logger            The Log to use when persisting StopWatches in one of the stop or lap methods.
 * @param normalPriority    The level at which this StopWatch is logged if one of the stop or lap methods that doesNOT take an exception is called.
 * @param exceptionPriority The level at which this StopWatch is logged if one of the stop or lap methods that DOEStake an exception is called.
 */
public CommonsLogStopWatch(long startTime,long elapsedTime,String tag,String message,Log logger,int normalPriority,int exceptionPriority){
  super(startTime,elapsedTime,tag,message);
  this.logger=logger;
  this.normalPriority=normalPriority;
  this.exceptionPriority=exceptionPriority;
}
 

Example 36

From project sqoop, under directory /src/java/org/apache/sqoop/mapreduce/.

Source file: JobBase.java

  29 
vote

/** 
 * Display a notice on the log that the current MapReduce job has been retired, and thus Counters are unavailable.
 * @param log the Log to display the info to.
 */
protected void displayRetiredJobNotice(Log log){
  log.info("The MapReduce job has already been retired. Performance");
  log.info("counters are unavailable. To get this information, ");
  log.info("you will need to enable the completed job store on ");
  log.info("the jobtracker with:");
  log.info("mapreduce.jobtracker.persist.jobstatus.active = true");
  log.info("mapreduce.jobtracker.persist.jobstatus.hours = 1");
  log.info("A jobtracker restart is required for these settings");
  log.info("to take effect.");
}
 

Example 37

From project tika, under directory /tika-server/src/main/java/org/apache/tika/server/.

Source file: TikaResource.java

  29 
vote

public static void logRequest(Log logger,UriInfo info,Metadata metadata){
  if (metadata.get(org.apache.tika.metadata.HttpHeaders.CONTENT_TYPE) == null) {
    logger.info(String.format("%s (autodetecting type)",info.getPath()));
  }
 else {
    logger.info(String.format("%s (%s)",info.getPath(),metadata.get(org.apache.tika.metadata.HttpHeaders.CONTENT_TYPE)));
  }
}