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

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 commons-logging, under directory /src/test/org/apache/commons/logging/config/.

Source file: FirstPriorityConfigTestCase.java

  35 
vote

/** 
 * Verify that the config file being used is the one containing the desired configId value.
 */
public void testPriority() throws Exception {
  LogFactory instance=LogFactory.getFactory();
  ClassLoader thisClassLoader=this.getClass().getClassLoader();
  ClassLoader lfClassLoader=instance.getClass().getClassLoader();
  ClassLoader contextClassLoader=Thread.currentThread().getContextClassLoader();
  assertEquals(thisClassLoader,contextClassLoader);
  assertEquals(lfClassLoader,thisClassLoader.getParent());
  assertEquals(PathableClassLoader.class.getName(),lfClassLoader.getClass().getName());
  String id=(String)instance.getAttribute("configId");
  assertEquals("Correct config file loaded","priority20",id);
}
 

Example 2

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 3

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

Source file: JobEntryUtils.java

  30 
vote

public static Logger findLogger(String logName){
  Log log=LogFactory.getLog(logName);
  if (log instanceof org.apache.commons.logging.impl.Log4JLogger) {
    Logger logger=((org.apache.commons.logging.impl.Log4JLogger)log).getLogger();
    if (logger == null) {
      throw new IllegalArgumentException("Logger does not exist for log: " + logName);
    }
    return logger;
  }
 else   if (log == null) {
    throw new IllegalArgumentException("Unknown log name: " + logName);
  }
 else {
    throw new IllegalArgumentException("Unsupported logging type: " + log.getClass());
  }
}
 

Example 4

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

Source file: BlitzToolsInterceptor.java

  30 
vote

@Override public Object before(Invocation inv) throws Exception {
  Class<?> controllerClass=inv.getControllerClass();
  if (!LogFactory.getLog(controllerClass).isDebugEnabled()) {
    String msg=String.format("Warning: Set logger.%s to debug level first. " + "<br> Blitz-Version: %s",controllerClass.getName(),BlitzVersion.getVersion());
    return Utils.wrap(msg);
  }
  return true;
}
 

Example 5

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

Source file: SolrRecordWriter.java

  30 
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 6

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

Source file: CommonsLogStopWatchTest.java

  30 
vote

public void testStopWatch() throws Exception {
  LogFactory.getLog(StopWatch.DEFAULT_LOGGER_NAME).info("GOING_TO_STD_ERR");
  if (fakeErr.toString().indexOf("GOING_TO_STD_ERR") >= 0) {
    super.testStopWatch();
  }
 else {
    System.out.println("Logging isn't going to our std err as expected - skipping CommonsLogStopWatchTest");
  }
}
 

Example 7

From project sqoop, under directory /src/test/com/cloudera/sqoop/mapreduce/.

Source file: TestImportJob.java

  30 
vote

public void testFailedImportDueToIOException() throws IOException {
  createTableForColType("VARCHAR(32)","'meep'");
  Configuration conf=new Configuration();
  LogFactory.getLog(getClass()).info(" getWarehouseDir() " + getWarehouseDir());
  Path outputPath=new Path(new Path(getWarehouseDir()),getTableName());
  FileSystem fs=FileSystem.getLocal(conf);
  fs.mkdirs(outputPath);
  assertTrue(fs.exists(outputPath));
  String[] argv=getArgv(true,new String[]{"DATA_COL0"},conf);
  Sqoop importer=new Sqoop(new ImportTool());
  try {
    int ret=Sqoop.runSqoop(importer,argv);
    assertTrue("Expected ImportException running this job.",1 == ret);
  }
 catch (  Exception e) {
    LOG.info("Got exceptional return (expected: ok). msg is: " + e);
  }
}
 

Example 8

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

Source file: ScimUserEndpointsTests.java

  30 
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 9

From project Valkyrie-RCP, under directory /valkyrie-rcp-core/src/main/java/org/valkyriercp/application/exceptionhandling/.

