我正在进行 Apache camel 的性能测试,到目前为止,我能够运行 logback async 来获得一些速度,
在开始我的路线时,无论如何都要禁用驼峰上下文的 INFO 。
logback.xml:
我的logback.xml配置是,
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false" scan="false">
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
<!-- To show the log in console -->
<appender name="OUT" class="ch.qos.logback.core.ConsoleAppender">
<prudent>true</prudent>
<encoder>
<Pattern>
%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</encoder>
</appender>
<logger name="org.apache.catalina.core" level="INFO" />
<!-- DEBUG Config -->
<logger name="logs_debug" level="DEBUG" additivity="false">
<appender-ref ref="OUT" />
</logger>
<!-- INFO Config -->
<logger name="logs_info" level="INFO" additivity="false">
<appender-ref ref="OUT" />
</logger>
<!-- ERROR Config -->
<logger name="logs_error" level="ERROR" additivity="false">
<appender-ref ref="OUT" />
</logger>
<!-- To make the Logback ASYNC -->
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<includeCallerData>true</includeCallerData>
<queueSize>500</queueSize>
<discardingThreshold>2</discardingThreshold>
<appender-ref ref="OUT" />
</appender>
<!-- root Logback -->
<root level="ERROR">
<appender-ref ref="ASYNC" />
</root>
</configuration>
我得到了这个回复。
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building roi-asynlogback 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ roi-customlogback ---
[INFO] Deleting /home/bizruntime/BizRuntime/Maven/log4j/roi-customlogback/target
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ roi-customlogback ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ roi-customlogback ---
[INFO] Compiling 7 source files to /home/bizruntime/BizRuntime/Maven/log4j/roi-customlogback/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ roi-customlogback ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/bizruntime/BizRuntime/Maven/log4j/roi-customlogback/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ roi-customlogback ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ roi-customlogback ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ roi-customlogback ---
[INFO] Building jar: /home/bizruntime/BizRuntime/Maven/log4j/roi-customlogback/target/roi-customlogback-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] >>> camel-maven-plugin:2.13.2:run (default-cli) @ roi-customlogback >>>
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ roi-customlogback ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ roi-customlogback ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ roi-customlogback ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/bizruntime/BizRuntime/Maven/log4j/roi-customlogback/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ roi-customlogback ---
[INFO] Not compiling test sources
[INFO]
[INFO] <<< camel-maven-plugin:2.13.2:run (default-cli) @ roi-customlogback <<<
[INFO]
[INFO] --- camel-maven-plugin:2.13.2:run (default-cli) @ roi-customlogback ---
[INFO] Using org.apache.camel.spring.Main to initiate a CamelContext
[INFO] Starting Camel ...
Jun 01, 2016 5:26:05 PM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@47262043: startup date [Wed Jun 01 17:26:05 IST 2016]; root of context hierarchy
Jun 01, 2016 5:26:05 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from file [/home/bizruntime/BizRuntime/Maven/log4j/roi-customlogback/target/classes/META-INF/spring/camel-context.xml]
Jun 01, 2016 5:26:06 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@5918a58d: defining beans [logFormatter,log,addempdetails,customlogback,template,consumerTemplate,camel-1:beanPostProcessor,camel-1]; root of factory hierarchy
Jun 01, 2016 5:26:07 PM org.restlet.engine.connector.ServerConnectionHelper start
INFO: Starting the internal [HTTP/1.1] server on port 9090
答案 0 :(得分:2)
不,我不这么认为,因为你使用camel-maven-plugin启动Camel,这是一个Maven插件,它有自己的启动和日志记录,在Camel启动之前发生等等。
如果你想完全没有日志记录,那么自己启动Camel作为java主应用程序。
现在重点是你真的不应该浪费时间,因为启动是可以忽略的,不应该在你的性能测试中测量。只有当应用程序启动并运行时,您可能需要调整/调整日志/ JMX /线程等等以获得更高的性能。
答案 1 :(得分:1)
尝试从骆驼网站查看link。
日志提供了一些选项: 要使用的记录级别。可能的值:ERROR,WARN,INFO,DEBUG,TRACE,OFF
可以像这样使用:
.log(LoggingLevel.ERROR, "some error to log")
答案 2 :(得分:1)
我有log4j,配置如下,对我来说效果很好
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
</head>
<body>
<input type="button" value="Sort" id="sort"></input>
<table cellpadding="1" cellspacing="1" id="mytable" border="1">
<tr>
<td>Coby</td>
<td>Vanna</td>
<td>Balurghat</td>
</tr>
<tr>
<td>Arsenio</td>
<td>Ignacia</td>
<td>Tramutola</td>
</tr>
<tr>
<td>Kenneth</td>
<td>Gretchen</td>
<td>Penhold</td>
</tr>
<tr>
<td>Aquila</td>
<td>Breanna</td>
<td>Liverpool</td>
</tr>
<tr>
<td>Dane</td>
<td>Isadora</td>
<td>Silverton</td>
</tr>
<tr>
<td>Jerry</td>
<td>Mari</td>
<td>Thon</td>
</tr>
<tr>
<td>Kareem</td>
<td>Courtney</td>
<td>Senneville</td>
</tr>
<tr>
<td>Fulton</td>
<td>Karen</td>
<td>Berloz</td>
</tr>
<tr>
<td>Quamar</td>
<td>Quon</td>
<td>Zamora</td>
</tr>
</table>
<script type="text/javascript" language="javascript">
$("#sort").click(function(){
$('#mytable tr').each(function() {
var arr=[];
var x = $(this).find("td").eq(1).text();
arr.push(x);
SortElements();
});
})
function SortElements() {
arr.sort(alphabetical);
alert(arr);
}
function alphabetical(a, b)
{
var A = a.toLowerCase();
var B = b.toLowerCase();
if (A < B){
return -1;
}else if (A > B){
return 1;
}else{
return 0;
}
}
</script>
</body>
</html>
我认为对于logback也会是这样的。