Configure logger in vertx 3

11,614

Solution 1

So, try this: give ur config file this name: vertx-default-jul-logging.properties and place it into src/main/resources.

put in that content:

handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=FINEST

.level=ERROR
com.sensegrow.level=ERROR

Run main(). This will work. From that on try to rename it and extend it to your needs. :)

Hope this helps.

PS: till here you dont need any jvm variables. Try this first and then extend it. If then something doens't work and you know exactly which argument, or so write again. :)

Jeerze,

Simon

For more information about logginfile name and logging in vertx3 see: Vertx3 Logging

Solution 2

I configured Logback in Vert.x successfully, you can check the details in the following answer:

https://stackoverflow.com/a/43101501/973418

Share:
11,614
Deepak Agrawal
Author by

Deepak Agrawal

Assistant Consultant-Developer at Oodles Technologies Pvt Ltd. I am a creative programmer. I started programming because I love logic, and it allows me to exercise my brain by wrapping it around new challenges all the time. I am a master-level graduate in computer science, I have one bachelor's degrees. I am an enthusiast of the Bitcoin project, as well as a gamer at my leisure time. I love learning new things, I love being challenged - both at work and at my free time. I strive for perfection.

Updated on June 28, 2022

Comments

  • Deepak Agrawal
    Deepak Agrawal almost 2 years

    I am using vertx 3.0 with spring boot. Now I am trying to config logger log levels, using below config:

    JVM Arguments:

    -Dspring.profiles.active=dev 
    -Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory 
    -Djava.util.logging.config.file=logging.properties
    

    logging.properties:

    handlers=java.util.logging.ConsoleHandler
    java.util.logging.ConsoleHandler.level=ERROR
    com.sensegrow.level=ERROR
    

    JAVA Class:

    package com.sensegrow.main;
    
    @SpringBootApplication
    public class Application{
    
        private static Logger logger ;
        public static JsonObject config;
        private static Vertx vertx;
    
        // Convenience method so you can run it in your IDE
        public static void main(String[] args) throws Exception 
        {
            logger = LoggerFactory.getLogger(Application.class);
            logger.trace("trace");
            logger.debug("debug");
            logger.info("info");
            logger.warn("warning");
            logger.error("error");
            SpringApplication.run(Application.class, args);
        }
    }
    

    Output:

    16:29:58.073 [                main] INFO  - com.sensegrow.main.Application           - info
    16:29:58.076 [                main] WARN  - com.sensegrow.main.Application           - warning
    16:29:58.076 [                main] ERROR - com.sensegrow.main.Application           - error
    

    As log level for package com.sensegrow is error. Why I am getting Info and warn level logs.