Source file: DefaultRegisterableExceptionHandler.java

  30 
vote

public void uncaughtException(Thread thread,Throwable throwable){
  LogFactory.getLog(ApplicationLifecycleAdvisor.class).error(throwable.getMessage(),throwable);
  String exceptionMessage;
  if (throwable instanceof MessageSourceResolvable) {
    exceptionMessage=applicationConfig.messageSourceAccessor().getMessage((MessageSourceResolvable)throwable);
  }
 else {
    exceptionMessage=throwable.getLocalizedMessage();
  }
  if (!StringUtils.hasText(exceptionMessage)) {
    String defaultMessage="An application exception occurred.\nPlease contact your administrator.";
    exceptionMessage=applicationConfig.messageSourceAccessor().getMessage("applicationDialog.defaultException",defaultMessage);
  }
  Message message=new DefaultMessage(exceptionMessage,Severity.ERROR);
  ApplicationWindow activeWindow=applicationConfig.windowManager().getActiveWindow();
  JFrame parentFrame=(activeWindow == null) ? null : activeWindow.getControl();
  JOptionPane.showMessageDialog(parentFrame,message.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);
}
 

Example 10

From project arkadiko, under directory /src/com/liferay/arkadiko/util/.

Source file: AKFrameworkFactory.java

  29 
vote

public static Framework init(Map<String,String> properties) throws Exception {
  List<FrameworkFactory> frameworkFactories=AKServiceLoader.load(FrameworkFactory.class);
  if (frameworkFactories.isEmpty()) {
    return null;
  }
  FrameworkFactory frameworkFactory=frameworkFactories.get(0);
  Framework framework=frameworkFactory.newFramework(properties);
  framework.init();
  BundleContext bundleContext=framework.getBundleContext();
  bundleContext.registerService(LogFactory.class,LogFactory.getFactory(),new Hashtable<String,Object>());
  installBundles(bundleContext,properties);
  framework.start();
  startBundles(bundleContext,properties);
  return framework;
}
 

Example 11

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

Source file: SolrRecordWriter.java

  29 
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 12

From project discovery, under directory /src/main/java/com/tacitknowledge/util/discovery/.

Source file: ClasspathUtils.java

  29 
vote

/** 
 * Get the list of classpath components
 * @param ucl url classloader
 * @return List of classpath components
 */
private static List getUrlClassLoaderClasspathComponents(URLClassLoader ucl){
  List components=new ArrayList();
  URL[] urls=new URL[0];
  if (ucl.getClass().getName().equals("org.jboss.mx.loading.UnifiedClassLoader3")) {
    try {
      Method classPathMethod=ucl.getClass().getMethod("getClasspath",new Class[]{});
      urls=(URL[])classPathMethod.invoke(ucl,new Object[0]);
    }
 catch (    Exception e) {
      LogFactory.getLog(ClasspathUtils.class).debug("Error invoking getClasspath on UnifiedClassLoader3: ",e);
    }
  }
 else {
    urls=ucl.getURLs();
  }
  for (int i=0; i < urls.length; i++) {
    URL url=urls[i];
    components.add(getCanonicalPath(url.getPath()));
  }
  return components;
}
 

Example 13

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

Source file: ParamMap.java

  29 
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 14

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

Source file: LogUtils.java

  29 
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 15

From project ha-jdbc, under directory /src/main/java/net/sf/hajdbc/logging/commons/.

Source file: CommonsLoggingProvider.java

  29 
vote

/** 
 * {@inheritDoc}
 * @see net.sf.hajdbc.logging.LoggingProvider#isEnabled()
 */
@Override public boolean isEnabled(){
  try {
    LogFactory.getFactory();
    return true;
  }
 catch (  LogConfigurationException e) {
    return false;
  }
}
 

Example 16

From project hadoop_framework, under directory /core/src/main/java/com/lightboxtechnologies/spectrum/.

Source file: PythonJob.java

  29 
vote

public void eval(Reader script,String scriptName){
  LOG.info("Evaluating script " + scriptName);
  try {
    Engine.eval(script);
    LOG.info("Evaluated script successfully");
    String kt=(String)Engine.get("keyType"), vt=(String)Engine.get("valueType");
    LOG.info("keyType = " + kt + "; valueType = "+ vt);
    OutKey=createOutKey(kt);
    OutValue=createOutValue(vt);
    ScriptLog=LogFactory.getLog(new Path(scriptName).getName());
  }
 catch (  ScriptException err) {
    LOG.warn("Script had a problem in evaluation");
    throw new RuntimeException(err);
  }
}
 

Example 17

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

Source file: ThreadPool.java

  29 
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 18

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

Source file: AbstractConnPool.java

  29 
vote

/** 
 * Creates a new connection pool.
 */
protected AbstractConnPool(){
  super();
  this.log=LogFactory.getLog(getClass());
  this.leasedConnections=new HashSet<BasicPoolEntry>();
  this.idleConnHandler=new IdleConnectionHandler();
  this.poolLock=new ReentrantLock();
}
 

Example 19

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

Source file: LoggingBHttpClientConnection.java

  29 
vote

public LoggingBHttpClientConnection(int buffersize,final CharsetDecoder chardecoder,final CharsetEncoder charencoder,final MessageConstraints constraints,final ContentLengthStrategy incomingContentStrategy,final ContentLengthStrategy outgoingContentStrategy,final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,final HttpMessageParserFactory<HttpResponse> responseParserFactory){
  super(buffersize,chardecoder,charencoder,constraints,incomingContentStrategy,outgoingContentStrategy,requestWriterFactory,responseParserFactory);
  this.id="http-outgoing-" + COUNT.incrementAndGet();
  this.log=LogFactory.getLog(getClass());
  this.headerlog=LogFactory.getLog("org.apache.http.headers");
  this.wire=new Wire(LogFactory.getLog("org.apache.http.wire"),this.id);
}
 

Example 20

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

Source file: ParamMap.java

  29 
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 21

From project JGlobus, under directory /gridftp/src/main/java/org/globus/ftp/vanilla/.

Source file: TransferMonitor.java

  29 
vote

public TransferMonitor(BasicClientControlChannel controlChannel,TransferState transferState,MarkerListener mListener,int maxWait,int ioDelay,int side){
  logger=LogFactory.getLog(TransferMonitor.class.getName() + ((side == LOCAL) ? ".Local" : ".Remote"));
  this.controlChannel=controlChannel;
  this.transferState=transferState;
  this.mListener=mListener;
  this.maxWait=maxWait;
  this.ioDelay=ioDelay;
  abortable=true;
  aborted.flag=false;
  this.side=side;
}
 

Example 22

From project JsTestDriver, under directory /idea-plugin/src/com/google/jstestdriver/idea/ui/.

Source file: MainUI.java

  29 
vote

private static void configureLogging(){
  LogFactory.getFactory().setAttribute(JCL_LOG_CONFIG_ATTR,LogPanelLog.class.getName());
  System.setProperty(JETTY_LOG_CLASS_PROP,Slf4jLog.class.getName());
  System.setProperty(JCL_SIMPLELOG_SHOW_SHORT_LOGNAME,"false");
  System.setProperty(JCL_SIMPLELOG_SHOWLOGNAME,"false");
}
 

Example 23

From project Lily, under directory /cr/repo-util/src/main/java/org/lilyproject/util/repo/.

Source file: VersionTag.java

  29 
vote

/** 
 * Filters the given set of fields to only those that are vtag fields.
 */
public static Set<String> filterVTagFields(Set<String> fieldIds,TypeManager typeManager){
  Set<String> result=new HashSet<String>();
  for (  String field : fieldIds) {
    try {
      if (VersionTag.isVersionTag(typeManager.getFieldTypeById(field))) {
        result.add(field);
      }
    }
 catch (    FieldTypeNotFoundException e) {
    }
catch (    Throwable t) {
      LogFactory.getLog(VersionTag.class).error("Error loading field type to find out if it is a vtag field.",t);
    }
  }
  return result;
}
 

Example 24

From project Newsreader, under directory /bundles/org.apache.mime4j/src/org/apache/james/mime4j/parser/.

Source file: AbstractEntity.java

  29 
vote

AbstractEntity(BodyDescriptor parent,int startState,int endState,MimeEntityConfig config){
  this.log=LogFactory.getLog(getClass());
  this.parent=parent;
  this.state=startState;
  this.startState=startState;
  this.endState=endState;
  this.config=config;
  this.body=newBodyDescriptor(parent);
  this.linebuf=new ByteArrayBuffer(64);
  this.lineCount=0;
  this.endOfHeader=false;
  this.headerCount=0;
}
 

Example 25

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

Source file: JavaUtilLoggingHelper.java

  29 
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 26

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

Source file: JavaUtilLoggingHelper.java

  29 
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 27

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 28

From project org.ops4j.pax.logging, under directory /pax-logging-samples/logger/src/main/java/org/ops4j/pax/logging/example/.

Source file: Activator.java

  29 
vote

public void start(BundleContext bundleContext) throws Exception {
  m_jclLogger=LogFactory.getLog(Activator.class);
  m_juliLogger=org.apache.juli.logging.LogFactory.getLog(Activator.class);
  m_avalonLogger=AvalonLogFactory.getLogger(Activator.class.getName());
  m_slf4jLogger=LoggerFactory.getLogger(Activator.class);
  m_jdkLogger=java.util.logging.Logger.getLogger(Activator.class.getName());
  m_jclLogger.info("Starting Example...    (jcl)");
  m_avalonLogger.info("Starting Example...    (avalon)");
  m_slf4jLogger.info("Starting Example...    (slf4j)");
  m_jdkLogger.info("Starting Example...    (jdk)");
  m_juliLogger.info("Starting Example...    (juli)");
  HttpHandler handler=new TestHandler("test");
  InetAddrPort port=new InetAddrPort(8080);
  HttpListener listener=new SocketListener(port);
  m_server=new HttpServer();
  HttpContext context=new HttpContext();
  context.setContextPath("/");
  context.addHandler(handler);
  m_server.addContext(context);
  m_server.addListener(listener);
  m_server.start();
}
 

Example 29

From project org.ops4j.pax.runner, under directory /pax-runner/src/main/java/org/ops4j/pax/runner/.

Source file: Run.java

  29 
vote

/** 
 * Creates the logger to use at the specified log level. The log level is only supported by the "special" JCL implementation embedded into Pax Runner. In case that the JCL in the classpath in snot the embedded one it will fallback to standard JCL usage.
 * @param logLevel log level to use
 */
private static void createLogger(final LogLevel logLevel){
  try {
    LOGGER=LogFactory.getLog(Run.class,logLevel);
  }
 catch (  NoSuchMethodError ignore) {
    LOGGER=LogFactory.getLog(Run.class);
  }
}
 

Example 30

From project RSB, under directory /src/main/java/eu/openanalytics/rsb/config/.

Source file: RServiEnvironmentServletContextListener.java

  29 
vote

public void contextInitialized(final ServletContextEvent sce){
  ECommons.init("de.walware.rj.services.eruntime",this);
  logger=LogFactory.getLog("de.walware.rj.servi.pool");
  RjsComConfig.setProperty("rj.servi.graphicFactory",new RClientGraphicFactory(){
    public Map<String,? extends Object> getInitServerProperties(){
      return null;
    }
    public RClientGraphic newGraphic(    final int devId,    final double w,    final double h,    final InitConfig config,    final boolean active,    final RClientGraphicActions actions,    final int options){
      return new RClientGraphicDummy(devId,w,h);
    }
    public void closeGraphic(    final RClientGraphic graphic){
    }
  }
);
}
 

Example 31

From project slf4j_1, under directory /slf4j-jcl/src/main/java/org/slf4j/impl/.

Source file: JCLLoggerFactory.java

  29 
vote

public Logger getLogger(String name){
  Logger logger=null;
synchronized (this) {
    logger=(Logger)loggerMap.get(name);
    if (logger == null) {
      org.apache.commons.logging.Log jclLogger=LogFactory.getLog(name);
      logger=new JCLLoggerAdapter(jclLogger,name);
      loggerMap.put(name,logger);
    }
  }
  return logger;
}
 

Example 32

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

Source file: DAOFactory.java

  29 
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 33

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

Source file: Client.java

  29 
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 34

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

Source file: CommonsLoggingOperationCollectionAspectTest.java

  29 
vote

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

Example 35

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

Source file: SmbSession.java

  29 
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 36

From project spring-js, under directory /src/test/java/org/springframework/beans/factory/xml/.

Source file: XmlBeanFactoryTests.java

  29 
vote

public @Test void testLookupOverrideMethodsWithSetterInjection(){
  DefaultListableBeanFactory xbf=new DefaultListableBeanFactory();
  XmlBeanDefinitionReader reader=new XmlBeanDefinitionReader(xbf);
  reader.loadBeanDefinitions(OVERRIDES_CONTEXT);
  testLookupOverrideMethodsWithSetterInjection(xbf,"overrideOneMethod",true);
  testLookupOverrideMethodsWithSetterInjection(xbf,"overrideInheritedMethod",true);
  int howMany=100;
  StopWatch sw=new StopWatch();
  sw.start("Look up " + howMany + " prototype bean instances with method overrides");
  for (int i=0; i < howMany; i++) {
    testLookupOverrideMethodsWithSetterInjection(xbf,"overrideOnPrototype",false);
  }
  sw.stop();
  System.out.println(sw);
  if (!LogFactory.getLog(DefaultListableBeanFactory.class).isDebugEnabled()) {
    assertTrue(sw.getTotalTimeMillis() < 2000);
  }
  OverrideOneMethod swappedOom=(OverrideOneMethod)xbf.getBean("overrideOneMethodSwappedReturnValues");
  TestBean tb=swappedOom.getPrototypeDependency();
  assertEquals("David",tb.getName());
  tb=swappedOom.protectedOverrideSingleton();
  assertEquals("Jenny",tb.getName());
}
 

Example 37

From project spring-security, under directory /web/src/main/java/org/springframework/security/web/session/.

Source file: HttpSessionEventPublisher.java

  29 
vote

/** 
 * Handles the HttpSessionEvent by publishing a  {@link HttpSessionCreatedEvent} to the applicationappContext.
 * @param event HttpSessionEvent passed in by the container
 */
public void sessionCreated(HttpSessionEvent event){
  HttpSessionCreatedEvent e=new HttpSessionCreatedEvent(event.getSession());
  Log log=LogFactory.getLog(LOGGER_NAME);
  if (log.isDebugEnabled()) {
    log.debug("Publishing event: " + e);
  }
  getContext(event.getSession().getServletContext()).publishEvent(e);
}
 

Example 38

From project vmarket, under directory /src/main/java/org/apache/velocity/runtime/log/.

Source file: CommonsLogLogChute.java

  29 
vote

/** 
 * LogChute methods 
 */
public void init(RuntimeServices rs) throws Exception {
  String name=(String)rs.getProperty(LOGCHUTE_COMMONS_LOG_NAME);
  if (name == null) {
    name=DEFAULT_LOG_NAME;
  }
  log=LogFactory.getLog(name);
  log(LogChute.DEBUG_ID,"CommonsLogLogChute name is '" + name + "'");
}