Search in sources :

Example 86 with Logger

use of java.util.logging.Logger in project OpenAM by OpenRock.

the class OpenSSOLogger method log.

public static void log(LogLevel type, Level level, String msgid, String[] msgdata, Subject logFor) {
    Logger logger = (type.equals(LogLevel.ERROR)) ? LoggerFactory.getLogger(LOG_NAME + ".error") : LoggerFactory.getLogger(LOG_NAME + ".access");
    if (logger.isLoggable(level)) {
        try {
            LogMessageProvider msgProvider = MessageProviderFactory.getProvider(LOG_MSG_XML);
            LogRecord logRec = msgProvider.createLogRecord(msgid, msgdata, SubjectUtils.getSSOToken(logFor));
            if (logRec != null) {
                logger.log(getERecord(logRec));
            }
        } catch (IOException ex) {
            Logger.getLogger(OpenSSOLogger.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
Also used : LogMessageProvider(com.sun.identity.log.messageid.LogMessageProvider) ELogRecord(com.sun.identity.entitlement.log.ELogRecord) LogRecord(com.sun.identity.log.LogRecord) IOException(java.io.IOException) Logger(java.util.logging.Logger)

Example 87 with Logger

use of java.util.logging.Logger in project android_frameworks_base by ResurrectionRemix.

the class CookiesTest method testCookiesAreNotLogged.

/**
     * Test that we don't log potentially sensitive cookie values.
     * http://b/3095990
     */
public void testCookiesAreNotLogged() throws IOException, URISyntaxException {
    // enqueue an HTTP response with a cookie that will be rejected
    server.enqueue(new MockResponse().addHeader("Set-Cookie: password=secret; Domain=fake.domain"));
    server.play();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Logger logger = Logger.getLogger("org.apache.http");
    StreamHandler handler = new StreamHandler(out, new SimpleFormatter());
    logger.addHandler(handler);
    try {
        HttpClient client = new DefaultHttpClient();
        client.execute(new HttpGet(server.getUrl("/").toURI()));
        handler.close();
        String log = out.toString("UTF-8");
        assertTrue(log, log.contains("password"));
        assertTrue(log, log.contains("fake.domain"));
        assertFalse(log, log.contains("secret"));
    } finally {
        logger.removeHandler(handler);
    }
}
Also used : MockResponse(com.google.mockwebserver.MockResponse) StreamHandler(java.util.logging.StreamHandler) SimpleFormatter(java.util.logging.SimpleFormatter) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) HttpClient(org.apache.http.client.HttpClient) HttpGet(org.apache.http.client.methods.HttpGet) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Logger(java.util.logging.Logger) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient)

Example 88 with Logger

use of java.util.logging.Logger in project Info-Evaluation by TechnionYP5777.

the class Row method add.

public <T> void add(T data) {
    Logger logi = Logger.getLogger(Row.class.getName());
    logi.log(Level.INFO, "Data type is: " + data.getClass().getName() + "Data is :" + data);
    this.row.add(new AbstractMap.SimpleImmutableEntry<Object, Class>(data, data.getClass()));
}
Also used : AbstractMap(java.util.AbstractMap) Logger(java.util.logging.Logger)

Example 89 with Logger

use of java.util.logging.Logger in project pcgen by PCGen.

the class Logging method debugPrintLocalised.

/**
	 * Print localised information message if PCGen is debugging.
	 *
	 * @param message String information message (usually variable)
	 * @param params Object information message (usually value)
	 */
public static void debugPrintLocalised(final String message, Object... params) {
    Logger l = getLogger();
    if (l.isLoggable(DEBUG)) {
        String msg = LanguageBundle.getFormattedString(message, params);
        l.log(DEBUG, msg);
    }
}
Also used : Logger(java.util.logging.Logger)

Example 90 with Logger

use of java.util.logging.Logger in project pcgen by PCGen.

the class Logging method debugPrint.

/**
	 * Print the message. Currently quietly discards the Throwable.
	 *
	 * @param s String error message
	 * @param thr Throwable stack frame
	 */
public static void debugPrint(final String s, final Throwable thr) {
    debugPrint(s);
    Logger l = getLogger();
    if (l != null && l.isLoggable(DEBUG)) {
        thr.printStackTrace(System.err);
    }
}
Also used : Logger(java.util.logging.Logger)

Aggregations

Logger (java.util.logging.Logger)499 Test (org.junit.Test)70 LogRecord (java.util.logging.LogRecord)60 ActionReport (org.glassfish.api.ActionReport)56 Handler (java.util.logging.Handler)52 IOException (java.io.IOException)37 File (java.io.File)36 Level (java.util.logging.Level)25 ArrayList (java.util.ArrayList)22 ConsoleHandler (java.util.logging.ConsoleHandler)19 Properties (java.util.Properties)15 SimpleFormatter (java.util.logging.SimpleFormatter)15 Config (com.sun.enterprise.config.serverbeans.Config)14 HashMap (java.util.HashMap)14 Map (java.util.Map)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)11 ResourceBundle (java.util.ResourceBundle)11 LogManager (java.util.logging.LogManager)11 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)11 BlockingQueueHandler (fish.payara.nucleus.notification.BlockingQueueHandler)10