本文整理汇总了Java中org.apache.catalina.valves.AccessLogValve类的典型用法代码示例。如果您正苦于以下问题:Java AccessLogValve类的具体用法?Java AccessLogValve怎么用?Java AccessLogValve使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AccessLogValve类属于org.apache.catalina.valves包,在下文中一共展示了AccessLogValve类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCurrentLogFileNameSupplier
import org.apache.catalina.valves.AccessLogValve; //导入依赖的package包/类
/**
* Retrieves current access log file name from AccessLogValve to avoid accidental
* exclusion.
*
* @param accessLogValve the access log valve
* @param currentLogFileField the current log file field
* @return A Supplier that knows how to retrieve the file name
*/
private static Supplier<String> createCurrentLogFileNameSupplier(
final AccessLogValve accessLogValve, final Field currentLogFileField) {
return () -> {
String fileName = null;
try {
final File currentLogFile = (File) currentLogFileField
.get(accessLogValve);
if (currentLogFile != null) {
fileName = currentLogFile.toPath().getFileName().toString();
}
}
catch (final Exception e) {
log.warn(e.getMessage(), e);
}
return fileName;
};
}
开发者ID:marcosbarbero,项目名称:spring-boot-starter-purge-accesslog,代码行数:26,代码来源:TomcatPurgeAccessLogHolder.java
示例2: purgeAccessLogCustomizer
import org.apache.catalina.valves.AccessLogValve; //导入依赖的package包/类
/**
* Purge access log customizer embedded servlet container customizer.
*
* @param serverProperties the server properties
* @param purgeProperties the purge properties
* @return the embedded servlet container customizer
*/
@Bean
public EmbeddedServletContainerCustomizer purgeAccessLogCustomizer(
final ServerProperties serverProperties,
final PurgeProperties purgeProperties) {
return container -> {
final TomcatEmbeddedServletContainerFactory factory = (TomcatEmbeddedServletContainerFactory) container;
final Accesslog accesslog = serverProperties.getTomcat().getAccesslog();
factory.getEngineValves().stream()
.filter(valve -> valve instanceof AccessLogValve)
.map(valve -> (AccessLogValve) valve).findFirst()
.ifPresent(valve -> {
final TomcatPurgeAccessLogHolder accessLogHolder = new TomcatPurgeAccessLogHolder(
purgeProperties, Paths.get(accesslog.getDirectory()),
accesslog.getPrefix(), accesslog.getSuffix(), valve);
factory.addContextCustomizers(accessLogHolder);
});
};
}
开发者ID:marcosbarbero,项目名称:spring-boot-starter-purge-accesslog,代码行数:26,代码来源:PurgeAccessLogAutoConfiguration.java
示例3: addAccessLog
import org.apache.catalina.valves.AccessLogValve; //导入依赖的package包/类
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());
}
}
示例4: setUpValve
import org.apache.catalina.valves.AccessLogValve; //导入依赖的package包/类
@Override
public void setUpValve(Tomcat tomcat) {
// clear AccessLogValve
for (Valve vl : tomcat.getHost().getPipeline().getValves()) {
if (vl.getClass().equals(AccessLogValve.class)) {
tomcat.getHost().getPipeline().removeValve(vl);
}
}
if (accessLogDirectory == null) {
accessLogDirectory = new File(getBuildDirectory(), "logs").toString();
}
AccessLogValve alv = new AccessLogValve();
alv.setDirectory(accessLogDirectory);
alv.setPattern("combined");
tomcat.getHost().getPipeline().addValve(alv);
}
示例5: setUpValve
import org.apache.catalina.valves.AccessLogValve; //导入依赖的package包/类
@Override
protected void setUpValve(Tomcat tomcat) throws UnknownHostException {
// remove AccessLogValve
for (Valve vl : tomcat.getHost().getPipeline().getValves()) {
if (vl.getClass().equals(AccessLogValve.class)) {
tomcat.getHost().getPipeline().removeValve(vl);
}
}
mongoClient = new MongoClient(new MongoClientURI(url));
db = mongoClient.getDB(dbName);
MongoAccessLogValve mavl = new MongoAccessLogValve();
mavl.setUri(url);
mavl.setDbName(dbName);
mavl.setCollName(collName);
mavl.setPattern(pattern);
tomcat.getHost().getPipeline().addValve(mavl);
}
示例6: initAccessLog
import org.apache.catalina.valves.AccessLogValve; //导入依赖的package包/类
/**
* アクセスログを構成する.
*
* @throws IOException
*/
protected void initAccessLog() throws IOException {
// --------------------------------
// アクセスログを構成する.
// --------------------------------
File accessLogDir = getLogsDir();
String logDir = accessLogDir.getAbsolutePath();
AccessLogValve accessLogValve = new AccessLogValve();
accessLogValve.setDirectory(logDir);
accessLogValve.setPrefix("accesslog");
accessLogValve.setPattern(
org.apache.catalina.valves.Constants.AccessLog.COMBINED_ALIAS
);
accessLogValve.setFileDateFormat("yyyy-MM-dd");
accessLogValve.setSuffix(".log");
accessLogValve.setRenameOnRotate(true);
accessLogValve.setRequestAttributesEnabled(true);
accessLogValve.setBuffered(false);
accessLogValve.setEnabled(true);
ctx.addValve(accessLogValve);
// ↓ エンジン単位に指定する場合
// ((StandardEngine) tomcat.getEngine()).addValve(accessLogValve);
}
示例7: getCurrentLogFileField
import org.apache.catalina.valves.AccessLogValve; //导入依赖的package包/类
/**
* Retrieves current log file field.
*
* @param accessLogValve the access log valve
* @return the current log file field
*/
private static Field getCurrentLogFileField(final AccessLogValve accessLogValve) {
final Field currentLogFileField = findField(accessLogValve.getClass(),
CURRENT_LOG_FILE_FIELD, File.class);
makeAccessible(currentLogFileField);
return currentLogFileField;
}
开发者ID:marcosbarbero,项目名称:spring-boot-starter-purge-accesslog,代码行数:13,代码来源:TomcatPurgeAccessLogHolder.java
示例8: createMockedAccessLogValve
import org.apache.catalina.valves.AccessLogValve; //导入依赖的package包/类
private AccessLogValve createMockedAccessLogValve(final Path currentAccessLogFile) {
final AccessLogValve accessLogValve = new AccessLogValve();
final Field field = findField(AccessLogValve.class, CURRENT_LOG_FILE_FIELD);
makeAccessible(field);
setField(field, accessLogValve, currentAccessLogFile.toFile());
return accessLogValve;
}
开发者ID:marcosbarbero,项目名称:spring-boot-starter-purge-accesslog,代码行数:8,代码来源:TomcatPurgeAccessLogHolderTest.java
示例9: createAccessLoggerValve
import org.apache.catalina.valves.AccessLogValve; //导入依赖的package包/类
/**
* Create a new AccessLoggerValve.
*
* @param parent MBean Name of the associated parent component
*
* @exception Exception if an MBean cannot be created or registered
*
* @deprecated Will be removed in Tomcat 8.0.x. Replaced by {@link
* #createValve(String, String)}.
*/
@Deprecated
public String createAccessLoggerValve(String parent)
throws Exception {
ObjectName pname = new ObjectName(parent);
// Create a new AccessLogValve instance
AccessLogValve accessLogger = new AccessLogValve();
ContainerBase containerBase = getParentContainerFromParent(pname);
// Add the new instance to its parent component
containerBase.getPipeline().addValve(accessLogger);
ObjectName oname = accessLogger.getObjectName();
return (oname.toString());
}
示例10: createAccessLoggerValve
import org.apache.catalina.valves.AccessLogValve; //导入依赖的package包/类
/**
* Create a new AccessLoggerValve.
*
* @param parent MBean Name of the associated parent component
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createAccessLoggerValve(String parent)
throws Exception {
ObjectName pname = new ObjectName(parent);
// Create a new AccessLogValve instance
AccessLogValve accessLogger = new AccessLogValve();
ContainerBase containerBase = getParentContainerFromParent(pname);
// Add the new instance to its parent component
containerBase.addValve(accessLogger);
ObjectName oname = accessLogger.getObjectName();
return (oname.toString());
}
示例11: createAccessLoggerValve
import org.apache.catalina.valves.AccessLogValve; //导入依赖的package包/类
/**
* Create a new AccessLoggerValve.
*
* @param parent
* MBean Name of the associated parent component
*
* @exception Exception
* if an MBean cannot be created or registered
*
* @deprecated Will be removed in Tomcat 8.0.x. Replaced by
* {@link #createValve(String, String)}.
*/
@Deprecated
public String createAccessLoggerValve(String parent) throws Exception {
ObjectName pname = new ObjectName(parent);
// Create a new AccessLogValve instance
AccessLogValve accessLogger = new AccessLogValve();
ContainerBase containerBase = getParentContainerFromParent(pname);
// Add the new instance to its parent component
containerBase.getPipeline().addValve(accessLogger);
ObjectName oname = accessLogger.getObjectName();
return (oname.toString());
}
示例12: customizeAccessLog
import org.apache.catalina.valves.AccessLogValve; //导入依赖的package包/类
private void customizeAccessLog(TomcatEmbeddedServletContainerFactory factory) {
AccessLogValve valve = new AccessLogValve();
valve.setPattern(this.accesslog.getPattern());
valve.setDirectory(this.accesslog.getDirectory());
valve.setPrefix(this.accesslog.getPrefix());
valve.setSuffix(this.accesslog.getSuffix());
valve.setRenameOnRotate(this.accesslog.isRenameOnRotate());
factory.addEngineValves(valve);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:ServerProperties.java
示例13: customizeAccessLog
import org.apache.catalina.valves.AccessLogValve; //导入依赖的package包/类
private void customizeAccessLog(TomcatEmbeddedServletContainerFactory factory) {
AccessLogValve valve = new AccessLogValve();
valve.setPattern(this.accesslog.getPattern());
valve.setDirectory(this.accesslog.getDirectory());
valve.setPrefix(this.accesslog.getPrefix());
valve.setSuffix(this.accesslog.getSuffix());
factory.addContextValves(valve);
}
示例14: createAccessLoggerValve
import org.apache.catalina.valves.AccessLogValve; //导入依赖的package包/类
/**
* Create a new AccessLoggerValve.
*
* @param parent MBean Name of the associated parent component
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createAccessLoggerValve(String parent)
throws Exception {
ObjectName pname = new ObjectName(parent);
// Create a new AccessLogValve instance
AccessLogValve accessLogger = new AccessLogValve();
ContainerBase containerBase = getParentContainerFromParent(pname);
// Add the new instance to its parent component
containerBase.getPipeline().addValve(accessLogger);
ObjectName oname = accessLogger.getObjectName();
return (oname.toString());
}
示例15: setUp
import org.apache.catalina.valves.AccessLogValve; //导入依赖的package包/类
@Before
@Override
public void setUp() throws Exception {
super.setUp();
// Trigger loading of catalina.properties
CatalinaProperties.getProperty("foo");
File appBase = new File(getTemporaryDirectory(), "webapps");
if (!appBase.exists() && !appBase.mkdir()) {
fail("Unable to create appBase for test");
}
tomcat = new TomcatWithFastSessionIDs();
String protocol = getProtocol();
Connector connector = new Connector(protocol);
// Listen only on localhost
connector.setAttribute("address",
InetAddress.getByName("localhost").getHostAddress());
// Use random free port
connector.setPort(0);
// Mainly set to reduce timeouts during async tests
connector.setAttribute("connectionTimeout", "3000");
tomcat.getService().addConnector(connector);
tomcat.setConnector(connector);
// Add AprLifecycleListener if we are using the Apr connector
if (protocol.contains("Apr")) {
StandardServer server = (StandardServer) tomcat.getServer();
AprLifecycleListener listener = new AprLifecycleListener();
listener.setSSLRandomSeed("/dev/urandom");
server.addLifecycleListener(listener);
connector.setAttribute("pollerThreadCount", Integer.valueOf(1));
}
File catalinaBase = getTemporaryDirectory();
tomcat.setBaseDir(catalinaBase.getAbsolutePath());
tomcat.getHost().setAppBase(appBase.getAbsolutePath());
accessLogEnabled = Boolean.parseBoolean(
System.getProperty("tomcat.test.accesslog", "false"));
if (accessLogEnabled) {
String accessLogDirectory = System
.getProperty("tomcat.test.reports");
if (accessLogDirectory == null) {
accessLogDirectory = new File(getBuildDirectory(), "logs")
.toString();
}
AccessLogValve alv = new AccessLogValve();
alv.setDirectory(accessLogDirectory);
alv.setPattern("%h %l %u %t \"%r\" %s %b %I %D");
tomcat.getHost().getPipeline().addValve(alv);
}
// Cannot delete the whole tempDir, because logs are there,
// but delete known subdirectories of it.
addDeleteOnTearDown(new File(catalinaBase, "webapps"));
addDeleteOnTearDown(new File(catalinaBase, "work"));
}