You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jclouds.apache.org by John McDonnell <jo...@apache.org> on 2018/11/21 22:14:20 UTC

Custom Logging

Hi,

I use JClouds for creating accounts/domains, and retrieving usage on a CloudStack instance.  

We need to produce better logging where by we can match requests and responses in a single entry into a DB table.

From what I can see a custom logging module wouldn't quite work as it implements org.jclouds.logging.BaseLogger which only supports customising the "standard" log<level> methods.

I'm looking for an alternative, can we change the rest client used by JClouds?

Regards

John

Re: Custom Logging

Posted by Ignasi Barrera <na...@apache.org>.
Good! Keep us posted :)

If it works, this could be a good guest blog post in the jclouds blog. If
you are willing to write something we'd be super happy to publish that on
our site.

On Thu, Nov 22, 2018, 01:17 John McDonnell <johnmcdonnell@apache.org wrote:

> Hi,
>
> Cool, didn't see this class.
>
> Will investigate it over the next few days.
>
> Regards
>
> John
>
> On 2018/11/22 00:00:07, Ignasi Barrera <na...@apache.org> wrote:
> > Interesting.
> >
> > I see it supports Apache HttpClient and OkHttp, and we support both as
> http
> > drivers.
> >
> > Actually, for OkHttp you can provide a custom module that binds your
> > own OkHttpClientSupplier
> > [1] implementation and you could initialize it with the logbook
> interceptor.
> >
> > Could that be an option?
> >
> >
> >
> > [1]
> >
> https://github.com/jclouds/jclouds/blob/master/drivers/okhttp/src/main/java/org/jclouds/http/okhttp/OkHttpClientSupplier.java
> >
> >
> > On Thu, Nov 22, 2018, 00:50 John McDonnell <johnmcdonnell@apache.org
> wrote:
> >
> > > Hi Ignasi,
> > >
> > > Thanks for the reply.
> > >
> > > So the requirement we have is that we need to log both the requests and
> > > the responses to both a database table but also a file.  Additionally
> we
> > > would also need to hide passwords in any requests (i.e. if we create an
> > > account on CloudStack we need to supply a password).
> > >
> > > Previously we used a logging module here where by we logged each
> request
> > > or response (we did the password hiding here also), into a database
> table.
> > > The problem we have with using a class that extends from
> > > org.jclouds.logging.BaseLogger we couldn't match requests to responses
> as
> > > each request or response came in on its own to the logger to be logged.
> > >
> > > Ultimately we want to bring more consistency, when reviewing
> > > request/response logs its very hard to match them up when theres alot
> of
> > > traffic (we can communicate with multiple cloudstack instances within a
> > > short space of time).  I came across logbook recently and was
> intrigued but
> > > the more customisation it brings to logging, but was struggling to
> work out
> > > how to use something like this with JClouds.  My best guess was to see
> if
> > > we could customise the rest client used - to one supported by logbook.
> > >
> > > [1]: https://github.com/zalando/logbook
> > >
> > > Regards
> > >
> > > John
> > >
> > > On 2018/11/21 23:10:10, Ignasi Barrera <na...@apache.org> wrote:
> > > > Hi John,
> > > >
> > > > Can you elaborate a bit?
> > > > If you use the SLF4j driver with Logback, could you achieve what you
> need
> > > > with its Mapped Diagnostic Context [1]?
> > > >
> > > >
> > > > I.
> > > >
> > > > [1] https://logback.qos.ch/manual/mdc.html
> > > >
> > > >
> > > > On Wed, 21 Nov 2018 at 23:14, John McDonnell <
> johnmcdonnell@apache.org>
> > > > wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > I use JClouds for creating accounts/domains, and retrieving usage
> on a
> > > > > CloudStack instance.
> > > > >
> > > > > We need to produce better logging where by we can match requests
> and
> > > > > responses in a single entry into a DB table.
> > > > >
> > > > > From what I can see a custom logging module wouldn't quite work as
> it
> > > > > implements org.jclouds.logging.BaseLogger which only supports
> > > customising
> > > > > the "standard" log<level> methods.
> > > > >
> > > > > I'm looking for an alternative, can we change the rest client used
> by
> > > > > JClouds?
> > > > >
> > > > > Regards
> > > > >
> > > > > John
> > > > >
> > > >
> > >
> >
>

Re: Custom Logging

Posted by John McDonnell <jo...@apache.org>.
Hi,

