protected void setupAccessLogIfNeeds(Context ctx) { if (accessLogOption != null && ctx instanceof StandardContext) { // also check context type just in case final StandardContext stdctx = (StandardContext) ctx; final AccessLogValve valve = new AccessLogValve(); accessLogOption.getLogDir().ifPresent(dir -> valve.setDirectory(dir)); accessLogOption.getFilePrefix().ifPresent(prefix -> valve.setPrefix(prefix)); accessLogOption.getFileSuffix().ifPresent(suffix -> valve.setSuffix(suffix)); accessLogOption.getFileDateFormat().ifPresent(format -> valve.setFileDateFormat(format)); valve.setEncoding(accessLogOption.getFileEncoding().orElse("UTF-8")); valve.setPattern(accessLogOption.getFormatPattern().orElse("common")); accessLogOption.getConditionIf().ifPresent(cond -> valve.setConditionIf(cond)); accessLogOption.getConditionUnless().ifPresent(cond -> valve.setConditionUnless(cond)); stdctx.addValve(valve); } }