Egor Baranov
Egor Baranov

Reputation: 11

How to set log level for Jenkins in plugin tests

I'm working on workflow-durable-task-step Jenkins plugin and I want to debug one of the tests of this plugin. To understand the problem I need to see Jenkins logs. By default INFO level logs are shown during tests, but I need FINE level.

How to show all possible logs for internal Jenkins process during mvn test command?

I've tried to run tests like mvn -Djava.util.logging.loglevel=FINEST test but this option changes log level for test itself but not Jenkins internal process. I mean if I write something like LOGGER.log(Level.FINE, "Hello world"); in the body of my test - it will be show but no logs with FINE level of Jenkins process started by my test will be displayed.

Upvotes: 1

Views: 6906

Answers (2)

Vetsin
Vetsin

Reputation: 2592

Within your test add something like the following:

    @Rule
    public LoggerRule logs = new LoggerRule()
            .recordPackage(YourClass.class, Level.FINE)

The LoggerRule ultimately is what you wanted

Upvotes: 0

Ian W
Ian W

Reputation: 4767

I think you are looking for ${JENKINS_URL}/log/levels

Documentation: Logger Configuration

Also see: Viewing Logs

Upvotes: 0

Related Questions