Cool, didn't see this class.

Will investigate it over the next few days.

Regards

John

On 2018/11/22 00:00:07, Ignasi Barrera <na...@apache.org> wrote: 
> Interesting.
> 
> I see it supports Apache HttpClient and OkHttp, and we support both as http
> drivers.
> 
> Actually, for OkHttp you can provide a custom module that binds your
> own OkHttpClientSupplier
> [1] implementation and you could initialize it with the logbook interceptor.
> 
> Could that be an option?
> 
> 
> 
> [1]
> https://github.com/jclouds/jclouds/blob/master/drivers/okhttp/src/main/java/org/jclouds/http/okhttp/OkHttpClientSupplier.java
> 
> 
> On Thu, Nov 22, 2018, 00:50 John McDonnell <johnmcdonnell@apache.org wrote:
> 
> > Hi Ignasi,
> >
> > Thanks for the reply.
> >
> > So the requirement we have is that we need to log both the requests and
> > the responses to both a database table but also a file.  Additionally we
> > would also need to hide passwords in any requests (i.e. if we create an
> > account on CloudStack we need to supply a password).
> >
> > Previously we used a logging module here where by we logged each request
> > or response (we did the password hiding here also), into a database table.
> > The problem we have with using a class that extends from
> > org.jclouds.logging.BaseLogger we couldn't match requests to responses as
> > each request or response came in on its own to the logger to be logged.
> >
> > Ultimately we want to bring more consistency, when reviewing
> > request/response logs its very hard to match them up when theres alot of
> > traffic (we can communicate with multiple cloudstack instances within a
> > short space of time).  I came across logbook recently and was intrigued but
> > the more customisation it brings to logging, but was struggling to work out
> > how to use something like this with JClouds.  My best guess was to see if
> > we could customise the rest client used - to one supported by logbook.
> >
> > [1]: https://github.com/zalando/logbook
> >
> > Regards
> >
> > John
> >
> > On 2018/11/21 23:10:10, Ignasi Barrera <na...@apache.org> wrote:
> > > Hi John,
> > >
> > > Can you elaborate a bit?
> > > If you use the SLF4j driver with Logback, could you achieve what you need
> > > with its Mapped Diagnostic Context [1]?
> > >
> > >
> > > I.
> > >
> > > [1] https://logback.qos.ch/manual/mdc.html
> > >
> > >
> > > On Wed, 21 Nov 2018 at 23:14, John McDonnell <jo...@apache.org>
> > > wrote:
> > >
> > > > Hi,
> > > >
> > > > I use JClouds for creating accounts/domains, and retrieving usage on a
> > > > CloudStack instance.
> > > >
> > > > We need to produce better logging where by we can match requests and
> > > > responses in a single entry into a DB table.
> > > >
> > > > From what I can see a custom logging module wouldn't quite work as it
> > > > implements org.jclouds.logging.BaseLogger which only supports
> > customising
> > > > the "standard" log<level> methods.
> > > >
> > > > I'm looking for an alternative, can we change the rest client used by
> > > > JClouds?
> > > >
> > > > Regards
> > > >
> > > > John
> > > >
> > >
> >
> 

Re: Custom Logging

Posted by Ignasi Barrera <na...@apache.org>.
Interesting.

I see it supports Apache HttpClient and OkHttp, and we support both as http
drivers.

Actually, for OkHttp you can provide a custom module that binds your
own OkHttpClientSupplier
[1] implementation and you could initialize it with the logbook interceptor.

Could that be an option?



[1]
https://github.com/jclouds/jclouds/blob/master/drivers/okhttp/src/main/java/org/jclouds/http/okhttp/OkHttpClientSupplier.java


On Thu, Nov 22, 2018, 00:50 John McDonnell <johnmcdonnell@apache.org wrote:

> Hi Ignasi,
>
> Thanks for the reply.
>
> So the requirement we have is that we need to log both the requests and
> the responses to both a database table but also a file.  Additionally we
> would also need to hide passwords in any requests (i.e. if we create an
> account on CloudStack we need to supply a password).
>
> Previously we used a logging module here where by we logged each request
> or response (we did the password hiding here also), into a database table.
> The problem we have with using a class that extends from
> org.jclouds.logging.BaseLogger we couldn't match requests to responses as
> each request or response came in on its own to the logger to be logged.
>
> Ultimately we want to bring more consistency, when reviewing
> request/response logs its very hard to match them up when theres alot of
> traffic (we can communicate with multiple cloudstack instances within a
> short space of time).  I came across logbook recently and was intrigued but
> the more customisation it brings to logging, but was struggling to work out
> how to use something like this with JClouds.  My best guess was to see if
> we could customise the rest client used - to one supported by logbook.
>
> [1]: https://github.com/zalando/logbook
>
> Regards
>
> John
>
> On 2018/11/21 23:10:10, Ignasi Barrera <na...@apache.org> wrote:
> > Hi John,
> >
> > Can you elaborate a bit?
> > If you use the SLF4j driver with Logback, could you achieve what you need
> > with its Mapped Diagnostic Context [1]?
> >
> >
> > I.
> >
> > [1] https://logback.qos.ch/manual/mdc.html
> >
> >
> > On Wed, 21 Nov 2018 at 23:14, John McDonnell <jo...@apache.org>
> > wrote:
> >
> > > Hi,
> > >
> > > I use JClouds for creating accounts/domains, and retrieving usage on a
> > > CloudStack instance.
> > >
> > > We need to produce better logging where by we can match requests and
> > > responses in a single entry into a DB table.
> > >
> > > From what I can see a custom logging module wouldn't quite work as it
> > > implements org.jclouds.logging.BaseLogger which only supports
> customising
> > > the "standard" log<level> methods.
> > >
> > > I'm looking for an alternative, can we change the rest client used by
> > > JClouds?
> > >
> > > Regards
> > >
> > > John
> > >
> >
>

Re: Custom Logging

Posted by John McDonnell <jo...@apache.org>.
Hi Ignasi,

Thanks for the reply.

So the requirement we have is that we need to log both the requests and the responses to both a database table but also a file.  Additionally we would also need to hide passwords in any requests (i.e. if we create an account on CloudStack we need to supply a password).

Previously we used a logging module here where by we logged each request or response (we did the password hiding here also), into a database table.  The problem we have with using a class that extends from org.jclouds.logging.BaseLogger we couldn't match requests to responses as each request or response came in on its own to the logger to be logged.

Ultimately we want to bring more consistency, when reviewing request/response logs its very hard to match them up when theres alot of traffic (we can communicate with multiple cloudstack instances within a short space of time).  I came across logbook recently and was intrigued but the more customisation it brings to logging, but was struggling to work out how to use something like this with JClouds.  My best guess was to see if we could customise the rest client used - to one supported by logbook.

[1]: https://github.com/zalando/logbook

Regards

John

On 2018/11/21 23:10:10, Ignasi Barrera <na...@apache.org> wrote: 
> Hi John,
> 
> Can you elaborate a bit?
> If you use the SLF4j driver with Logback, could you achieve what you need
> with its Mapped Diagnostic Context [1]?
> 
> 
> I.
> 
> [1] https://logback.qos.ch/manual/mdc.html
> 
> 
> On Wed, 21 Nov 2018 at 23:14, John McDonnell <jo...@apache.org>
> wrote:
> 
> > Hi,
> >
> > I use JClouds for creating accounts/domains, and retrieving usage on a
> > CloudStack instance.
> >
> > We need to produce better logging where by we can match requests and
> > responses in a single entry into a DB table.
> >
> > From what I can see a custom logging module wouldn't quite work as it
> > implements org.jclouds.logging.BaseLogger which only supports customising
> > the "standard" log<level> methods.
> >
> > I'm looking for an alternative, can we change the rest client used by
> > JClouds?
> >
> > Regards
> >
> > John
> >
> 

Re: Custom Logging

Posted by Ignasi Barrera <na...@apache.org>.
Hi John,

Can you elaborate a bit?
If you use the SLF4j driver with Logback, could you achieve what you need
with its Mapped Diagnostic Context [1]?


I.

[1] https://logback.qos.ch/manual/mdc.html


On Wed, 21 Nov 2018 at 23:14, John McDonnell <jo...@apache.org>
wrote:

> Hi,
>
> I use JClouds for creating accounts/domains, and retrieving usage on a
> CloudStack instance.
>
> We need to produce better logging where by we can match requests and
> responses in a single entry into a DB table.
>
> From what I can see a custom logging module wouldn't quite work as it
> implements org.jclouds.logging.BaseLogger which only supports customising
> the "standard" log<level> methods.
>
> I'm looking for an alternative, can we change the rest client used by
> JClouds?
>
> Regards
>
> John
>