getAnonymousLogger ( )源码实例Demo

java.util.logging.Logger#getAnonymousLogger ( )源码实例Demo

下面列出了java.util.logging.Logger#getAnonymousLogger ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: GLEXP-Team-onebillion   文件: OBUtils.java
public static String getExternalFilePathForFolder (String fileName, String folderName, OBSectionController controller)
{
    try
    {
        File outputDir = new File(Environment.getExternalStorageDirectory(), folderName);
        boolean folderCreated = outputDir.mkdir();
        File outputFile = new File(outputDir, fileName);
        return outputFile.getAbsolutePath();
    }
    catch (Exception exception)
    {
        Logger logger = Logger.getAnonymousLogger();
        logger.log(Level.SEVERE, "Error in getExternalFilePathForFolder", exception);
    }
    return null;
}
 
源代码2 项目: jdk8u-jdk   文件: LoggingDeadlock.java
public static void main(String[] args) throws InterruptedException{
    Thread t1 = new Thread(new Runnable() {
        public void run() {
            randomDelay();
            // Trigger Logger.<clinit>
            Logger.getAnonymousLogger();
        }
    });

    Thread t2 = new Thread(new Runnable() {
        public void run() {
            randomDelay();
            // Trigger LogManager.<clinit>
            LogManager.getLogManager();
        }
    });

    t1.start();
    t2.start();

    t1.join();
    t2.join();
    System.out.println("\nTest passed");
}
 
源代码3 项目: jdk8u60   文件: LoggingDeadlock.java
public static void main(String[] args) throws InterruptedException{
    Thread t1 = new Thread(new Runnable() {
        public void run() {
            randomDelay();
            // Trigger Logger.<clinit>
            Logger.getAnonymousLogger();
        }
    });

    Thread t2 = new Thread(new Runnable() {
        public void run() {
            randomDelay();
            // Trigger LogManager.<clinit>
            LogManager.getLogManager();
        }
    });

    t1.start();
    t2.start();

    t1.join();
    t2.join();
    System.out.println("\nTest passed");
}
 
源代码4 项目: jdk8u_jdk   文件: LoggingDeadlock.java
public static void main(String[] args) throws InterruptedException{
    Thread t1 = new Thread(new Runnable() {
        public void run() {
            randomDelay();
            // Trigger Logger.<clinit>
            Logger.getAnonymousLogger();
        }
    });

    Thread t2 = new Thread(new Runnable() {
        public void run() {
            randomDelay();
            // Trigger LogManager.<clinit>
            LogManager.getLogManager();
        }
    });

    t1.start();
    t2.start();

    t1.join();
    t2.join();
    System.out.println("\nTest passed");
}
 
源代码5 项目: openjdk-8-source   文件: LoggingDeadlock.java
public static void main(String[] args) throws InterruptedException{
    Thread t1 = new Thread(new Runnable() {
        public void run() {
            randomDelay();
            // Trigger Logger.<clinit>
            Logger.getAnonymousLogger();
        }
    });

    Thread t2 = new Thread(new Runnable() {
        public void run() {
            randomDelay();
            // Trigger LogManager.<clinit>
            LogManager.getLogManager();
        }
    });

    t1.start();
    t2.start();

    t1.join();
    t2.join();
    System.out.println("\nTest passed");
}
 
源代码6 项目: jdk8u-dev-jdk   文件: LoggingDeadlock.java
public static void main(String[] args) throws InterruptedException{
    Thread t1 = new Thread(new Runnable() {
        public void run() {
            randomDelay();
            // Trigger Logger.<clinit>
            Logger.getAnonymousLogger();
        }
    });

    Thread t2 = new Thread(new Runnable() {
        public void run() {
            randomDelay();
            // Trigger LogManager.<clinit>
            LogManager.getLogManager();
        }
    });

    t1.start();
    t2.start();

    t1.join();
    t2.join();
    System.out.println("\nTest passed");
}
 
源代码7 项目: hottub   文件: LoggingDeadlock.java
public static void main(String[] args) throws InterruptedException{
    Thread t1 = new Thread(new Runnable() {
        public void run() {
            randomDelay();
            // Trigger Logger.<clinit>
            Logger.getAnonymousLogger();
        }
    });

    Thread t2 = new Thread(new Runnable() {
        public void run() {
            randomDelay();
            // Trigger LogManager.<clinit>
            LogManager.getLogManager();
        }
    });

    t1.start();
    t2.start();

    t1.join();
    t2.join();
    System.out.println("\nTest passed");
}
 
源代码8 项目: sarl   文件: SarlScriptExecutor.java
@Override
public CompiledFile compile(int lineno, String code, List<String> issues, ICompilatedResourceReceiver receiver) throws Exception {
	File rootFolder = createRootFolder();
	File sourceFolder = createSourceFolder(rootFolder);
	File genFolder = createGenFolder(rootFolder);
	File binFolder = createBinFolder(rootFolder);
	final SarlBatchCompiler compiler = this.compilerProvider.get();
	compiler.setBasePath(rootFolder.getAbsolutePath());
	compiler.addSourcePath(sourceFolder);
	compiler.setClassOutputPath(binFolder);
	compiler.setOutputPath(genFolder);
	compiler.setGenerateGeneratedAnnotation(false);
	compiler.setGenerateInlineAnnotation(false);
	compiler.setGenerateSyntheticSuppressWarnings(true);
	compiler.setCleaningPolicy(CleaningPolicy.NO_CLEANING);
	compiler.setClassPath(this.classpath);
	compiler.setBootClassPath(this.bootClasspath);
	compiler.setJavaSourceVersion(this.sourceVersion);
	compiler.setAllWarningSeverities(Severity.IGNORE);
	compiler.setWarningSeverity(IssueCodes.DEPRECATED_MEMBER_REFERENCE, Severity.ERROR);
	compiler.setJavaCompilerVerbose(false);
	final Logger nopLogger = Logger.getAnonymousLogger();
	nopLogger.setLevel(Level.OFF);
	compiler.setLogger(nopLogger);
	if (issues != null) {
		compiler.addIssueMessageListener((issue, uri, message) -> {
			if (issue.isSyntaxError() || issue.getSeverity() == Severity.ERROR) {
				final Integer line = issue.getLineNumber();
				final int issueLine = (line == null ? 0 : line.intValue()) + lineno;
				issues.add(MessageFormat.format(Messages.SarlScriptExecutor_1, message, issueLine));
			}
		});
	}
	if (receiver != null) {
		compiler.addCompiledResourceReceiver(receiver);
	}
	File file = createFile(sourceFolder, code);
	compiler.compile();
	return new CompiledFile(rootFolder, file);
}
 
源代码9 项目: jdk8u-jdk   文件: TestAppletLoggerContext.java
public static void testOne() {
    for (int i=0; i<3 ; i++) {
        Logger logger1 = Logger.getAnonymousLogger();
        Logger logger1b = Logger.getAnonymousLogger();
        Bridge.changeContext();
        Logger logger2 = Logger.getAnonymousLogger();
        Logger logger2b = Logger.getAnonymousLogger();
        Bridge.changeContext();
        Logger logger3 = new Bridge.CustomAnonymousLogger();
        Logger logger3b = new Bridge.CustomAnonymousLogger();
        Bridge.changeContext();
        Logger logger4 = new Bridge.CustomAnonymousLogger();
        Logger logger4b = new Bridge.CustomAnonymousLogger();
    }
}
 
源代码10 项目: mail-importer   文件: ThunderbirdMailStorageTest.java
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);

  mailStorage = new ThunderbirdMailStorage(
      Logger.getAnonymousLogger(),
      rootFolder,
      new XMozillaStatusParser());
}
 
源代码11 项目: hottub   文件: TestAppletLoggerContext.java
public static void testOne() {
    for (int i=0; i<3 ; i++) {
        Logger logger1 = Logger.getAnonymousLogger();
        Logger logger1b = Logger.getAnonymousLogger();
        Bridge.changeContext();
        Logger logger2 = Logger.getAnonymousLogger();
        Logger logger2b = Logger.getAnonymousLogger();
        Bridge.changeContext();
        Logger logger3 = new Bridge.CustomAnonymousLogger();
        Logger logger3b = new Bridge.CustomAnonymousLogger();
        Bridge.changeContext();
        Logger logger4 = new Bridge.CustomAnonymousLogger();
        Logger logger4b = new Bridge.CustomAnonymousLogger();
    }
}
 
