繁体   English   中英

OWASP ESAPI 和 SLF4J/Logback 设置

[英]OWASP ESAPI and SLF4J/Logback setup

我目前有一个使用 SLF4J/LoggerFactory 捕获日志的程序,配置是通过 logback.xml 完成的。 我的日志按预期工作。 最近,安全团队在我的工作中指示我更新使用 ESAPI 的 class。 我更新了 class 并将ESAPI.propertiesvalidation.properties添加到src/main/resources/esapi ESAPI.properties中,我将 ESAPI.Logger 更新为ESAPI.Logger=org.owasp.esapi.logging.slf4j.Slf4JLogFactory 根据我的在线研究和 SO,我认为我可以使用我的日志(初始化为protected final static Logger log = LoggerFactory.getLogger(this.class);并用作log.info("Example") ) 正常(将日志输出到服务器上的文件),但是当 java 程序运行时,日志只是 output 到 CL。

LogFactory 的配置指示应该委托给哪个 Logging Framework 实例 org.owasp.esapi.Logger。

从您的问题来看,您似乎希望日志事件遵循以下流程:

MyCode -> SLF4J -> ESAPI -> 控制台。

实际上,它的实现方式是:
MyCode -> ESAPI_LOGGER -> SLF4J -> 控制台

ESAPI Logger 不是 SLF4J 日志记录合约的实现。 它只会委托给 esapi.properties 中配置的记录器实例。 代码中的所有引用都需要更新为

Logger esapiLogger = ESAPI.getLogger(myLogger_byClass_or_byName)

您可能希望调整ESAPI.properties文件中的这些相关属性:

# ESAPI Logging
# Set the application name if these logs are combined with other applications
Logger.ApplicationName=ExampleApplication
# If you use an HTML log viewer that does not properly HTML escape log data, you can set LogEncodingRequired to true
Logger.LogEncodingRequired=false
# Determines whether ESAPI should log the application name. This might be clutter in some single-server/single-app environments.
Logger.LogApplicationName=true
# Determines whether ESAPI should log the server IP and port. This might be clutter in some single-server environments.
Logger.LogServerIP=true
# Determines whether ESAPI should log the user info.
Logger.UserInfo=true
# Determines whether ESAPI should log the session id and client IP.
Logger.ClientInfo=true

我在阅读当前版本的README.md后解决了我的问题,如果您使用的是 slf4j 库,该版本引用了2.2.3.0 发行说明 我需要排除引入的 slf4j-simple,因为它是 AntiSamy 1.6.2 的依赖项。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM