Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set my Apache camel log level to ERROR Using logback.xml

I am working on performance testing of Apache camel, so far i am able to run logback async to gain some speed,

Is there anyway to disable even the INFO of camel-context at starting my route.

logback.xml:

And my logback.xml configuration is,

<?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>

And i get this response.

[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
like image 887
umar faraz Avatar asked Apr 08 '26 14:04

umar faraz


2 Answers

Try to look at the link from camels site.

The log gives some options: Logging level to use. Possible values: ERROR, WARN, INFO, DEBUG, TRACE, OFF

can be used like this:

.log(LoggingLevel.ERROR, "some error to log")
like image 80
Aku Nour Avatar answered Apr 10 '26 04:04

Aku Nour


No I do not think so as you are starting Camel using the camel-maven-plugin that is a Maven plugin that has its own kind of startup and logging that happens before Camel is started etc.

If you want to have no logging at all, then start Camel yourself as a java main app.

Now the point is that you should really not waste time on this, as the startup is neglible and should not be measured in your performance tests. Its only when the application is up and running you may need to tweak/tune logging/JMX/threads and whatnot for higher performance.

like image 23
Claus Ibsen Avatar answered Apr 10 '26 02:04

Claus Ibsen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!