Timestamps on build logs

1,745 views
Skip to first unread message

Antonio Muñiz

unread,
Sep 7, 2015, 5:05:02 AM9/7/15
to jenkin...@googlegroups.com
Hello,

Probably by history aspects Jenkins builds log files have never used timestamps entries on log lines. There are some plugins that adds this feature, but using a kind of separate additional data, I still miss a plain timestamp in the log file.

I see three main reasons to implement this feature:

1. Using a timestamp entry at the beginning of the line in logs is a kind of "standard" in the Java world (all well known loggers do it by default).
2. They are really useful when you have to find an issue and don't have access to the Jenkins UI, all you have is that log file.
3. Most of the logs analysis tools require a timestamp entry on each log line.

My intention is:
1. Use a custom (overridden) PrintStream on StreamTaskLinstener
2. Provide a way to activate or deactivate this feature by configuration (it would be disabled by default in order to not break anything working before).

I'm writing this, because, as I see it, it would require a core change (StreamTaskListener mainly and some top level configuration), so I'd like to know what the community thinks about it.

Regards,
Antonio.

--
Antonio Muñiz
Software Engineer
CloudBees, Inc.

Mirko Friedenhagen

unread,
Sep 7, 2015, 6:24:32 AM9/7/15
to jenkin...@googlegroups.com

Hello Antonio,

there is already a plugin for this. Do you want this to be part of the core?

Regards
Mirko
--
Sent from my mobile

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAJc7kzT3L5i_oa7t%2B40J_5Z4JqGtOBE-%2BZ5Xpavf866WH05LxA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Antonio Muñiz

unread,
Sep 7, 2015, 6:35:36 AM9/7/15
to jenkin...@googlegroups.com
Hello Mirko,

Do you mean Timestamper Plugin? It stores timing information in additional files and then show it in the UI, but the original build log file (in the filesystem) remains the same. The aim of this new feature would be having the timing information just in the original build log file.

Regards,
Antonio.


For more options, visit https://groups.google.com/d/optout.

Antonio Muñiz

unread,
Sep 7, 2015, 6:36:52 AM9/7/15
to jenkin...@googlegroups.com
BTW I would like to do it as a plugin, but there is no extension point for that.

Daniel Beck

unread,
Sep 7, 2015, 10:08:03 AM9/7/15
to jenkin...@googlegroups.com

> On 07.09.2015, at 03:35, Antonio Muñiz <amu...@cloudbees.com> wrote:
>
> Do you mean Timestamper Plugin? It stores timing information in additional files and then show it in the UI, but the original build log file (in the filesystem) remains the same. The aim of this new feature would be having the timing information just in the original build log file.

--

> On 07.09.2015, at 03:36, Antonio Muñiz <amu...@cloudbees.com> wrote:
>
> BTW I would like to do it as a plugin, but there is no extension point for that.

It seems to me that ConsoleLogFilter should be able to do this.

Timestamper uses that when you don't have an AbstractBuild or configure it to. See e.g.
https://github.com/jenkinsci/timestamper-plugin/blob/master/src/main/java/hudson/plugins/timestamper/TimestamperBuildWrapper.java#L99
https://github.com/jenkinsci/timestamper-plugin/blob/master/src/main/java/hudson/plugins/timestamper/TimestampNote.java#L34

Antonio Muñiz

unread,
Sep 7, 2015, 10:24:01 AM9/7/15
to jenkin...@googlegroups.com

On Mon, Sep 7, 2015 at 4:07 PM, Daniel Beck <m...@beckweb.net> wrote:
It seems to me that ConsoleLogFilter should be able to do this.

Great, I'll try it that way.
Thanks Daniel!

Jesse Glick

unread,
Sep 7, 2015, 3:56:20 PM9/7/15
to Jenkins Dev

Or there is a system property you can set to do the obvious thing on _all_ builds. (IMO you should need to select a configuration option to use the more complicated and fragile external storage.)

Antonio Muñiz

unread,
Sep 8, 2015, 4:51:30 AM9/8/15
to jenkin...@googlegroups.com

On Mon, Sep 7, 2015 at 9:56 PM, Jesse Glick <jgl...@cloudbees.com> wrote:
IMO you should need to select a configuration option to use the more complicated and fragile external storage

Jesse, not sure what you mean, what external storage?

Jesse Glick

unread,
Sep 8, 2015, 2:46:46 PM9/8/15
to Jenkins Dev
On Tue, Sep 8, 2015 at 4:51 AM, Antonio Muñiz <amu...@cloudbees.com> wrote:
> not sure what you mean, what external storage?

https://github.com/jenkinsci/timestamper-plugin/blob/409ae9298bf8c4252cabd0147aaea941c9a9a00f/src/main/java/hudson/plugins/timestamper/TimestamperBuildWrapper.java#L99

If you set a system property, or are using Workflow, the plugin just
inserts some annotations into the log like you probably expected.
Otherwise it uses a much more complicated scheme (added in 1.4)
involving a subdirectory of the build directory with some control
files, for reasons obscure to me.

Antonio Muñiz

unread,
Sep 8, 2015, 2:52:22 PM9/8/15
to jenkin...@googlegroups.com

On Tue, Sep 8, 2015 at 8:46 PM, Jesse Glick <jgl...@cloudbees.com> wrote:
If you set a system property, or are using Workflow, the plugin just
inserts some annotations into the log

Yeah, I relied on that feature to implement a similar one - basically the same but adding plain text timing entries** which is more suitable for external log parsers - https://github.com/jenkinsci/timestamper-plugin/pull/16

** Just note that the original feature adds timing entries in encoded binary format.
Reply all
Reply to author
Forward
0 new messages