You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jclouds.apache.org by Timur Alperovich <ti...@gmail.com> on 2014/06/26 03:08:17 UTC

[jclouds-karaf] Initialization of log4j

Hi there,

I'm still looking into propagating an additional command line option
to affect the configuration of log4j (specifically, override the log
level and the location of the logs --
https://issues.apache.org/jira/browse/JCLOUDS-119) and I got a bit
lost in jclouds-karaf. Could someone point me to where Log4J is
initialized/configured (which is where, I presume, the log4j property
needs to be overriden -- I want to override the log4j.rootLogger and
log4j.appender.file.File properties)?

Maybe this is a totally wrong way to go about attempting to resolve
this issue -- please do let me know if that is the case.

Thank you!

-- 
Cheers,
Timur

Re: [jclouds-karaf] Initialization of log4j

Posted by Timur Alperovich <ti...@gmail.com>.
Thanks for the reply, Chris!

On Thu, Jun 26, 2014 at 12:26 AM, Chris Custine <ch...@gmail.com> wrote:
> I think the logging is configured differently if you use the interactive
> console via jclouds-cli (which is configured as part of the osgi runtime
> in etc/org.ops4j.pax.logging.cfg) or using the jclouds shell command
> (configured in etc/log4j.properties).  I think you can do what you want,
> but it will take a bit of work to figure out the right place to do it.  If
> PAX logging (the mechanism in Karaf that handles most of this) were to
> support log4j2 the EnvironmentLookup feature would work perfectly for this
> because you could just set the log level and location based on env
> variables.
> http://logging.apache.org/log4j/2.x/manual/lookups.html#EnvironmentLookup
>  Unfortunately it doesn't look like PAX logging supports log4j2 yet, but it
> might be in the works:
> http://karaf.922171.n3.nabble.com/Were-you-guys-still-interested-in-adopting-Log4j2-for-your-logging-system-td4033296.html
>
> One thing you can do is use the KARAF_OPTS env variable to set a path to a
> custom log4j.properties file.  I have one with special appenders and debug
> log level and I call the jclouds command like this:
> KARAF_OPTS="-Dlog4j.configuration=file://$(pwd)/etc/log4j-debug.properties"
> bin/jclouds image list
> --properties=/Users/ccustine/.jclouds/devstack.properties
>
> not the prettiest solution but HTH.

That's a really good pointer. I think I can definitely work around
this issue with the KARAF_OPTS variable for now.

> Chris
>
> --
> Chris Custine
>
>
>
> On Wed, Jun 25, 2014 at 7:08 PM, Timur Alperovich <
> timur.alperovich@gmail.com> wrote:
>
>> Hi there,
>>
>> I'm still looking into propagating an additional command line option
>> to affect the configuration of log4j (specifically, override the log
>> level and the location of the logs --
>> https://issues.apache.org/jira/browse/JCLOUDS-119) and I got a bit
>> lost in jclouds-karaf. Could someone point me to where Log4J is
>> initialized/configured (which is where, I presume, the log4j property
>> needs to be overriden -- I want to override the log4j.rootLogger and
>> log4j.appender.file.File properties)?
>>
>> Maybe this is a totally wrong way to go about attempting to resolve
>> this issue -- please do let me know if that is the case.
>>
>> Thank you!
>>
>> --
>> Cheers,
>> Timur
>>

-- 
Cheers,
Timur

Re: [jclouds-karaf] Initialization of log4j

Posted by Chris Custine <ch...@gmail.com>.
I think the logging is configured differently if you use the interactive
console via jclouds-cli (which is configured as part of the osgi runtime
in etc/org.ops4j.pax.logging.cfg) or using the jclouds shell command
(configured in etc/log4j.properties).  I think you can do what you want,
but it will take a bit of work to figure out the right place to do it.  If
PAX logging (the mechanism in Karaf that handles most of this) were to
support log4j2 the EnvironmentLookup feature would work perfectly for this
because you could just set the log level and location based on env
variables.
http://logging.apache.org/log4j/2.x/manual/lookups.html#EnvironmentLookup
 Unfortunately it doesn't look like PAX logging supports log4j2 yet, but it
might be in the works:
http://karaf.922171.n3.nabble.com/Were-you-guys-still-interested-in-adopting-Log4j2-for-your-logging-system-td4033296.html

One thing you can do is use the KARAF_OPTS env variable to set a path to a
custom log4j.properties file.  I have one with special appenders and debug
log level and I call the jclouds command like this:
KARAF_OPTS="-Dlog4j.configuration=file://$(pwd)/etc/log4j-debug.properties"
bin/jclouds image list
--properties=/Users/ccustine/.jclouds/devstack.properties

not the prettiest solution but HTH.

Chris

--
Chris Custine



On Wed, Jun 25, 2014 at 7:08 PM, Timur Alperovich <
timur.alperovich@gmail.com> wrote:

> Hi there,
>
> I'm still looking into propagating an additional command line option
> to affect the configuration of log4j (specifically, override the log
> level and the location of the logs --
> https://issues.apache.org/jira/browse/JCLOUDS-119) and I got a bit
> lost in jclouds-karaf. Could someone point me to where Log4J is
> initialized/configured (which is where, I presume, the log4j property
> needs to be overriden -- I want to override the log4j.rootLogger and
> log4j.appender.file.File properties)?
>
> Maybe this is a totally wrong way to go about attempting to resolve
> this issue -- please do let me know if that is the case.
>
> Thank you!
>
> --
> Cheers,
> Timur
>