Java Code Examples for java.util.logging.Logger.getAnonymousLogger()

The following are Jave code examples for showing how to use getAnonymousLogger() of the java.util.logging.Logger class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: bibliome-java-utils   File: Test.java   View Source Code Vote up 7 votes
public static void main(String[] args) throws SAXException, IOException, ParserConfigurationException {
	File inputFile = new File(args[0]);
	
	DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
	DocumentBuilder docBuilder = dbf.newDocumentBuilder();
	Logger logger = Logger.getAnonymousLogger();
	logger.setLevel(Level.FINE);
	YateaHandler handler = new YateaHandler(logger, docBuilder);
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);
	XMLUtils.ignoreDTD(spf);
    SAXParser saxParser = spf.newSAXParser();
    saxParser.parse(inputFile, handler);
    Map<String,TermCandidate> candidates = handler.getTermCandidates();
    for (TermCandidate cand : candidates.values()) {
    	System.out.println(cand.toString() + ", HEAD:" + cand.getHead());
    }
}
 
Example 2
Project: 201710-paseos_01   File: FotosTestIntegracion.java   View Source Code Vote up 6 votes
@Test 
public void postman(){

    try {              
        Process process = Runtime.getRuntime().exec("/paseos-01-prueba-fotos");
        InputStream inputStream = process.getInputStream();
        BufferedReader bf= new BufferedReader(new InputStreamReader(inputStream));
        String line="";
        String ln;
        Logger log=Logger.getAnonymousLogger();
        
        while ((ln=bf.readLine()) != null) {
           log.info(ln);
            line=line.concat(ln);
        }
            
        inputStream.close();
        bf.close();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}
 
Example 3
Project: jdk8u-jdk   File: LoggingDeadlock.java   View Source Code Vote up 6 votes
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");
}
 
Example 4
Project: Pogamut3   File: SimpleLogging.java   View Source Code Vote up 6 votes
public static void initLogging(boolean time) {
	
	Logger log = Logger.getAnonymousLogger();
	while (log != null) {
		for (Handler handler : log.getHandlers()) {
			log.removeHandler(handler);
		}
		if (log.getParent() == null) {
			if (time) {
				log.addHandler(new TimeLogHandler());
			} else {
				log.addHandler(new SimpleLogHandler());
			}
		}
		log = log.getParent();
	}		
}
 
Example 5
Project: 201710-paseos_01   File: paseosTestIntegracion.java   View Source Code Vote up 6 votes
@Test 
public void postman(){

    try {              
        Process process = Runtime.getRuntime().exec("/paseos-01-prueba-paseos");
        InputStream inputStream = process.getInputStream();
        BufferedReader bf= new BufferedReader(new InputStreamReader(inputStream));
        String line="";
        String ln;
        Logger log=Logger.getAnonymousLogger();
        
        while ((ln=bf.readLine()) != null) {
           log.info(ln);
            line=line.concat(ln);
        }
            
        inputStream.close();
        bf.close();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}
 
Example 6
Project: Pogamut3   File: Main.java   View Source Code Vote up 5 votes
public static void main(String[] args) throws JSAPException {
//      FOR TESTING		
//		args = new String[] {
//			"-u",
//			"D:\\Games\\UT2004-Devel",
//			"-m",
//			"DM-TrainingDay",
//			"-c"			
//		};
		
		SimpleLogging.initLogging(true);
		
		log = Logger.getAnonymousLogger();
		
		initJSAP();
	    
	    header();
	    
	    readConfig(args);
	    
	    sanityChecks();
	    
	    if (convertAll) {
	    	transformAll();
	    } else {
	    	transformMaps(maps);
	    }
	    	
	}
 
Example 7
Project: Pogamut3   File: SimpleLogging.java   View Source Code Vote up 5 votes
public static void addFileLogging(final String pathToFile) {
	Logger log = Logger.getAnonymousLogger();
	
	
	try {
		final PrintWriter writer = new PrintWriter(new FileWriter(new File(pathToFile)));
		
		while (log != null) {
			if (log.getParent() == null) {
				log.addHandler(new Handler() {
					
					@Override
					public void close() throws SecurityException {
						writer.close();
					}

					@Override
					public void flush() {
						writer.flush();
					}

					@Override
					public void publish(LogRecord record) {
						writer.println("[" + record.getLevel() + "] " + record.getMessage());
					}
					
				});
			}
			log = log.getParent();
		}	
		
	} catch (IOException e) {
		throw new RuntimeException("Could not open file " + new File(pathToFile).getAbsolutePath() + " for logging!", e);
	}
	
}
 
Example 8
Project: openjdk-jdk10   File: TestAppletLoggerContext.java   View Source Code Vote up 5 votes
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();
    }
}
 
Example 9
Project: Elasticsearch   File: InjectorShell.java   View Source Code Vote up 5 votes
@Override
public Logger get(Errors errors, InternalContext context, Dependency<?> dependency) {
    InjectionPoint injectionPoint = dependency.getInjectionPoint();
    return injectionPoint == null
            ? Logger.getAnonymousLogger()
            : Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
}
 
Example 10
Project: openjdk-jdk10   File: LoadItUp1.java   View Source Code Vote up 4 votes
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);
}
 
Example 11
Project: jdk8u-jdk   File: TestAnonymousLogger.java   View Source Code Vote up 4 votes
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());
    }
}
 
Example 12
Project: Pogamut3   File: JavaDocStripper.java   View Source Code Vote up 4 votes
public static void main( String[] args ) {

if (args.length == 0) {
	printHelp();
	System.exit(1);
}

SimpleLogging.initLogging();
Logger log = Logger.getAnonymousLogger();

log.info("=====================");
log.info("JavaDoc Stripper Tool");
log.info("=====================");
log.info("");
log.info("Reading configuration...");

Substitution multiLineCommentSubst = new Substitution();
multiLineCommentSubst.setCaseSensitive(false);
multiLineCommentSubst.setMultiLine(true);
multiLineCommentSubst.setReMatch(multiLineCommentPattern);
multiLineCommentSubst.setReSubst("");

Substitution singleLineCommentSubst = new Substitution();
singleLineCommentSubst.setCaseSensitive(false);
singleLineCommentSubst.setMultiLine(false);
singleLineCommentSubst.setReMatch(singleLineCommentPattern);
singleLineCommentSubst.setReSubst("");

boolean recursive = "-r".equals(args[0]);

if (recursive) {
	log.info("'-r' paramter detected, will be recursively descending to subdirs.");
} else {
	log.info("'-r' parameter not specified, won't recursively descend to subdirs.");
}

RewriteFilesConfig config = new RewriteFilesConfig();

int i = recursive ? 1 : 0;
for (; i < args.length; ++i) {
	File file = new File(args[i]);
	if (!file.exists()) {
		log.warning("File/Dir (" + (i+1) + ". param) does not exist, ommiting: " + args[i] + " -> " + file.getAbsolutePath());
		continue;
	}
	
	IncludeDirForSubstitutions dir = new IncludeDirForSubstitutions();			
	if (file.isDirectory()) {
		log.info("Adding configuration for directory (" + (i+1) + ". param): " + args[i] + " -> " + file.getAbsolutePath());
		dir.setSubdirs(recursive);
		dir.setDir(file);
		dir.getIncludeFiles().add("*.java");
		dir.getSubstitutions().add(singleLineCommentSubst);
		dir.getSubstitutions().add(multiLineCommentSubst);								
	} else {
		log.info("Adding configuration for file      (" + (i+1) + ". param): " + args[i] + " -> " + file.getAbsolutePath());
		dir.setSubdirs(false);
		dir.setDir(file.getParentFile());
		dir.getIncludeFiles().add(file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf(fileSeparator)+1));
		dir.getSubstitutions().add(singleLineCommentSubst);
		dir.getSubstitutions().add(multiLineCommentSubst);
	}		
	
	config.getDirs().add(dir);
}

RewriteFiles rewriter = new RewriteFiles(config);
rewriter.setLog(log);
log.info("STRIPPING!");
rewriter.rewrite();

log.info("");
log.info("DONE!");

System.exit(0);
  }
 
Example 13
Project: businessworks   File: InjectorShell.java   View Source Code Vote up 4 votes
public Logger get(Errors errors, InternalContext context, Dependency<?> dependency, boolean linked) {
  InjectionPoint injectionPoint = dependency.getInjectionPoint();
  return injectionPoint == null
      ? Logger.getAnonymousLogger()
      : Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
}
 
Example 14
Project: jdk8u-jdk   File: LoadItUp1.java   View Source Code Vote up 4 votes
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);
}
 
Example 15
Project: asf-gitpubsub-jenkins-plugin   File: ASFGitSCMNavigatorTest.java   View Source Code Vote up 4 votes
@NonNull
@Override
public TaskListener getListener() {
    return new LogTaskListener(Logger.getAnonymousLogger(), Level.INFO);
}
 
Example 16
Project: businessworks   File: InjectorShell.java   View Source Code Vote up 4 votes
public Logger get() {
  return Logger.getAnonymousLogger();
}
 
Example 17
Project: elasticsearch_my   File: InjectorShell.java   View Source Code Vote up 4 votes
@Override
public Logger get() {
    return Logger.getAnonymousLogger();
}
 
Example 18
Project: Elasticsearch   File: InjectorShell.java   View Source Code Vote up 4 votes
@Override
public Logger get() {
    return Logger.getAnonymousLogger();
}
 
Example 19
Project: myfaces-trinidad   File: TrinidadLogger.java   View Source Code Vote up 2 votes
/**
 * Create an anonymous Logger.  The newly created Logger is not
 * registered in the LogManager namespace.  There will be no
 * access checks on updates to the logger.
 * <p>
 * This factory method is primarily intended for use from applets.
 * Because the resulting Logger is anonymous it can be kept private
 * by the creating class.  This removes the need for normal security
 * checks, which in turn allows untrusted applet code to update
 * the control state of the Logger.  For example an applet can do
 * a setLevel or an addHandler on an anonymous Logger.
 * <p>
 * Even although the new logger is anonymous, it is configured
 * to have the root logger ("") as its parent.  This means that
 * by default it inherits its effective level and handlers
 * from the root logger.
 * <p>
 *
 * @return a newly created private Logger
 */
public static TrinidadLogger getAnonymousLogger() 
{
  return new TrinidadLogger(Logger.getAnonymousLogger());    
}
 
Example 20
Project: myfaces-trinidad   File: TrinidadLogger.java   View Source Code Vote up 2 votes
/**
 * Create an anonymous Logger.  The newly created Logger is not
 * registered in the LogManager namespace.  There will be no
 * access checks on updates to the logger.
 * <p>
 * This factory method is primarily intended for use from applets.
 * Because the resulting Logger is anonymous it can be kept private
 * by the creating class.  This removes the need for normal security
 * checks, which in turn allows untrusted applet code to update
 * the control state of the Logger.  For example an applet can do
 * a setLevel or an addHandler on an anonymous Logger.
 * <p>
 * Even although the new logger is anonymous, it is configured
 * to have the root logger ("") as its parent.  This means that
 * by default it inherits its effective level and handlers
 * from the root logger.
 * <p>
 * @param     resourceBundleName  name of ResourceBundle to be used for localizing
 *                messages for this logger.
 * @return a newly created private Logger
 * @throws MissingResourceException if the named ResourceBundle cannot be found.
 */
public static TrinidadLogger getAnonymousLogger(String resourceBundleName) 
{
  return new TrinidadLogger(Logger.getAnonymousLogger(resourceBundleName));
}