Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.tectonica.log;
Configures J.U.L to print to the console using a Tectonica formatter. To use:
  1. add the following to your JVM arguments:
  2. optionally, if you want to state the minimum log level, add another argument, like this:
  3. optionally, if you want to provide your own formatter, add another argument, like this:

Zach Melamed
public class LogConfigConsole
	private static final String DEFAULT_LEVEL = "INFO";
	private static final String DEFAULT_FORMATTER = LogFormat.class.getName();
	public LogConfigConsole() throws Exception
		String level = System.getProperty("com.tectonica.log.level");
		if (level == null || level.isEmpty())
			level = ;
		String formatterClassName = System.getProperty("com.tectonica.log.formatter");
		if (formatterClassName == null || formatterClassName.isEmpty())
			formatterClassName = ;
		StringBuilder props = new StringBuilder();
		// configure globals
		props.append(".level = ").append(level).append("\n");
		// configure handlers
		String con = ConsoleHandler.class.getName();
		props.append("handlers = ").append(con).append("\n");
		// configure console handler
		props.append(con).append(".level = ").append(level).append("\n");
		props.append(con).append(".formatter = ").append(formatterClassName).append("\n");
		// apply configuration
		try (InputStream ins = new ByteArrayInputStream(props.toString().getBytes()))
		catch (Exception e)
New to GrepCode? Check out our FAQ X