org.apache.commons.logging.impl.Jdk14Logger Java Examples

The following examples show how to use org.apache.commons.logging.impl.Jdk14Logger. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AlipayLogger.java    From alipay-sdk with Apache License 2.0 5 votes vote down vote up
/**
 * 开启DEBUG级别日志(仅针对JDK14LOGGER,LOG4J请自行修改配置文件)
 * 
 * @param isEnabled
 */
public static void setJDKDebugEnabled(Boolean isEnabled) {
    //如果使用JDK14LOGGER,将业务日志级别设为DEBUG(FINE)
    if (blog instanceof Jdk14Logger) {
        Jdk14Logger logger = (Jdk14Logger) blog;
        if (isEnabled) {
            logger.getLogger().setLevel(Level.FINE);
            Handler consoleHandler = new ConsoleHandler();
            consoleHandler.setLevel(Level.FINE);
            logger.getLogger().addHandler(consoleHandler);
        } else {
            logger.getLogger().setLevel(Level.INFO);
        }
    }
}
 
Example #2
Source File: AlipayLogger.java    From pay with Apache License 2.0 5 votes vote down vote up
public static void setJDKDebugEnabled(Boolean isEnabled) {
    //如果使用JDK14LOGGER,将业务日志级别设为DEBUG(FINE)
    if (blog instanceof Jdk14Logger) {
        Jdk14Logger logger = (Jdk14Logger) blog;
        if (isEnabled) {
            logger.getLogger().setLevel(Level.FINE);
            Handler consoleHandler = new ConsoleHandler();
            consoleHandler.setLevel(Level.FINE);
            logger.getLogger().addHandler(consoleHandler);
        } else {
            logger.getLogger().setLevel(Level.INFO);
        }
    }
}
 
Example #3
Source File: ModulesServlet.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
@Override
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        
        moduleManager=new ModuleManager();
        
        servletHome=config.getServletContext().getRealPath("/")+"WEB-INF";
        moduleManager.setVariable("servletHome", servletHome);
        
//        SimpleLog log=new SimpleLog("ModulesServlet");
//        log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
        Log log=new Jdk14Logger("ModulesServlet");
        moduleManager.setLogging(log);
        String configFile=config.getInitParameter("modulesconfig");
        if(configFile==null) {
            configFile=config.getInitParameter("modulesConfig");
            if(configFile==null) configFile="modulesconfig.xml";
        }
        
        bindAddress=config.getInitParameter("bindaddress");
        if(bindAddress==null){
            bindAddress=config.getInitParameter("bindAddress");
        }
        
        moduleManager.addModule(servletModule,new ModuleSettings("rootServlet"));                
        moduleManager.readXMLOptionsFile(configFile);
        
        if(bindAddress==null){
            bindAddress=moduleManager.getVariable("bindAddress");
            if(bindAddress==null) bindAddress=DEFAULT_BIND_ADDRESS;
        }
        
        try{
            moduleManager.autostartModules();
        }catch(ModuleException me){
            throw new ServletException("Unable to start modules.",me);
        }
    }
 
Example #4
Source File: WandoraModulesServer.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
public WandoraModulesServer(Wandora wandora){
    this.wandora = wandora;
    jettyServer = new Server();

    rootLog = new Jdk14Logger("ModulesServlet");
    log = rootLog;

    Options options = wandora.getOptions();
    readOptions(options);
    
    mimeTypes = new MimeTypes();
    
    initModuleManager();
    readBundleDirectories();
}
 
Example #5
Source File: AppDataSourceTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Test
public void run() throws OpenEJBException, NamingException, IOException {
    final File tempWar = new File("target/AppDataSourceTest");
    tempWar.mkdirs();
    new File(tempWar, "WEB-INF").mkdirs();
    IO.writeString(new File(tempWar, "WEB-INF/resources.xml"),
            "<resources>\n" +
                "<Resource id=\"java:app/gace/MyDS\" type=\"DataSource\">\n" +
                "DataSourceCreator=dbcp\n" +
                "</Resource>\n" +
            "</resources>\n");
    final Collection<LogRecord> records = new ArrayList<>();
    try (final Container c = new Container(new Configuration().randomHttpPort())) {
        Jdk14Logger.class.cast(LogFactory.getLog(BasicDataSource.class)).getLogger().addHandler(new Handler() {
            @Override
            public void publish(final LogRecord record) {
                if (record.getLevel() == Level.SEVERE || record.getLevel() == Level.WARNING) {
                    records.add(record);
                }
            }

            @Override
            public void flush() {
                // no-op
            }

            @Override
            public void close() throws SecurityException {
                // no-op
            }
        });
        c.deploy(null, tempWar);
    }

    // if we have the JMX bug of dbcp2 integration (in 7.0.0) then we have a WARNING record from BasicDataSource.close()
    // saying:
    // Failed to unregister the JMX name:
    //     Tomcat:type=DataSource,host=localhost,context=/AppDataSourceTest,class=javax.sql.DataSource,name="openejb/Resource/AppDataSourceTest/app/gace/MyDS"
    assertTrue(records.isEmpty());
}