slf4j & TaskListener.getLogger intercept

52 views
Skip to first unread message

Shaun Thompson

unread,
Dec 16, 2017, 2:18:23 PM12/16/17
to Jenkins Developers
I'm looking for ideas on a clean way to intercept logging in a Pipeline coming from the TaskListener.PrintStream getLogger() for other API's that are using slf4j.

Thanks

Jesse Glick

unread,
Dec 18, 2017, 9:16:18 AM12/18/17
to Jenkins Dev
On Sat, Dec 16, 2017 at 2:18 PM, Shaun Thompson <sth...@gmail.com> wrote:
> intercept logging in a Pipeline
> coming from the TaskListener.PrintStream getLogger() for other API's that
> are using slf4j.

Not sure what you are talking about. Build logs (`TaskListener`) and
the system log (`java.util.logging`) are unrelated.

Shaun Thompson

unread,
Dec 18, 2017, 3:16:15 PM12/18/17
to Jenkins Developers
I'm looking to output external logging, API's that use slf4j, to the build logs.  

Stephen Connolly

unread,
Dec 18, 2017, 4:04:16 PM12/18/17
to jenkin...@googlegroups.com
Running build related things in the Jenkins JVM is kind of an anti-pattern IMHO. Better to fork a JVM that you have complete control over the classloader, in which case the logging goes to STDOUT and you just pipe that to the build log

--
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-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/1a003078-f2a5-4e6d-b42a-782be39da94e%40googlegroups.com.

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

Shaun Thompson

unread,
Dec 19, 2017, 11:02:31 AM12/19/17
to Jenkins Developers
The way my plugin is setup is that I have a core API that has zero knowledge of Jenkins.   This allows the code to be used in a standalone cmd line or war type application.  Jenkins plugin just orchestrates the code.  I think I'll provide a thin wrapper around the TaskListener.PrintStream object for now in order to send valuable build information to the Pipeline build logs.

Thanks


On Monday, December 18, 2017 at 3:04:16 PM UTC-6, Stephen Connolly wrote:
Running build related things in the Jenkins JVM is kind of an anti-pattern IMHO. Better to fork a JVM that you have complete control over the classloader, in which case the logging goes to STDOUT and you just pipe that to the build log
On 18 December 2017 at 20:16, Shaun Thompson <sth...@gmail.com> wrote:
I'm looking to output external logging, API's that use slf4j, to the build logs.  

On Monday, December 18, 2017 at 8:16:18 AM UTC-6, Jesse Glick wrote:
On Sat, Dec 16, 2017 at 2:18 PM, Shaun Thompson <sth...@gmail.com> wrote:
> intercept logging in a Pipeline
> coming from the TaskListener.PrintStream getLogger() for other API's that
> are using slf4j.

Not sure what you are talking about. Build logs (`TaskListener`) and
the system log (`java.util.logging`) are unrelated.

--
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.

Shaun Thompson

unread,
Dec 19, 2017, 11:46:02 AM12/19/17
to Jenkins Developers
I guess the other approach is to have the plugin append to the Jenkins system log.  The plugin is using slf4j with jul-to-slf4j with a log4j2.xml configuration that goes to SYSTEM_OUT.  Before I start trying to find the write logging settings, is this possible?

Thanks
Reply all
Reply to author
Forward
0 new messages