本文整理汇总了Java中org.apache.catalina.valves.AccessLogValve.setPattern方法的典型用法代码示例。如果您正苦于以下问题:Java AccessLogValve.setPattern方法的具体用法?Java AccessLogValve.setPattern怎么用?Java AccessLogValve.setPattern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.catalina.valves.AccessLogValve
的用法示例。
在下文中一共展示了AccessLogValve.setPattern方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
}
示例2: 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);
}
示例3: 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);
}
示例4: 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
示例5: 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);
}
示例6: 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"));
}
示例7: 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) {
AccessLogValve alv = new AccessLogValve();
alv.setDirectory(getBuildDirectory() + "/logs");
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"));
}
示例8: setUp
import org.apache.catalina.valves.AccessLogValve; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
// Need to use JULI so log messages from the tests are visible
System.setProperty("java.util.logging.manager",
"org.apache.juli.ClassLoaderLogManager");
System.setProperty("java.util.logging.config.file", new File(
getBuildDirectory(), "conf/logging.properties").toString());
tempDir = new File(System.getProperty("tomcat.test.temp", "output/tmp"));
if (!tempDir.mkdirs() && !tempDir.isDirectory()) {
fail("Unable to create temporary directory for test");
}
System.setProperty("catalina.base", tempDir.getAbsolutePath());
// Trigger loading of catalina.properties
CatalinaProperties.getProperty("foo");
File appBase = new File(tempDir, "webapps");
if (!appBase.exists() && !appBase.mkdir()) {
fail("Unable to create appBase for test");
}
tomcat = new TomcatWithFastSessionIDs();
String protocol = getProtocol();
Connector connector = new Connector(protocol);
// If each test is running on same port - they
// may interfere with each other
connector.setPort(getNextPort());
// 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));
}
tomcat.setBaseDir(tempDir.getAbsolutePath());
tomcat.getHost().setAppBase(appBase.getAbsolutePath());
accessLogEnabled = Boolean.parseBoolean(
System.getProperty("tomcat.test.accesslog", "false"));
if (accessLogEnabled) {
AccessLogValve alv = new AccessLogValve();
alv.setDirectory(getBuildDirectory() + "/logs");
alv.setPattern("%h %l %u %t \"%r\" %s %b %I %D");
tomcat.getHost().getPipeline().addValve(alv);
}
}