Global ConsoleLogFilter support in WorkflowRun

97 views
Skip to first unread message

Ted Xiao

unread,
Nov 18, 2016, 11:48:41 AM11/18/16
to Jenkins Developers
I wrote a plugin tee the console log to a central location by implementing the ConsoleLogFilter,  but it doesn't work for WorkflowRun.
Compared Run.java and WorkflowRun.java

In Run.java
OutputStream logger = new FileOutputStream(getLogFile(), true);
// Global log filters
for (ConsoleLogFilter filter : ConsoleLogFilter.all()) {
    logger
= filter.decorateLogger(build, logger);
}



But there is no decorateLogger either in onLoad or Run method, is this by design or accepting pull quests to add the feature?

Jesse Glick

unread,
Nov 18, 2016, 12:31:08 PM11/18/16
to Jenkins Dev
On Fri, Nov 18, 2016 at 5:48 PM, Ted Xiao <xia...@gmail.com> wrote:
> I wrote a plugin tee the console log to a central location by implementing
> the ConsoleLogFilter, but it doesn't work for WorkflowRun.

What are you trying to accomplish? If JENKINS-38381, that is not the
way to do it.

Ted Xiao

unread,
Nov 20, 2016, 10:53:18 PM11/20/16
to Jenkins Developers
I think it is different to JENKINS-38381, the filter I wrote works like Unix tee command which forward the console log to a 3rd party log analyse system for real time monitoring and alerting, here is the implement

Jesse Glick

unread,
Nov 21, 2016, 11:46:31 AM11/21/16
to Jenkins Dev
On Mon, Nov 21, 2016 at 4:53 AM, Ted Xiao <xia...@gmail.com> wrote:
> I think it is different to JENKINS-38381, the filter I wrote works like Unix
> tee command which forward the console log to a 3rd party log analyse system
> for real time monitoring and alerting

JENKINS-38381 accomplishes exactly that.

Ted Xiao

unread,
Nov 22, 2016, 10:29:34 AM11/22/16
to Jenkins Developers
Correct me if I am wrong,  through the PR https://github.com/jenkinsci/workflow-job-plugin/pull/27/files#diff-5ac278e2951f186bb7e2f76208e6ed05R76 , there is a comment // TODO JENKINS-30777 decorate with ConsoleLogFilter.all()
Does that mean I need to use explicit declare such as 

withContext(new MyConsoleLogFilter()) {
    sh 'process'

Jesse Glick

unread,
Nov 22, 2016, 11:00:12 AM11/22/16
to Jenkins Dev
On Tue, Nov 22, 2016 at 4:29 PM, Ted Xiao <xia...@gmail.com> wrote:
> through the PR
> https://github.com/jenkinsci/workflow-job-plugin/pull/27/files#diff-5ac278e2951f186bb7e2f76208e6ed05R76
> , there is a comment // TODO JENKINS-30777 decorate with
> ConsoleLogFilter.all()

Yes—if and when a use case for applying a global
(`@Extension`-registered) `ConsoleLogFilter` arises. AFAIK there are
none; under JENKINS-38381, sending log results to an external system
uses a different API. (`ConsoleLogFilter` is involved in the
implementation, but these are locally created filters, not global
extensions.) See the downstream
https://github.com/jenkinsci/logstash-plugin/pull/18 for a (crude)
example.

Please note that development on this system is currently on hold. It
is functionally complete and has basic test coverage, but is not
production ready. I have not yet written up a friendly design guide.

> Does that mean I need to use explicit declare such as
>
> withContext(new MyConsoleLogFilter()) {
> sh 'process'
> }

No, it is transparent to job definitions.

Ted Xiao

unread,
Nov 22, 2016, 10:35:55 PM11/22/16
to Jenkins Developers
it is much clear now, thank you very much, Jesse! 
it is true that most plugins such as timestamper-plugin,mask-passwords-plugin, logstash-plugin used build wrapper to decorate logger, and I am a little surprised that I was the first one to "abuse" the global ConsoleLogFilter feature.
Thanks, I will add a simple wrapper for WorkFlowRun job

Carles Capdevila Tejada

unread,
Jul 20, 2017, 8:55:21 AM7/20/17
to Jenkins Developers

Hello there,

 

I’m developing a plugin to perform regexp replacements on the Jenkins log output: https://github.com/SoftwareBuildService/log-file-filter-plugin

 

It is based on global settings to perform the regexps replacements for any job. I’ve written a custom pipeline step to perform this filtering (in a manner similar to https://issues.jenkins-ci.org/browse/JENKINS-27486) but this is not ideal for our use case. I would like the ConsoleLogFilter to filter pipeline logs without the need for any step.


Has there been any progress on the topic?

 

Thank you for your attention.

Jesse Glick

unread,
Jul 20, 2017, 10:06:46 AM7/20/17
to Jenkins Dev
On Thu, Jul 20, 2017 at 7:50 AM, Carles Capdevila Tejada
<capde...@gmail.com> wrote:
> Has there been any progress on the topic?

No. I filed JENKINS-45693 to reflect the fact that JENKINS-30777 on
its own was useless.
Reply all
Reply to author
Forward
0 new messages