源代码12 项目: jdk8u-jdk   文件: TestAppletLoggerContext.java
public static void testOne() {
    for (int i=0; i<3 ; i++) {
        Logger logger1 = Logger.getAnonymousLogger();
        Logger logger1b = Logger.getAnonymousLogger();
        Bridge.changeContext();
        Logger logger2 = Logger.getAnonymousLogger();
        Logger logger2b = Logger.getAnonymousLogger();
        Bridge.changeContext();
        Logger logger3 = new Bridge.CustomAnonymousLogger();
        Logger logger3b = new Bridge.CustomAnonymousLogger();
        Bridge.changeContext();
        Logger logger4 = new Bridge.CustomAnonymousLogger();
        Logger logger4b = new Bridge.CustomAnonymousLogger();
    }
}
 
源代码13 项目: birt   文件: EngineLoggerTest.java
public void run( )
{
	try
	{
		FileHandler handler = new FileHandler( logFile );
		try
		{
			Logger logger = Logger.getAnonymousLogger( );
			logger.addHandler( handler );
			logger.setLevel( logLevel );
			logger.setUseParentHandlers( false );
			EngineLogger.setThreadLogger( logger );
			try
			{
				log( );
			}
			finally
			{
				EngineLogger.setThreadLogger( null );
			}
		}
		finally
		{
			handler.close( );
			count.decrementAndGet( );
			synchronized ( count )
			{
				count.notify( );
			}
		}
	}
	catch ( IOException ex )
	{
		ex.printStackTrace( );
	}
}
 
源代码14 项目: bazel   文件: SimpleLogHandlerTest.java
@Test
public void getLoggerFilePath_onMissingLogHandler_fails() throws Exception {
  HandlerQuerier handlerQuerier = new HandlerQuerier();
  Logger logger = Logger.getAnonymousLogger();

  assertThrows(IOException.class, () -> handlerQuerier.getLoggerFilePath(logger));
}
 
源代码15 项目: dragonwell8_jdk   文件: LoadItUp1.java
public Logger getAnonymousLogger(String rbName) throws Exception {
    // we should not be able to find the resource in this directory via
    // getLogger calls.  The only way that would be possible given this setup
    // is that if Logger.getLogger searched up the call stack
    return Logger.getAnonymousLogger(rbName);
}
 
源代码16 项目: hottub   文件: LoadItUp1.java
public Logger getAnonymousLogger(String rbName) throws Exception {
    // we should not be able to find the resource in this directory via
    // getLogger calls.  The only way that would be possible given this setup
    // is that if Logger.getLogger searched up the call stack
    return Logger.getAnonymousLogger(rbName);
}
 
源代码17 项目: openjdk-jdk9   文件: TestAnonymousLogger.java
public static void main(String[] args) {
    System.setSecurityManager(new SecurityManager());
    Logger anonymous = Logger.getAnonymousLogger();

    final TestHandler handler = new TestHandler();
    final TestFilter filter = new TestFilter();
    final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName());
    anonymous.setLevel(Level.FINEST);
    anonymous.addHandler(handler);
    anonymous.setFilter(filter);
    anonymous.setUseParentHandlers(true);
    anonymous.setResourceBundle(bundle);

    if (anonymous.getLevel() != Level.FINEST) {
        throw new RuntimeException("Unexpected level: " + anonymous.getLevel());
    } else {
        System.out.println("Got expected level: " + anonymous.getLevel());
    }
    if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) {
        throw new RuntimeException("Expected handler not found in: "
                + Arrays.asList(anonymous.getHandlers()));
    } else {
        System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers()));
    }
    if (anonymous.getFilter() != filter) {
        throw new RuntimeException("Unexpected filter: " + anonymous.getFilter());
    } else {
        System.out.println("Got expected filter: " + anonymous.getFilter());
    }
    if (!anonymous.getUseParentHandlers()) {
        throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers());
    } else {
        System.out.println("Got expected flag: " + anonymous.getUseParentHandlers());
    }
    if (anonymous.getResourceBundle() != bundle) {
        throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle());
    } else {
        System.out.println("Got expected bundle: " + anonymous.getResourceBundle());
    }
    try {
        anonymous.setParent(Logger.getLogger("foo.bar"));
        throw new RuntimeException("Expected SecurityException not raised!");
    } catch (SecurityException x) {
        System.out.println("Got expected exception: " + x);
    }
    if (anonymous.getParent() != Logger.getLogger("")) {
        throw new RuntimeException("Unexpected parent: " + anonymous.getParent());
    } else {
        System.out.println("Got expected parent: " + anonymous.getParent());
    }
}
 
