Quantcast

log messages from plugin doesn't reach system logger after restart of Jenkins

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

log messages from plugin doesn't reach system logger after restart of Jenkins

esrug
Hi, 

I have a problem where the logger messages from a plugin stops showing up in a the logger when Jenkins has been restarted.

I am working on an SCM plugin. I have created a class where I instantiate a logger and use it in the methods:

package dimtestplugin;
......
import java.util.logging.Level;
import java.util.logging.Logger;
.......
public class DimoScm extends SCM {
.....
private static final Logger LOGGER = Logger.getLogger(DimoScm.class.getName());
.......
@Override
public SCMRevisionState calcRevisionsFromBuild(AbstractBuild<?, ?> arg0,
Launcher arg1, TaskListener arg2) throws IOException,
InterruptedException {
DimRevisionState revisionState = new DimRevisionState();
//Ask for the time stamp of the latest modification in the repos based on the path
Date latestTimestamp = branch.getLastModificationDateByPath(path);
---> LOGGER.log(Level.FINE,"calcRevisionFromBuild - latestTimeStamp: " + latestTimestamp.toString());
revisionState.setTimeStampOfLastModification(latestTimestamp);
//return object containing the time stamp of the latest modification.
return revisionState;
}
.......
}

In Jenkins I create a logger which is connected to the specific class 'dimtestplugin.DimoScm'. When I create the logger in Jenkins the generated log messages start appearing in the window. So far so good.

Now, if I restart Jenkins the log messages stop appearing in the logger. If I then either create or delete a logger - it can be any of the loggers, it does not necessarily need to be related to my plugin, the messages start showing up again. I have created other loggers which for example logs messages from the Subversion plugin. These loggers doesn't stop working when I restart Jenkins.

I really need this to work because I want to use the log for debugging, and I don't want to have to recreate the logger every time I have created a new version of my plugin and restarted Jenkins.

Any help is much appreciated.

Thank you.
Esben
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: log messages from plugin doesn't reach system logger after restart of Jenkins

teilo-3
As a workaround
You can define the log level in a static file and configure java to
load that at startup.

Google logging.properties.

I have observed the same behaviour where a logger added in the yo is
lost on restart, I've never seen it kept and didn't think this was
even possible.

On Jul 4, 1:57 pm, Esben Rugbjerg <[hidden email]> wrote:

> Hi,
>
> I have a problem where the logger messages from a plugin stops showing up
> in a the logger when Jenkins has been restarted.
>
> I am working on an SCM plugin. I have created a class where I instantiate a
> logger and use it in the methods:
>
> package dimtestplugin;
> ......
> import java.util.logging.Level;
> import java.util.logging.Logger;
> .......
> public class DimoScm extends SCM {
> .....
> private static final Logger LOGGER =
> Logger.getLogger(DimoScm.class.getName());
> .......
> @Override
> public SCMRevisionState calcRevisionsFromBuild(AbstractBuild<?, ?> arg0,
> Launcher arg1, TaskListener arg2) throws IOException,
> InterruptedException {
>  DimRevisionState revisionState = new DimRevisionState();
> //Ask for the time stamp of the latest modification in the repos based on
> the path
> Date latestTimestamp = branch.getLastModificationDateByPath(path);
> ---> LOGGER.log(Level.FINE,"calcRevisionFromBuild - latestTimeStamp: " +
> latestTimestamp.toString());
>  revisionState.setTimeStampOfLastModification(latestTimestamp);
>  //return object containing the time stamp of the latest modification.
> return revisionState;
>
> }
> .......
> }
>
> In Jenkins I create a logger which is connected to the specific class
> 'dimtestplugin.DimoScm'. When I create the logger in Jenkins the generated
> log messages start appearing in the window. So far so good.
>
> Now, if I restart Jenkins the log messages stop appearing in the logger. If
> I then either create or delete a logger - it can be any of the loggers, it
> does not necessarily need to be related to my plugin, the messages start
> showing up again. I have created other loggers which for example logs
> messages from the Subversion plugin. These loggers doesn't stop working
> when I restart Jenkins.
>
> I really need this to work because I want to use the log for debugging, and
> I don't want to have to recreate the logger every time I have created a new
> version of my plugin and restarted Jenkins.
>
> Any help is much appreciated.
>
> Thank you.
> Esben
Loading...