List of usage examples for java.util.logging Logger getName
public String getName()
From source file:Main.java
static public final boolean isRoot(java.util.logging.Logger julLogger) { if (julLogger == null) return false; return julLogger.getName().equals(""); }
From source file:Main.java
static public final boolean isRegularNonRootLogger(java.util.logging.Logger julLogger) { if (julLogger == null) return false; return !julLogger.getName().equals(""); }
From source file:fr.opensagres.xdocreport.core.logging.LogUtils.java
private static void doLog(Logger log, Level level, String msg, Throwable t) { LogRecord record = new LogRecord(level, msg); record.setLoggerName(log.getName()); record.setResourceBundleName(log.getResourceBundleName()); record.setResourceBundle(log.getResourceBundle()); if (t != null) { record.setThrown(t);/* ww w. jav a2 s . c o m*/ } // try to get the right class name/method name - just trace // back the stack till we get out of this class StackTraceElement stack[] = (new Throwable()).getStackTrace(); String cname = LogUtils.class.getName(); for (int x = 0; x < stack.length; x++) { StackTraceElement frame = stack[x]; if (!frame.getClassName().equals(cname)) { record.setSourceClassName(frame.getClassName()); record.setSourceMethodName(frame.getMethodName()); break; } } log.log(record); }
From source file:org.apache.cxf.common.logging.LogUtils.java
private static void doLog(Logger log, Level level, String msg, Throwable t) { LogRecord record = new LogRecord(level, msg); record.setLoggerName(log.getName()); record.setResourceBundleName(log.getResourceBundleName()); record.setResourceBundle(log.getResourceBundle()); if (t != null) { record.setThrown(t);//from www . j a v a 2 s . c o m } //try to get the right class name/method name - just trace //back the stack till we get out of this class StackTraceElement stack[] = (new Throwable()).getStackTrace(); String cname = LogUtils.class.getName(); for (int x = 0; x < stack.length; x++) { StackTraceElement frame = stack[x]; if (!frame.getClassName().equals(cname)) { record.setSourceClassName(frame.getClassName()); record.setSourceMethodName(frame.getMethodName()); break; } } log.log(record); }
From source file:alma.acs.logging.AcsLogger.java
/** * Client applications that use ACS class <code>ComponentClient</code> may need to turn their own JDK Logger into * an <code>AcsLogger</code>. * <p>/* www.j a va 2 s. c o m*/ * If <code>logger</code> is itself of sub-type <code>AcsLogger</code> then it is returned directly without being wrapped. * The wrapping logger shares the parent logger and the log level with the provided logger. * * @param logger * the JDK logger * @param wrapperName * Name of the returned AcsLogger. May be <code>null</code> in which case the delegate's name plus * "wrapper" is taken. * @return an AcsLogger that delegates to the given <code>logger</code>. * @since ACS 8.0 */ public static AcsLogger fromJdkLogger(Logger logger, String wrapLoggerName) { if (logger instanceof AcsLogger) { return (AcsLogger) logger; } String acsLoggerName = (wrapLoggerName != null ? wrapLoggerName.trim() : logger.getName() + "wrapper"); AcsLogger ret = new AcsLogger(acsLoggerName, logger.getResourceBundleName(), null, true, logger); ret.setLevel(logger.getLevel()); ret.setParent(logger.getParent()); return ret; }
From source file:MailHandlerDemo.java
/** * Used debug problems with the logging.properties. The system property * java.security.debug=access,stack can be used to trace access to the * LogManager reset./*from www .j a v a 2s . co m*/ * * @param prefix a string to prefix the output. * @param err any PrintStream or null for System.out. */ @SuppressWarnings("UseOfSystemOutOrSystemErr") private static void checkConfig(String prefix, PrintStream err) { if (prefix == null || prefix.trim().length() == 0) { prefix = "DEBUG"; } if (err == null) { err = System.out; } try { err.println(prefix + ": java.version=" + System.getProperty("java.version")); err.println(prefix + ": LOGGER=" + LOGGER.getLevel()); err.println(prefix + ": JVM id " + ManagementFactory.getRuntimeMXBean().getName()); err.println(prefix + ": java.security.debug=" + System.getProperty("java.security.debug")); SecurityManager sm = System.getSecurityManager(); if (sm != null) { err.println(prefix + ": SecurityManager.class=" + sm.getClass().getName()); err.println(prefix + ": SecurityManager classLoader=" + toString(sm.getClass().getClassLoader())); err.println(prefix + ": SecurityManager.toString=" + sm); } else { err.println(prefix + ": SecurityManager.class=null"); err.println(prefix + ": SecurityManager.toString=null"); err.println(prefix + ": SecurityManager classLoader=null"); } String policy = System.getProperty("java.security.policy"); if (policy != null) { File f = new File(policy); err.println(prefix + ": AbsolutePath=" + f.getAbsolutePath()); err.println(prefix + ": CanonicalPath=" + f.getCanonicalPath()); err.println(prefix + ": length=" + f.length()); err.println(prefix + ": canRead=" + f.canRead()); err.println(prefix + ": lastModified=" + new java.util.Date(f.lastModified())); } LogManager manager = LogManager.getLogManager(); String key = "java.util.logging.config.file"; String cfg = System.getProperty(key); if (cfg != null) { err.println(prefix + ": " + cfg); File f = new File(cfg); err.println(prefix + ": AbsolutePath=" + f.getAbsolutePath()); err.println(prefix + ": CanonicalPath=" + f.getCanonicalPath()); err.println(prefix + ": length=" + f.length()); err.println(prefix + ": canRead=" + f.canRead()); err.println(prefix + ": lastModified=" + new java.util.Date(f.lastModified())); } else { err.println(prefix + ": " + key + " is not set as a system property."); } err.println(prefix + ": LogManager.class=" + manager.getClass().getName()); err.println(prefix + ": LogManager classLoader=" + toString(manager.getClass().getClassLoader())); err.println(prefix + ": LogManager.toString=" + manager); err.println(prefix + ": MailHandler classLoader=" + toString(MailHandler.class.getClassLoader())); err.println( prefix + ": Context ClassLoader=" + toString(Thread.currentThread().getContextClassLoader())); err.println(prefix + ": Session ClassLoader=" + toString(Session.class.getClassLoader())); err.println(prefix + ": DataHandler ClassLoader=" + toString(DataHandler.class.getClassLoader())); final String p = MailHandler.class.getName(); key = p.concat(".mail.to"); String to = manager.getProperty(key); err.println(prefix + ": TO=" + to); if (to != null) { err.println(prefix + ": TO=" + Arrays.toString(InternetAddress.parse(to, true))); } key = p.concat(".mail.from"); String from = manager.getProperty(key); if (from == null || from.length() == 0) { Session session = Session.getInstance(new Properties()); InternetAddress local = InternetAddress.getLocalAddress(session); err.println(prefix + ": FROM=" + local); } else { err.println(prefix + ": FROM=" + Arrays.asList(InternetAddress.parse(from, false))); err.println(prefix + ": FROM=" + Arrays.asList(InternetAddress.parse(from, true))); } synchronized (manager) { final Enumeration<String> e = manager.getLoggerNames(); while (e.hasMoreElements()) { final Logger l = manager.getLogger(e.nextElement()); if (l != null) { final Handler[] handlers = l.getHandlers(); if (handlers.length > 0) { err.println(prefix + ": " + l.getClass().getName() + ", " + l.getName()); for (Handler h : handlers) { err.println(prefix + ":\t" + toString(prefix, err, h)); } } } } } } catch (Throwable error) { err.print(prefix + ": "); error.printStackTrace(err); } err.flush(); }
From source file:net.kemitix.spring.common.logging.LoggerPostProcessorTest.java
/** * Test of postProcessBeforeInitialization method, of class * LoggerPostProcessor.// ww w . j a va2 s.c o m */ @Test public void testPostProcessBeforeInitialization() { System.out.println("postProcessBeforeInitialization"); //given LoggerProvider bean = new LoggerProvider() { @Log public Logger logger; @Override public Logger getLogger() { return logger; } }; //when Object result = loggerPostProcessor.postProcessBeforeInitialization(bean, null); //then assertThat(result, is(bean)); Logger logger = (Logger) getField(result, "logger"); assertThat(logger, is(not(nullValue()))); assertThat(logger.getName(), containsString(this.getClass().getName())); }
From source file:org.deviceconnect.android.deviceplugin.theta.ThetaDeviceApplication.java
@Override public void onCreate() { super.onCreate(); if (BuildConfig.DEBUG) { for (Logger logger : mLoggers) { AndroidHandler handler = new AndroidHandler(logger.getName()); handler.setFormatter(new SimpleFormatter()); handler.setLevel(Level.ALL); logger.addHandler(handler);//from www . ja v a 2 s. c o m logger.setLevel(Level.ALL); } } else { for (Logger logger : mLoggers) { logger.setLevel(Level.OFF); } } Context context = getApplicationContext(); mDeviceMgr = new ThetaDeviceManager(context); mHeadTracker = new HeadTrackerWrapper(new DefaultHeadTracker(context)); mSphericalViewApi = new SphericalViewApi(context); }
From source file:blue.lapis.pore.impl.PoreServer.java
public PoreServer(org.spongepowered.api.Game handle, org.slf4j.Logger logger) { super(handle.getServer()); this.game = handle; this.logger = Logger.getLogger(logger.getName()); this.commandMap = new PoreCommandMap(this); this.pluginManager = new SimplePluginManager(this, commandMap); this.servicesManager = new SimpleServicesManager(); Bukkit.setServer(this); }
From source file:com.machinepublishers.jbrowserdriver.Settings.java
private static void set(DesiredCapabilities capabilities, PropertyName name, Logger val) { capabilities.setCapability(name.propertyName, val == null ? null : val.getName()); }