modify logging info
This commit is contained in:
parent
9c6436e01b
commit
ec8b501fef
2 changed files with 29 additions and 14 deletions
|
@ -21,13 +21,17 @@ import javax.servlet.ServletContext;
|
|||
|
||||
import org.codelibs.core.beans.util.BeanUtil;
|
||||
import org.codelibs.core.beans.util.CopyOptions;
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.exception.UserRoleLoginException;
|
||||
import org.dbflute.optional.OptionalThing;
|
||||
import org.lastaflute.di.util.LdiFileUtil;
|
||||
import org.lastaflute.web.login.LoginManager;
|
||||
import org.lastaflute.web.response.ActionResponse;
|
||||
import org.lastaflute.web.ruts.process.ActionRuntime;
|
||||
import org.lastaflute.web.util.LaRequestUtil;
|
||||
import org.lastaflute.web.util.LaServletContextUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
|
@ -35,6 +39,8 @@ import org.lastaflute.web.util.LaServletContextUtil;
|
|||
*/
|
||||
public abstract class FessAdminAction extends FessBaseAction {
|
||||
|
||||
private static final Logger auditLogger = LoggerFactory.getLogger("fess.log.audit");
|
||||
|
||||
// ===================================================================================
|
||||
// Attribute
|
||||
// =========
|
||||
|
@ -94,4 +100,26 @@ public abstract class FessAdminAction extends FessBaseAction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResponse hookBefore(ActionRuntime runtime) {
|
||||
final String client = LaRequestUtil.getOptionalRequest().map(req -> {
|
||||
final String value = req.getHeader("x-forwarded-for");
|
||||
if (StringUtil.isNotBlank(value)) {
|
||||
return value;
|
||||
} else {
|
||||
return req.getRemoteAddr();
|
||||
}
|
||||
}).orElse("-");
|
||||
final String username = getUserBean().map(u -> u.getUserId()).orElse("-");
|
||||
final String requestPath = runtime.getRequestPath();
|
||||
final String executeName = runtime.getExecuteMethod().getName();
|
||||
auditLogger.info("{} {} {} {}", client, username, requestPath, executeName);
|
||||
return super.hookBefore(runtime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hookFinally(ActionRuntime runtime) {
|
||||
super.hookFinally(runtime);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<!-- <property name="log.pattern" value="%d [%t] %-5p \\(%C{0}@%M\\(\\):%L\\) - %msg%n" /> -->
|
||||
<property name="log.file.basedir" value="${fess.log.path:-target/logs}" />
|
||||
<property name="backup.date.suffix" value="_%d{yyyyMMdd}" />
|
||||
<property name="backup.max.history" value="180" />
|
||||
<property name="backup.max.history" value="90" />
|
||||
<property name="audit.log.pattern" value="%d %msg%n" />
|
||||
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
|
@ -41,19 +41,6 @@
|
|||
<maxHistory>${backup.max.history}</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
<appender name="mailfile"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${log.file.basedir}/mail.log</File>
|
||||
<Append>true</Append>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.file.basedir}/backup/mail${backup.date.suffix}.log
|
||||
</fileNamePattern>
|
||||
<maxHistory>${backup.max.history}</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<logger name="org.codelibs.fess" additivity="false" level="${log.level}">
|
||||
<if condition='isNull("lasta.env")'>
|
||||
|
|
Loading…
Add table
Reference in a new issue