/** * Installs a {@code MonolineFormatter} for the root logger, or returns the existing instance if any. * This method performs the following choices: * * <ul> * <li>If a {@link ConsoleHandler} is associated to the root logger, then: * <ul> * <li>If that handler already uses a {@code MonolineFormatter}, then the existing formatter is returned.</li> * <li>Otherwise the {@code ConsoleHandler} formatter is replaced by a new {@code MonolineFormatter} instance, * and that new instance is returned. We perform this replacement in order to avoid sending twice the same * records to the console.</li> * </ul></li> * <li>Otherwise a new {@code ConsoleHandler} using a new {@code MonolineFormatter} is created and added to the * root logger.</li> * </ul> * * <div class="note"><b>Implementation note:</b> * The current implementation does not check for duplicated {@code ConsoleHandler} instances, * and does not check if any child logger has a {@code ConsoleHandler}.</div> * * @return the new or existing {@code MonolineFormatter}. The formatter output can be configured * using the {@link #setTimeFormat(String)} and {@link #setSourceFormat(String)} methods. * @throws SecurityException if this method does not have the permission to install the formatter. */ @Configuration public static MonolineFormatter install() throws SecurityException { return install(Logging.getLogger(""), null); }
/** * Installs a {@code MonolineFormatter} for the root logger, or returns the existing instance if any. * This method performs the following choices: * * <ul> * <li>If a {@link ConsoleHandler} is associated to the root logger, then: * <ul> * <li>If that handler already uses a {@code MonolineFormatter}, then the existing formatter is returned.</li> * <li>Otherwise the {@code ConsoleHandler} formatter is replaced by a new {@code MonolineFormatter} instance, * and that new instance is returned. We perform this replacement in order to avoid sending twice the same * records to the console.</li> * </ul></li> * <li>Otherwise a new {@code ConsoleHandler} using a new {@code MonolineFormatter} is created and added to the * root logger.</li> * </ul> * * <div class="note"><b>Implementation note:</b> * The current implementation does not check for duplicated {@code ConsoleHandler} instances, * and does not check if any child logger has a {@code ConsoleHandler}.</div> * * @return the new or existing {@code MonolineFormatter}. The formatter output can be configured * using the {@link #setTimeFormat(String)} and {@link #setSourceFormat(String)} methods. * @throws SecurityException if this method does not have the permission to install the formatter. */ @Configuration public static MonolineFormatter install() throws SecurityException { return install(Logging.getLogger(""), null); }
MonolineFormatter.install();
if ("server".equalsIgnoreCase(get(properties, "platform", "desktop"))) { } else { MonolineFormatter.install();
/** * Installs Apache SIS monoline formatter for easier identification of Apache SIS log messages among Maven outputs. * We perform this installation only for {@code *TestSuite}, not for individual {@code *Test}. Consequently this is * typically enabled when building a whole module with Maven but not when debugging an individual class. * * @since 1.0 */ @BeforeClass public static void configureLogging() { MonolineFormatter f = MonolineFormatter.install(); f.setHeader(null); f.setTimeFormat(null); f.setSourceFormat("class.method"); }