源代码18 项目: bazel   文件: FileHandlerQuerierTest.java
private Logger getLoggerWithFileHandler(FileHandler handler) {
  Logger logger = Logger.getAnonymousLogger();
  logger.addHandler(handler);
  return logger;
}
 
源代码19 项目: jdk8u_jdk   文件: TestAnonymousLogger.java
public static void main(String[] args) {
    System.setSecurityManager(new SecurityManager());
    Logger anonymous = Logger.getAnonymousLogger();

    final TestHandler handler = new TestHandler();
    final TestFilter filter = new TestFilter();
    final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName());
    anonymous.setLevel(Level.FINEST);
    anonymous.addHandler(handler);
    anonymous.setFilter(filter);
    anonymous.setUseParentHandlers(true);
    anonymous.setResourceBundle(bundle);

    if (anonymous.getLevel() != Level.FINEST) {
        throw new RuntimeException("Unexpected level: " + anonymous.getLevel());
    } else {
        System.out.println("Got expected level: " + anonymous.getLevel());
    }
    if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) {
        throw new RuntimeException("Expected handler not found in: "
                + Arrays.asList(anonymous.getHandlers()));
    } else {
        System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers()));
    }
    if (anonymous.getFilter() != filter) {
        throw new RuntimeException("Unexpected filter: " + anonymous.getFilter());
    } else {
        System.out.println("Got expected filter: " + anonymous.getFilter());
    }
    if (!anonymous.getUseParentHandlers()) {
        throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers());
    } else {
        System.out.println("Got expected flag: " + anonymous.getUseParentHandlers());
    }
    if (anonymous.getResourceBundle() != bundle) {
        throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle());
    } else {
        System.out.println("Got expected bundle: " + anonymous.getResourceBundle());
    }
    try {
        anonymous.setParent(Logger.getLogger("foo.bar"));
        throw new RuntimeException("Expected SecurityException not raised!");
    } catch (SecurityException x) {
        System.out.println("Got expected exception: " + x);
    }
    if (anonymous.getParent() != Logger.getLogger("")) {
        throw new RuntimeException("Unexpected parent: " + anonymous.getParent());
    } else {
        System.out.println("Got expected parent: " + anonymous.getParent());
    }
}
 
源代码20 项目: jdk8u-dev-jdk   文件: TestAnonymousLogger.java
public static void main(String[] args) {
    System.setSecurityManager(new SecurityManager());
    Logger anonymous = Logger.getAnonymousLogger();

    final TestHandler handler = new TestHandler();
    final TestFilter filter = new TestFilter();
    final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName());
    anonymous.setLevel(Level.FINEST);
    anonymous.addHandler(handler);
    anonymous.setFilter(filter);
    anonymous.setUseParentHandlers(true);
    anonymous.setResourceBundle(bundle);

    if (anonymous.getLevel() != Level.FINEST) {
        throw new RuntimeException("Unexpected level: " + anonymous.getLevel());
    } else {
        System.out.println("Got expected level: " + anonymous.getLevel());
    }
    if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) {
        throw new RuntimeException("Expected handler not found in: "
                + Arrays.asList(anonymous.getHandlers()));
    } else {
        System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers()));
    }
    if (anonymous.getFilter() != filter) {
        throw new RuntimeException("Unexpected filter: " + anonymous.getFilter());
    } else {
        System.out.println("Got expected filter: " + anonymous.getFilter());
    }
    if (!anonymous.getUseParentHandlers()) {
        throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers());
    } else {
        System.out.println("Got expected flag: " + anonymous.getUseParentHandlers());
    }
    if (anonymous.getResourceBundle() != bundle) {
        throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle());
    } else {
        System.out.println("Got expected bundle: " + anonymous.getResourceBundle());
    }
    try {
        anonymous.setParent(Logger.getLogger("foo.bar"));
        throw new RuntimeException("Expected SecurityException not raised!");
    } catch (SecurityException x) {
        System.out.println("Got expected exception: " + x);
    }
    if (anonymous.getParent() != Logger.getLogger("")) {
        throw new RuntimeException("Unexpected parent: " + anonymous.getParent());
    } else {
        System.out.println("Got expected parent: " + anonymous.getParent());
    }
}