Search in sources :

Example 1 with AthenzRequestLog

use of com.yahoo.athenz.container.log.AthenzRequestLog in project athenz by yahoo.

the class AthenzJettyContainer method addRequestLogHandler.

public void addRequestLogHandler() {
    RequestLogHandler requestLogHandler = new RequestLogHandler();
    // check to see if have a slf4j logger name specified. if we don't
    // then we'll just use our NCSARequestLog extended Athenz logger
    // when using the slf4j logger we don't have the option to pass
    // our audit logger to keep track of unauthenticated requests
    String accessSlf4jLogger = System.getProperty(AthenzConsts.ATHENZ_PROP_ACCESS_SLF4J_LOGGER);
    if (accessSlf4jLogger != null && !accessSlf4jLogger.isEmpty()) {
        Slf4jRequestLog requestLog = new Slf4jRequestLog();
        requestLog.setLoggerName(accessSlf4jLogger);
        requestLog.setExtended(true);
        requestLog.setPreferProxiedForAddress(true);
        requestLog.setLogTimeZone("GMT");
        requestLogHandler.setRequestLog(requestLog);
    } else {
        String logDir = System.getProperty(AthenzConsts.ATHENZ_PROP_ACCESS_LOG_DIR, getRootDir() + "/logs/athenz");
        String logName = System.getProperty(AthenzConsts.ATHENZ_PROP_ACCESS_LOG_NAME, "access.yyyy_MM_dd.log");
        AthenzRequestLog requestLog = new AthenzRequestLog(logDir + File.separator + logName);
        requestLog.setAppend(true);
        requestLog.setExtended(true);
        requestLog.setPreferProxiedForAddress(true);
        requestLog.setLogTimeZone("GMT");
        String retainDays = System.getProperty(AthenzConsts.ATHENZ_PROP_ACCESS_LOG_RETAIN_DAYS, "31");
        int days = Integer.parseInt(retainDays);
        if (days > 0) {
            requestLog.setRetainDays(days);
        }
        requestLogHandler.setRequestLog(requestLog);
    }
    handlers.addHandler(requestLogHandler);
}
Also used : Slf4jRequestLog(org.eclipse.jetty.server.Slf4jRequestLog) RequestLogHandler(org.eclipse.jetty.server.handler.RequestLogHandler) AthenzRequestLog(com.yahoo.athenz.container.log.AthenzRequestLog)

Example 2 with AthenzRequestLog

use of com.yahoo.athenz.container.log.AthenzRequestLog in project athenz by yahoo.

the class AthenzRequestLogTest method testGetAuditLogMsgBuilderFileNameOnly.

@Test
public void testGetAuditLogMsgBuilderFileNameOnly() {
    AthenzRequestLog log = new AthenzRequestLog("/dev/null");
    assertNotNull(log);
}
Also used : AthenzRequestLog(com.yahoo.athenz.container.log.AthenzRequestLog) Test(org.testng.annotations.Test)

Aggregations

AthenzRequestLog (com.yahoo.athenz.container.log.AthenzRequestLog)2 Slf4jRequestLog (org.eclipse.jetty.server.Slf4jRequestLog)1 RequestLogHandler (org.eclipse.jetty.server.handler.RequestLogHandler)1 Test (org.testng.annotations.Test)1