项目:micro-server
文件:TomcatApplication.java
private void addAccessLog(Tomcat httpServer,StandardContext context) {
try {
String accessLogLocation = serverData.getRootContext().getBean(AccessLogLocationBean.class).getAccessLogLocation();
accessLogLocation = accessLogLocation + "/" + replaceSlash(serverData.getModule().getContext()) + "-access.log";
AccessLogValve accessLogValve = new AccessLogValve();
accessLogValve.setDirectory(accessLogLocation);
accessLogValve.setPattern(Constants.AccessLog.COMMON_ALIAS);
accessLogValve.setSuffix(".log");
accessLogValve.setRotatable(true);
context.getPipeline().addValve(accessLogValve);
} catch (Exception e) {
logger.error(InternalErrorCode.SERVER_STARTUP_Failed_TO_CREATE_ACCESS_LOG.toString() + ": " + e.getMessage());
if (e.getCause() != null)
logger.error("CAUSED BY: " + InternalErrorCode.SERVER_STARTUP_Failed_TO_CREATE_ACCESS_LOG.toString() + ": " + e.getCause().getMessage());
}
}
项目:tomcat-mongo-access-log
文件:MongoAccessLogValve.java
/**
* Set the format pattern,first translating any recognized alias.
*
* @param pattern The new pattern
*/
public void setPattern(String pattern) {
if (pattern == null) {
this.pattern = "";
} else if (pattern.equals(Constants.AccessLog.COMMON_ALIAS)) {
this.pattern = Constants.AccessLog.COMMON_PATTERN;
} else if (pattern.equals(Constants.AccessLog.COMBINED_ALIAS)) {
this.pattern = Constants.AccessLog.COMBINED_PATTERN;
} else if (pattern.equals(me.chanjar.tomcat.valves.Constants.MongoAccessLog.DEFAULT_ALIAS)) {
this.pattern = me.chanjar.tomcat.valves.Constants.MongoAccessLog.DEFAULT_PATTERN;
} else if (pattern.equals(me.chanjar.tomcat.valves.Constants.MongoAccessLog.ALL_ALIAS)) {
this.pattern = me.chanjar.tomcat.valves.Constants.MongoAccessLog.ALL_PATTERN;
} else {
this.pattern = pattern;
}
logElements = createLogElements();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。