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

This code example shows how to use the following methods: sleep, getProperty, readConfiguration
	/* 
	 * Test the constructor with no relevant log manager properties are set 
	 * except host and port. 
	 */ 
	public void testConstructor_NoBasicProperties() throws Exception { 
		assertNull(LOG_MANAGER.getProperty(
				"java.util.logging.SocketHandler.level")); 
		assertNull(LOG_MANAGER.getProperty(
				"java.util.logging.SocketHandler.filter")); 
		assertNull(LOG_MANAGER.getProperty(
				"java.util.logging.SocketHandler.formatter")); 
		assertNull(LOG_MANAGER.getProperty(
				"java.util.logging.SocketHandler.encoding")); 
		Properties p = new Properties();
		p.put("java.util.logging.SocketHandler.host", "127.0.0.1");
		p.put("java.util.logging.SocketHandler.port", "6666");
		LOG_MANAGER.readConfiguration(
				EnvironmentHelper.PropertiesToInputStream(p));
 
		// start the server to be ready to accept log messages 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: addLogger, getLogger
        // test name with space 
        Logger foo = new MockLogger(FOO, null);
        Logger fooBeforeSpace = new MockLogger(FOO + " ", null);
        Logger fooAfterSpace = new MockLogger(" " + FOO, null);
        Logger fooWithBothSpace = new MockLogger(" " + FOO + " ", null);
        assertTrue(mockManager.addLogger(foo));
        assertTrue(mockManager.addLogger(fooBeforeSpace));
        assertTrue(mockManager.addLogger(fooAfterSpace));
        assertTrue(mockManager.addLogger(fooWithBothSpace));
 
        assertSame(foo, mockManager.getLogger(FOO));
        assertSame(fooBeforeSpace, mockManager.getLogger(FOO + " "));
        assertSame(fooAfterSpace, mockManager.getLogger(" " + FOO));
        assertSame(fooWithBothSpace, mockManager.getLogger(" " + FOO + " "));
    } 
 
    /* 
     * test for method public void checkAccess() throws SecurityException 
     */ 
    public void testCheckAccess() { 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: readConfiguration, reset
    final static String baseClassName = OldMemoryHandlerTest.class.getName();
    MemoryHandler handler;
 
    @Override protected void setUp() throws Exception { 
        super.setUp(); 
        manager.reset();
        initProps(); 
        manager.readConfiguration(propertiesToInputStream(props));
        handler = new MemoryHandler();
    } 
 
    @Override protected void tearDown() throws Exception { 
        super.tearDown(); 
        manager.readConfiguration();
        props.clear();
    } 
 
    public static InputStream propertiesToInputStream(Properties p) throws IOException {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        p.store(bos, "");
Full Snippet Info
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getProperty
      throw new IOError(e);
    } 
  } 
 
  private static Level getLogLevelFromProperty(LogManager logManager, Level defaultLevel) {
    String levelStr = logManager.getProperty(ConsoleHandler.class.getName() + ".level");
    if (levelStr != null) {
      return Level.parse(levelStr);
    } else { 
      return defaultLevel;
    } 
  } 
 
  @VisibleForTesting 
  static OutputStreamWriter utf8OutputStreamWriter(OutputStream outputStream) {
    try { 
      return new OutputStreamWriter(outputStream, "UTF-8");
    } catch (UnsupportedEncodingException e) {
      throw new IOError(e);
    } 
Full Snippet Info
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: readConfiguration, reset
	/* 
	 * @see TestCase#setUp() 
	 */ 
	protected void setUp() throws Exception { 
		super.setUp(); 
		manager.reset();
		initProps(); 
		manager.readConfiguration(EnvironmentHelper
				.PropertiesToInputStream(props));
		handler = new MemoryHandler();
        errSubstituteStream = new NullOutputStream();
        System.setErr(new PrintStream(errSubstituteStream));
	} 
 
	/** 
	 * 
	 */ 
	private void initProps() { 
		props.put("java.util.logging.MemoryHandler.level", "FINE");
		props.put("java.util.logging.MemoryHandler.filter", baseClassName
Full Snippet Info
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: readConfiguration, reset
    FileHandler handler;
    LogRecord r;
 
    protected void setUp() throws Exception {
        super.setUp(); 
        manager.reset();
 
        //initProp 
        props.clear();
        props.put("java.util.logging.FileHandler.level", "FINE");
        props.put("java.util.logging.FileHandler.filter", className
                + "$MockFilter"); 
        props.put("java.util.logging.FileHandler.formatter", className
                + "$MockFormatter"); 
        props.put("java.util.logging.FileHandler.encoding", "iso-8859-1");
        // limit to only two message 
        props.put("java.util.logging.FileHandler.limit", "1000");
        // rotation count is 2 
        props.put("java.util.logging.FileHandler.count", "2");
        // using append mode 

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getProperty
		assertNull(m.getProperty("java.util.logging.FileHandler.pattern"));
	} 
 
	private static void checkProperty(LogManager m) {
		// assertEquals(m.getProperty(".level"), "INFO"); 
		assertEquals(m.getProperty("java.util.logging.FileHandler.limit"),
				"50000"); 
		assertEquals(m
				.getProperty("java.util.logging.ConsoleHandler.formatter"),
				"java.util.logging.SimpleFormatter"); 
		// assertEquals(m.getProperty("handlers"), 
		// "java.util.logging.ConsoleHandler"); 
		assertEquals(m.getProperty("java.util.logging.FileHandler.count"), "5");
		assertEquals(m.getProperty("LogManagerTestFoo.level"), "WARNING");
		assertEquals(m.getProperty("java.util.logging.FileHandler.formatter"),
				"java.util.logging.XMLFormatter"); 
		assertEquals(m.getProperty("java.util.logging.ConsoleHandler.level"),
				"OFF"); 
		assertEquals(m.getProperty("java.util.logging.FileHandler.pattern"),
				"%h/java%u.log"); 

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getLogger
   * Replaces all LogManager.getLogger(name) calls, adding a thread specific 
   * prefix which is appended to all logger names in dev mode in order to 
   * maintain a pseudo tree of loggers for each thread. 
   */ 
  public static Logger logManagerGetLogger(LogManager manager, String name) {
    return manager.getLogger(addLoggerPrefix(name));
  } 
 
  /** 
   * Replaces all LogManager.getLoggerNames() calls, deleting the thread specific 
   * prefix which is appended to all logger names in dev mode in order to 
   * maintain a pseudo tree of loggers for each thread.  Also deletes all logger 
   * names that do not start with the prefix since those belong to the server 
   * and should not be returned in this function. 
   */ 
  public static Enumeration<String> logManagerGetLoggerNames(LogManager manager) {
    Enumeration<String> loggerList = manager.getLoggerNames();
    List<String> newList = new ArrayList<String>();
    while (loggerList.hasMoreElements()) {
      String name = loggerList.nextElement();
Full Snippet Info
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: addLogger, getLogger
            LogHelper.s_logManager = LogManager.getLogManager();
            LogHelper.setGlobalParameters(); 
        } 
         
        String name = cl.getName();
        LogHelper logger = (LogHelper) LogHelper.s_logManager.getLogger(name);
         
        if (logger == null) {
            logger = new LogHelper(name);
            LogHelper.s_logManager.addLogger(logger);
            logger = (LogHelper) LogHelper.s_logManager.getLogger(name);
        } 
         
        return logger;
    } 
     
    private static void setGlobalParameters() { 
        Logger topLogger = Logger.getLogger("");
         
        Handler consoleHandler = null;
Full Snippet Info
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: readConfiguration, reset
    FileHandler handler;
    LogRecord r;
 
    protected void setUp() throws Exception { 
        super.setUp(); 
        manager.reset();
 
        //initProp 
        props.clear();
        props.put("java.util.logging.FileHandler.level", "FINE");
        props.put("java.util.logging.FileHandler.filter", className
                + "$MockFilter"); 
        props.put("java.util.logging.FileHandler.formatter", className
                + "$MockFormatter"); 
        props.put("java.util.logging.FileHandler.encoding", "iso-8859-1");
        // limit to only two message 
        props.put("java.util.logging.FileHandler.limit", "1000");
        // rotation count is 2 
        props.put("java.util.logging.FileHandler.count", "2");
        // using append mode 

4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 LogManager Methods: