jclouds-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ignasi Barrera <n...@apache.org>
Subject Re: Injecting own Logger documenation?
Date Mon, 16 Feb 2015 16:52:22 GMT
Hi Forrest,

To create a custom logger you just have to extend the jclouds BaseLogger
and create a LoggerFactory that creates instances of your logger. If you
have a look at the existing Log4jLogger [1], you'll see how you can
implement both. Once you have the logger and the factory, you just need to
create a Guice module that binds your custom implementation to the jclouds
Logger interface. Again, have a look at the existing Log4JLoggingModule [2]
to see how you can do this.

Once you have the logger implementation, the factory, and the Guice module,
you just need to create the jclouds Context passing your logging module:

ContextBuilder.newBuilder("...")
   .modules(ImmutableSet.of(new YourCustomLoggingModule()))
   (.....)


HTH!


I.


[1]
https://github.com/jclouds/jclouds/blob/master/drivers/log4j/src/main/java/org/jclouds/logging/log4j/Log4JLogger.java
[2]
https://github.com/jclouds/jclouds/blob/master/drivers/log4j/src/main/java/org/jclouds/logging/log4j/config/Log4JLoggingModule.java


On 16 February 2015 at 17:31, Forrest Townsend <forrest.town18@gmail.com>
wrote:

> Hello,
>
> Is there documentation that currently exists showing how to inject a
> custom logger in jclouds? My goal is to use a logger that only prints out
> errors to a file when I don't enable tracing through my program. But if I
> do enable tracing, it would lower the level of tracing for debug.
>
> Thanks.
>

Mime
View raw message