2016-07-04 38 views

回答

0

關於應用程序日誌,我們需要手動解析要記錄的值。你應該從請求中獲得IP地址。您可以將其添加到Thread local並將其配置爲模式佈局[5]。

String ipAddress = request.getHeader("X-FORWARDED-FOR"); 
    if (ipAddress == null) { 
     ipAddress = request.getRemoteAddr(); 
    } 

您可以使用請求頭「X-Forwarded-For」[1]。

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="${carbon.home}/repository/logs" 
               prefix="http_access_management_console_" suffix=".log" 
               pattern="%{X-Forwarded-For}i %h %l %u %t &quot;%r&quot; %s %b &quot;%{Referer}i&quot; &quot;%{User-Agent}i&quot;" /> 

[2]

[1]。 https://tomcat.apache.org/tomcat-7.0-doc/config/valve.html#Proxies_Support [2]。 https://docs.wso2.com/display/ESB490/Access+Logs

[3]。 http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html#Access_Log_Valve

[4]。 http://www.techstacks.com/howto/configure-access-logging-in-tomcat.html [5]。 https://logging.apache.org/log4j/2.x/manual/thread-context.html

+0

@Poorman,謝謝! 但我需要的是自動登錄文件wso2carbon.log,我看過這個文檔,但無法完成我想要的。 – Naka

+0

我不認爲你可以通過配置來完成。你應該實現一個像[5] – Poornan