Java 8 SimpleFormatter - 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 SimpleFormatter class.

This code example shows how to use the following methods:
        if ( logdir != null ) {
            try { 
                Logger logger = Logger.getLogger("prefuse");
                logger.setUseParentHandlers(false);
                Handler fileHandler = new FileHandler(logdir+"/"+logfile);
                fileHandler.setFormatter(new SimpleFormatter());
                logger.addHandler(fileHandler);
            } catch ( IOException e ) {
                e.printStackTrace();
            } 
        } 
    } 
     
    /** 
     * Get a prefuse configuration property. 
     * @param key the name of the property to lookup 
     * @return the property value, or null if the key is not found 
     */ 
    public static String get(String key) {
        return s_config.getProperty(key);
6
CodeRank
This code example shows how to use the following methods:
		logger.setLevel(Level.INFO);
		fileTxt = new FileHandler("Logging.txt");
		fileHTML = new FileHandler("Logging.html");
 
		// Create txt Formatter 
		formatterTxt = new SimpleFormatter();
		fileTxt.setFormatter(formatterTxt);
		logger.addHandler(fileTxt);
 
		// Create HTML Formatter 
		formatterHTML = new MyHtmlFormatter();
		fileHTML.setFormatter(formatterHTML);
		logger.addHandler(fileHTML);
	} 
} 
6
CodeRank
This code example shows how to use the following methods:getHead, getTail
public class OldSimpleFormatterTest extends TestCase {
 
    SimpleFormatter sf = new SimpleFormatter();
 
    public void testSimpleFormatter() { 
        assertEquals("Head for this SimpleFormatter should be empty", "", sf.getHead(null));
        assertEquals("Tail for this SimpleFormatter should be empty", "", sf.getTail(null));
    } 
} 
6
CodeRank
This code example shows how to use the following methods:
  static { 
    String LOGGER_NAME = "AnotherRunnerLogger";
    logger = Logger.getLogger(LOGGER_NAME);
    try { 
      FileHandler fileHandler = new FileHandler(LOGGER_NAME + ".log");
      fileHandler.setFormatter(new SimpleFormatter());
      logger.addHandler(fileHandler);
    } catch (IOException e) {
      throw new RuntimeException(e);
    } 
  } 
 
  public FeelingDifferentRunner(Class<?> klass) throws InitializationError {
    super(klass);
  } 
 
  @Override 
  protected Statement methodBlock(FrameworkMethod method) {
    logger.severe(method.toString());
    return super.methodBlock(method);
5
CodeRank
This code example shows how to use the following methods:format
		lr = new LogRecord(Level.FINE, MSG);
	} 
 
	public void testFormatNull() { 
		try { 
			sf.format(null);
			fail("should throw nullpointer exception");
		} catch (NullPointerException e) {
		} 
		sf.format(new LogRecord(Level.SEVERE, null));
	} 
 
	public void testLocalizedFormat() { 
		// if bundle set, should use localized message 
		ResourceBundle rb = ResourceBundle
				.getBundle("bundles/java/util/logging/res");
		lr.setResourceBundle(rb);
		lr.setMessage("msg");
		String localeMsg = rb.getString("msg");
		String str = sf.format(lr);
5
CodeRank
This code example shows how to use the following methods:
        if ( logdir != null ) {
            try { 
                Logger logger = Logger.getLogger("prefuse");
                logger.setUseParentHandlers(false);
                Handler fileHandler = new FileHandler(logdir+"/"+logfile);
                fileHandler.setFormatter(new SimpleFormatter());
                logger.addHandler(fileHandler);
            } catch ( IOException e ) {
                e.printStackTrace();
            } 
        } 
    } 
     
    /** 
     * Get a prefuse configuration property. 
     * @param key the name of the property to lookup 
     * @return the property value, or null if the key is not found 
     */ 
    public static String get(String key) {
        return s_config.getProperty(key);
5
CodeRank
This code example shows how to use the following methods:getHead, getTail
public class OldSimpleFormatterTest extends TestCase {
 
    SimpleFormatter sf = new SimpleFormatter();
 
    public void testSimpleFormatter() { 
        assertEquals("Head for this SimpleFormatter should be empty", "", sf.getHead(null));
        assertEquals("Tail for this SimpleFormatter should be empty", "", sf.getTail(null));
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
    public ByteArrayOutputStream baos;
    public StreamHandler streamHandler;
 
    public StubLogger() { 
        baos = new ByteArrayOutputStream(10000);
        streamHandler = new StreamHandler(baos, new SimpleFormatter());
        streamHandler.setLevel(Level.ALL);
        Logger logger = Logger.getLogger("");
        logger.addHandler(streamHandler);
    } 
 
    /** 
     * Returns any new java.util.logging messages since this method was last called,  
     * or since this object was constructed if this method has not yet been called. 
     */ 
    public String getNewLogMessages() {
        streamHandler.flush();
        String text = baos.toString();
        baos.reset();
        return text;
5
CodeRank
This code example shows how to use the following methods:
    @Override 
    public StandardOutputCapture start() { 
        super.start(); 
        if (!reset) {
            LogManager.getLogManager().reset();
            Logger.getLogger("").addHandler(new ConsoleHandler());
            reset = true;
        } 
        return this;
    } 
} 
6
CodeRank
This code example shows how to use the following methods:setLevel
 
	private SelectorThread threadSelector;
	private String baseUri;
 
	public TestServer(String aPackage) throws IllegalArgumentException, IOException {
		Handler h = new ConsoleHandler(); h.setLevel(Level.ALL);
		Logger.getLogger("").addHandler(h);
		 
		baseUri = "http://localhost:9998/";
		final Map<String, String> initParams = new HashMap<String, String>();
 
		initParams.put("com.sun.jersey.config.property.packages",
				aPackage);
 
		System.out.println("Starting grizzly...");
		threadSelector = GrizzlyWebContainerFactory.create(baseUri, initParams);
		System.out.println(String
				.format("Jersey app started with WADL available at %sapplication.wadl\n", baseUri));
	} 
	 
6
CodeRank
See Code Examples for Java 8 SimpleFormatter Methods: