本文整理汇总了Java中org.owasp.esapi.ESAPI.getLogger方法的典型用法代码示例。如果您正苦于以下问题:Java ESAPI.getLogger方法的具体用法?Java ESAPI.getLogger怎么用?Java ESAPI.getLogger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.owasp.esapi.ESAPI
的用法示例。
在下文中一共展示了ESAPI.getLogger方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.owasp.esapi.ESAPI; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* @throws Exception
*/
protected void setUp() throws Exception {
//override default log configuration in ESAPI.properties to use Log4JLogFactory
UnitTestSecurityConfiguration tmpConfig = new UnitTestSecurityConfiguration((DefaultSecurityConfiguration) ESAPI.securityConfiguration());
tmpConfig.setLogImplementation( Log4JLogFactory.class.getName() );
ESAPI.override(tmpConfig);
//This ensures a clean logger between tests
testLogger = ESAPI.getLogger( "test ExampleExtendedLog4JLogFactory: " + testCount++ );
System.out.println("Test ExampleExtendedLog4JLogFactory logger: " + testLogger);
//declare this one as Log4JLogger to be able to use Log4J logging methods
log4JLogger = (Log4JLogger)ESAPI.getLogger( "test Log4JLogFactory: " + testCount);
System.out.println("Test Log4JLogFactory logger: " + log4JLogger);
}
示例2: main
import org.owasp.esapi.ESAPI; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
Logger logger = ESAPI.getLogger("ESAPILogging");
logger.warning(Logger.SECURITY_FAILURE, "This is a warning.");
logger.always(Logger.SECURITY_AUDIT, "This is an audit log. It always logs.");
} catch(Throwable t) {
System.err.println("Caught: " + t.getClass().getName() +
"; exception msg: " + t);
t.printStackTrace(System.err);
}
}
示例3: setUp
import org.owasp.esapi.ESAPI; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* @throws Exception
*/
protected void setUp() throws Exception {
UnitTestSecurityConfiguration tmpConfig = new UnitTestSecurityConfiguration((DefaultSecurityConfiguration) ESAPI.securityConfiguration());
tmpConfig.setLogImplementation( JavaLogFactory.class.getName() );
ESAPI.override(tmpConfig);
//This ensures a clean logger between tests
testLogger = ESAPI.getLogger( "test" + testCount++ );
System.out.println("Test logger: " + testLogger);
}
示例4: testLogHTTPRequest
import org.owasp.esapi.ESAPI; //导入方法依赖的package包/类
/**
* Test of logHTTPRequest method, of class org.owasp.esapi.Logger.
*
* @throws ValidationException
* the validation exception
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws AuthenticationException
* the authentication exception
*/
public void testLogHTTPRequest() throws ValidationException, IOException, AuthenticationException {
System.out.println("logHTTPRequest");
String[] ignore = {"password","ssn","ccn"};
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
ESAPI.httpUtilities().setCurrentHTTP(request, response);
Logger logger = ESAPI.getLogger("logger");
ESAPI.httpUtilities().logHTTPRequest( request, logger, Arrays.asList(ignore) );
request.addParameter("one","one");
request.addParameter("two","two1");
request.addParameter("two","two2");
request.addParameter("password","jwilliams");
ESAPI.httpUtilities().logHTTPRequest( request, logger, Arrays.asList(ignore) );
}
示例5: testLogLevels
import org.owasp.esapi.ESAPI; //导入方法依赖的package包/类
/**
* test of loggers without setting explicit log levels
* (log levels set from log4j.xml configuration)
*/
public void testLogLevels() {
Logger traceLogger = ESAPI.getLogger("org.owasp.esapi.reference.TestTrace");
Logger debugLogger = ESAPI.getLogger("org.owasp.esapi.reference.TestDebug");
Logger infoLogger = ESAPI.getLogger("org.owasp.esapi.reference.TestInfo");
Logger errorLogger = ESAPI.getLogger("org.owasp.esapi.reference.TestError");
Logger warningLogger = ESAPI.getLogger("org.owasp.esapi.reference.TestWarning");
Logger fatalLogger = ESAPI.getLogger("org.owasp.esapi.reference.TestFatal");
Logger unspecifiedLogger = ESAPI.getLogger("org.owasp.esapi.reference"); //should use package-wide log level configuration (info)
//traceLogger - all log levels should be enabled
assertTrue(traceLogger.isTraceEnabled());
assertTrue(traceLogger.isDebugEnabled());
assertTrue(traceLogger.isInfoEnabled());
assertTrue(traceLogger.isWarningEnabled());
assertTrue(traceLogger.isErrorEnabled());
assertTrue(traceLogger.isFatalEnabled());
//debugLogger - all log levels should be enabled EXCEPT trace
assertFalse(debugLogger.isTraceEnabled());
assertTrue(debugLogger.isDebugEnabled());
assertTrue(debugLogger.isInfoEnabled());
assertTrue(debugLogger.isWarningEnabled());
assertTrue(debugLogger.isErrorEnabled());
assertTrue(debugLogger.isFatalEnabled());
//infoLogger - all log levels should be enabled EXCEPT trace and debug
assertFalse(infoLogger.isTraceEnabled());
assertFalse(infoLogger.isDebugEnabled());
assertTrue(infoLogger.isInfoEnabled());
assertTrue(infoLogger.isWarningEnabled());
assertTrue(infoLogger.isErrorEnabled());
assertTrue(infoLogger.isFatalEnabled());
//warningLogger - all log levels should be enabled EXCEPT etc.
assertFalse(warningLogger.isTraceEnabled());
assertFalse(warningLogger.isDebugEnabled());
assertFalse(warningLogger.isInfoEnabled());
assertTrue(warningLogger.isWarningEnabled());
assertTrue(warningLogger.isErrorEnabled());
assertTrue(warningLogger.isFatalEnabled());
//errorLogger - all log levels should be enabled EXCEPT etc.
assertFalse(errorLogger.isTraceEnabled());
assertFalse(errorLogger.isDebugEnabled());
assertFalse(errorLogger.isInfoEnabled());
assertFalse(errorLogger.isWarningEnabled());
assertTrue(errorLogger.isErrorEnabled());
assertTrue(errorLogger.isFatalEnabled());
//fatalLogger - all log levels should be enabled EXCEPT etc.
assertFalse(fatalLogger.isTraceEnabled());
assertFalse(fatalLogger.isDebugEnabled());
assertFalse(fatalLogger.isInfoEnabled());
assertFalse(fatalLogger.isWarningEnabled());
assertFalse(fatalLogger.isErrorEnabled());
assertTrue(fatalLogger.isFatalEnabled());
//unspecifiedLogger - all log levels should be enabled EXCEPT trace and debug
assertFalse(unspecifiedLogger.isTraceEnabled());
assertFalse(unspecifiedLogger.isDebugEnabled());
assertTrue(unspecifiedLogger.isInfoEnabled());
assertTrue(unspecifiedLogger.isWarningEnabled());
assertTrue(unspecifiedLogger.isErrorEnabled());
assertTrue(unspecifiedLogger.isFatalEnabled());
}
示例6: testLogLevelsWithClass
import org.owasp.esapi.ESAPI; //导入方法依赖的package包/类
/**
* test of loggers without setting explicit log levels
* (log levels set from log4j.xml configuration)
*/
public void testLogLevelsWithClass() {
Logger traceLogger = ESAPI.getLogger(TestTrace.class);
Logger debugLogger = ESAPI.getLogger(TestDebug.class);
Logger infoLogger = ESAPI.getLogger(TestInfo.class);
Logger errorLogger = ESAPI.getLogger(TestError.class);
Logger warningLogger = ESAPI.getLogger(TestWarning.class);
Logger fatalLogger = ESAPI.getLogger(TestFatal.class);
Logger unspecifiedLogger = ESAPI.getLogger(TestUnspecified.class); //should use package-wide log level configuration (info)
//traceLogger - all log levels should be enabled
assertTrue(traceLogger.isTraceEnabled());
assertTrue(traceLogger.isDebugEnabled());
assertTrue(traceLogger.isInfoEnabled());
assertTrue(traceLogger.isWarningEnabled());
assertTrue(traceLogger.isErrorEnabled());
assertTrue(traceLogger.isFatalEnabled());
//debugLogger - all log levels should be enabled EXCEPT trace
assertFalse(debugLogger.isTraceEnabled());
assertTrue(debugLogger.isDebugEnabled());
assertTrue(debugLogger.isInfoEnabled());
assertTrue(debugLogger.isWarningEnabled());
assertTrue(debugLogger.isErrorEnabled());
assertTrue(debugLogger.isFatalEnabled());
//infoLogger - all log levels should be enabled EXCEPT trace and debug
assertFalse(infoLogger.isTraceEnabled());
assertFalse(infoLogger.isDebugEnabled());
assertTrue(infoLogger.isInfoEnabled());
assertTrue(infoLogger.isWarningEnabled());
assertTrue(infoLogger.isErrorEnabled());
assertTrue(infoLogger.isFatalEnabled());
//warningLogger - all log levels should be enabled EXCEPT etc.
assertFalse(warningLogger.isTraceEnabled());
assertFalse(warningLogger.isDebugEnabled());
assertFalse(warningLogger.isInfoEnabled());
assertTrue(warningLogger.isWarningEnabled());
assertTrue(warningLogger.isErrorEnabled());
assertTrue(warningLogger.isFatalEnabled());
//errorLogger - all log levels should be enabled EXCEPT etc.
assertFalse(errorLogger.isTraceEnabled());
assertFalse(errorLogger.isDebugEnabled());
assertFalse(errorLogger.isInfoEnabled());
assertFalse(errorLogger.isWarningEnabled());
assertTrue(errorLogger.isErrorEnabled());
assertTrue(errorLogger.isFatalEnabled());
//fatalLogger - all log levels should be enabled EXCEPT etc.
assertFalse(fatalLogger.isTraceEnabled());
assertFalse(fatalLogger.isDebugEnabled());
assertFalse(fatalLogger.isInfoEnabled());
assertFalse(fatalLogger.isWarningEnabled());
assertFalse(fatalLogger.isErrorEnabled());
assertTrue(fatalLogger.isFatalEnabled());
//unspecifiedLogger - all log levels should be enabled EXCEPT trace and debug
assertFalse(unspecifiedLogger.isTraceEnabled());
assertFalse(unspecifiedLogger.isDebugEnabled());
assertTrue(unspecifiedLogger.isInfoEnabled());
assertTrue(unspecifiedLogger.isWarningEnabled());
assertTrue(unspecifiedLogger.isErrorEnabled());
assertTrue(unspecifiedLogger.isFatalEnabled());
}