Java 8 Logger - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Logger class.

This code example shows how to use the following methods:info, setParent
public class BCLog { 
 
	public static final Logger logger = Logger.getLogger("Buildcraft");
 
	public static void initLog() { 
		logger.setParent(FMLLog.getLogger());
		logger.info("Starting BuildCraft " + Version.getVersion());
		logger.info("Copyright (c) SpaceToad, 2011");
		logger.info("http://www.mod-buildcraft.com");
	} 
 
	public static void logErrorAPI(String mod, Throwable error, Class classFile) {
		StringBuilder msg = new StringBuilder(mod);
		msg.append(" API error, please update your mods. Error: ").append(error);
		StackTraceElement[] stackTrace = error.getStackTrace();
		if (stackTrace.length > 0)
			msg.append(", ").append(stackTrace[0]);
		logger.log(Level.SEVERE, msg.toString());
 
		if (classFile != null) {
8
CodeRank
This code example shows how to use the following methods:setLevel
        } else if ("warn".equalsIgnoreCase(level)) {
            logger.setLevel(Level.WARNING);
        } else if ("info".equalsIgnoreCase(level)) {
            logger.setLevel(Level.INFO);
        } else if ("debug".equalsIgnoreCase(level)) {
            logger.setLevel(Level.FINE);
        } else if ("trace".equalsIgnoreCase(level)) {
            logger.setLevel(Level.FINE);
        } 
    } 
 
    @Override 
    public String getLevel() {
        if (logger.getLevel() == null) {
            return null; 
        } 
        return logger.getLevel().toString();
    } 
 
    @Override 
8
CodeRank
This code example shows how to use the following methods:fine
 
    /** 
     * Resets and logs elapsed time in milliseconds. 
     */ 
    public void resetAndLog(String label) {
        logger.fine(label + ": " + reset() + "ms");
    } 
} 
8
CodeRank
This code example shows how to use the following methods:info
 
        final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "ejb3as7-1012.jar")
                .addPackage(AnnotatedDoNothingBean.class.getPackage())
                .addPackage(DoNothingBean.class.getPackage())
                .addAsManifestResource(DuplicateViewDefinitionTestCase.class.getPackage(), "ejb-jar.xml");
        log.info(archive.toString(true));
        return archive;
    } 
 
    @EJB(mappedName = "java:global/ejb3as7-1012/AnnotatedDoNothingBean!org.jboss.as.test.integration.ejb.view.duplicateview.DoNothing") 
    private DoNothing bean;
 
    @Test 
    public void testDoNothing() { 
        // if it deploys, we are good to go 
        bean.doNothing();
    } 
} 
8
CodeRank
This code example shows how to use the following methods:log, x 1
	@Test 
	@RunAsClient 
	@InSequence(2) 
	public void signIn() throws Exception { 
 
		logger.log(Level.INFO, "url = " + url);
		browser.get(url);
 
		assertTrue("emailField.isDisplayed()", emailField.isDisplayed());
		assertTrue("passwordField.isDisplayed()", passwordField.isDisplayed());
		assertTrue("signInButton.isDisplayed()", signInButton.isDisplayed());
 
		logger.log(Level.INFO, "clearing emailField");
		emailField.clear();
		logger.log(Level.INFO, "emailField.sendKeys ...");
		emailField.sendKeys("test@liferay.com");
		logger.log(Level.INFO, "clearing passwordField");
		passwordField.clear();
		logger.log(Level.INFO, "passwordField.sendKeys ...");
		passwordField.sendKeys("test");

8
CodeRank
This code example shows how to use the following methods:info
 
    @Deployment 
    public static Archive<?> deploy() { 
        JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ejb3-reentrantly-created-singleton.jar");
        jar.addPackage(SingletonReentrantPostConstructTestCase.class.getPackage());
        log.info(jar.toString(true));
        return jar;
    } 
 
    /** 
     * Indirectly invokes the {@link PostConstruct} annotated {@link SingletonBeanOne#initialise()} method. 
     */ 
    @Test 
    public void testReentrantPostConstruction() { 
        // trigger the bean creation life-cycle 
        try { 
            singletonBean.start();
            Assert.fail("Expected an EJBException");
        } catch (EJBException expected) {
            final Throwable cause = expected.getCause();
8
CodeRank
This code example shows how to use the following methods:finest
     * 
     * @param ctx A bootstrap context containing references 
     * @throws ResourceAdapterInternalException indicates bootstrap failure. 
     */ 
    public void start(BootstrapContext ctx) throws ResourceAdapterInternalException {
        log.finest("start()");
 
        WorkManager wm = ctx.getWorkManager();
 
        if (wm instanceof NamedWorkManager) {
            NamedWorkManager nw = (NamedWorkManager) wm;
            setWorkManager(nw);
            log.finest("Work-manager:" + nw);
        } 
 
    } 
 
    /** 
     * This is called when a resource adapter instance is undeployed or during application server shutdown. 
     */ 
7
CodeRank
This code example shows how to use the following methods:log
    @Override 
    public boolean isRegistered(String mBeanName) {
        try { 
            return server.isRegistered(createObjectName(mBeanName));
        } catch (MalformedObjectNameException e) {
            LOGGER.log(Level.WARNING, "Unable to register MBean " + mBeanName, e);
            return false; 
        } 
    } 
 
    @Override 
    public void unregisterMBean(String mBeanName) {
        try { 
            server.unregisterMBean(createObjectName(mBeanName));
        } catch (Exception e) {
            LOGGER.log(Level.WARNING, "Unable to register MBean " + mBeanName, e);
        } 
    } 
 
    @Override 
7
CodeRank
This code example shows how to use the following methods:finest
     * 
     * @param ctx A bootstrap context containing references 
     * @throws ResourceAdapterInternalException indicates bootstrap failure. 
     */ 
    public void start(BootstrapContext ctx) throws ResourceAdapterInternalException {
        log.finest("start()");
 
        if (ctx instanceof NamedBootstrapContext) {
            NamedBootstrapContext nc = (NamedBootstrapContext) ctx;
            setBootstrapContextName(nc.getName());
            log.finest("Bootstrap-context:" + nc.getName());
        } 
        WorkManager wm = ctx.getWorkManager();
 
        if (wm instanceof NamedWorkManager) {
            NamedWorkManager nw = (NamedWorkManager) wm;
            setWorkManagerName(nw.getName());
            log.finest("Work-manager:" + nw.getName());
        } 
 

7
CodeRank
This code example shows how to use the following methods:info, severe, warning
		String data = runner.runCmd(new String[]{"bash","-c","rvictl -s "+serialNumber});
		if(data != null && data.contains("[SUCCEEDED]")){
			success = true;
			logger.info("rvi is started ok.");
		}else{ 
			logger.warning("Failed to start RVI and now trying to load com.apple.rpmuxd");
			//failed? maybe because com.apple.rpmuxd is not loaded 
			//try to load it 
			runner.runCmd(new String[]{"bash","-c","echo "+this.sudoPassword+" | sudo -S launchctl load -w /System/Library/LaunchDaemons/com.apple.rpmuxd.plist"});
			data = runner.runCmd(new String[]{"bash","-c","rvictl -s "+serialNumber});
			if(data != null && data.contains("[SUCCEEDED]")){
				success = true;
				logger.info("RVI started after second attemp and loaded com.apple.rpmuxd");
			}else{ 
				logger.severe("Failed to start RVI event after second attempt to load com.apple.rpmuxd");
			} 
		} 
		if(success){
			logger.info("********** Starting tcpdump...");
			startTcpdump(pcapFilePath);

7
CodeRank

Related Java 8 Logger Questions & Answers:

See Code Examples for Java 8 Logger Methods: