You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stratos.apache.org by Lahiru Sandaruwan <la...@wso2.com> on 2015/02/23 02:57:42 UTC

Stick to one practice while logging

Hi all,

There are lot of different approaches of logging in Stratos code. May be we
can follow same format so that code looks clean and understandable. This is
to decide which way we should follow.

*1. Separation of objects*

We are using square brackets in most of the places. I think that is a good
approach. May be we can use a comma after one object. We need to decide.

E.g. 1

[network-partition] network-partition-1 [cluster-instance]
single-cartridge-app-1 [cluster] php1.php.domain

E.g. 2

[network-partition] network-partition-1, [cluster-instance]
single-cartridge-app-1, [cluster] php1.php.domain

*2. Using same text for identifying a particular type*
E.g. We use [network-parition], [NW partition], [network partition] in
different places. We could stick to one.

*3. Using the String.format or concatenation. *

String.format brings clarity and readability while it reduces the
performance against concatenation. We need to decide what should be our
choice. I would vote for String.format considering performance gain is
negligible if we only have info level logs.

*4. Use isDebugEnabled() and don't use isInfoEnabled()*

Regarding this, we must use *isDebugEnabled* everywhere we do debug
logging. But i think we can skip *isInfoEnabled *assuming we will have info
logs in limited numbers. Wdyt?

We can add a guidance at [2] for developers regarding all the matters here,
after deciding.

Thanks.

[1]
http://stackoverflow.com/questions/925423/is-it-better-practice-to-use-string-format-over-string-concatenation-in-java
[2] https://cwiki.apache.org/confluence/display/STRATOS/Developer+Guide
-- 
--
Lahiru Sandaruwan
Committer and PMC member, Apache Stratos,
Senior Software Engineer,
WSO2 Inc., http://wso2.com
lean.enterprise.middleware

email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146

Re: Stick to one practice while logging

Posted by Vishanth Balasubramaniam <vi...@wso2.com>.
Wiki looks good.

Should we also have to mention to include "Licensed to the Apache Software
Foundation..." comment under "Adding Java doc comments in the IDE" section
[1]?

[1] -
https://cwiki.apache.org/confluence/display/STRATOS/Coding+Standards+and+Best+Practices#CodingStandardsandBestPractices-JavaSpecific

Thank you,
Vishanth

On Wed, Feb 25, 2015 at 11:22 AM, Mariangela Hills <ma...@wso2.com>
wrote:

> Thanks, Shavindri!
>
> Regards,
> Mariangela
>
>
>
>
> *--*
> Mariangela Hills
> Senior Technical Writer
>
> *WSO2, Inc.*
>
>
> On Wed, Feb 25, 2015 at 11:00 AM, Lahiru Sandaruwan <la...@wso2.com>
> wrote:
>
>> Thanks Shavindri. Looks good.
>>
>> Thanks.
>>
>> On Wed, Feb 25, 2015 at 10:54 AM, Shavindri Dissanayake <
>> shavindri@wso2.com> wrote:
>>
>>> Hi Team,
>>>
>>> The suggested content has been documented [1] under Logging.
>>>
>>> [1]
>>> https://cwiki.apache.org/confluence/display/STRATOS/Coding+Standards+and+Best+Practices
>>> [2] https://issues.apache.org/jira/browse/STRATOS-1212
>>>
>>> Thanks & Regards
>>> Shavindri Dissanayake
>>> Technical Writer
>>> LinkedIn Profile
>>> <https://www.linkedin.com/profile/view?id=112227277&trk=nav_responsive_tab_profile>
>>> Mob: 0779966739
>>>
>>> WSO2 Inc.
>>> lean.enterprise.middleware
>>>
>>> On Tue, Feb 24, 2015 at 11:53 AM, Mariangela Hills <ma...@wso2.com>
>>> wrote:
>>>
>>>> +1
>>>>
>>>> Regards,
>>>> Mariangela
>>>>
>>>>
>>>>
>>>>
>>>> *--*
>>>> Mariangela Hills
>>>> Senior Technical Writer
>>>>
>>>> *WSO2, Inc.*lean.enterprise.middleware.
>>>> m: +94 773 500185
>>>> w: http://wso2.com
>>>> <http://wso2.com/events/>
>>>>
>>>> On Mon, Feb 23, 2015 at 11:37 AM, Lahiru Sandaruwan <la...@wso2.com>
>>>> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Mon, Feb 23, 2015 at 11:32 AM, Isuru Perera <is...@apache.org>
>>>>> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I agree with every point except for skipping isInfoEnabled(). I
>>>>>> believe we must use these guard conditions. Some might decide to run
>>>>>> Stratos with only Error/Warn level logs. We might avoid guard conditions
>>>>>> for error/fatal level logs.
>>>>>>
>>>>>
>>>>> Agree. Let's enable that flexibility as well. So if we use that, we
>>>>> should use them all occasions we log info.
>>>>>
>>>>> Mari,
>>>>>
>>>>> Shall we go ahead and create a page?
>>>>>
>>>>> Thanks.
>>>>>
>>>>>>
>>>>>> And use String.format. Always avoid concatenation. String.format is
>>>>>> much better than concatenation and it helps string pooling as well.
>>>>>>
>>>>>> Thanks!
>>>>>>
>>>>>> On Mon, Feb 23, 2015 at 11:22 AM, Rajkumar Rajaratnam <
>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>
>>>>>>> +1 Lahiru.
>>>>>>>
>>>>>>> Also if you are logging an object, make sure you are overriding
>>>>>>> toString() method of the class. Otherwise the log is nothing but a garbage.
>>>>>>> Just got this log on master branch.
>>>>>>>
>>>>>>> *Rule executed for:
>>>>>>> org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext@42c0a4d8*
>>>>>>>
>>>>>>> ClusterLevelPartitionContext class doesn't override toString()
>>>>>>> method.
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> On Mon, Feb 23, 2015 at 7:27 AM, Lahiru Sandaruwan <lahirus@wso2.com
>>>>>>> > wrote:
>>>>>>>
>>>>>>>> Hi all,
>>>>>>>>
>>>>>>>> There are lot of different approaches of logging in Stratos code.
>>>>>>>> May be we can follow same format so that code looks clean and
>>>>>>>> understandable. This is to decide which way we should follow.
>>>>>>>>
>>>>>>>> *1. Separation of objects*
>>>>>>>>
>>>>>>>> We are using square brackets in most of the places. I think that is
>>>>>>>> a good approach. May be we can use a comma after one object. We need to
>>>>>>>> decide.
>>>>>>>>
>>>>>>>> E.g. 1
>>>>>>>>
>>>>>>>> [network-partition] network-partition-1 [cluster-instance]
>>>>>>>> single-cartridge-app-1 [cluster] php1.php.domain
>>>>>>>>
>>>>>>>> E.g. 2
>>>>>>>>
>>>>>>>> [network-partition] network-partition-1, [cluster-instance]
>>>>>>>> single-cartridge-app-1, [cluster] php1.php.domain
>>>>>>>>
>>>>>>>> *2. Using same text for identifying a particular type*
>>>>>>>> E.g. We use [network-parition], [NW partition], [network partition]
>>>>>>>> in different places. We could stick to one.
>>>>>>>>
>>>>>>>> *3. Using the String.format or concatenation. *
>>>>>>>>
>>>>>>>> String.format brings clarity and readability while it reduces the
>>>>>>>> performance against concatenation. We need to decide what should be our
>>>>>>>> choice. I would vote for String.format considering performance gain is
>>>>>>>> negligible if we only have info level logs.
>>>>>>>>
>>>>>>>> *4. Use isDebugEnabled() and don't use isInfoEnabled()*
>>>>>>>>
>>>>>>>> Regarding this, we must use *isDebugEnabled* everywhere we do
>>>>>>>> debug logging. But i think we can skip *isInfoEnabled *assuming we
>>>>>>>> will have info logs in limited numbers. Wdyt?
>>>>>>>>
>>>>>>>> We can add a guidance at [2] for developers regarding all the
>>>>>>>> matters here, after deciding.
>>>>>>>>
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>> [1]
>>>>>>>> http://stackoverflow.com/questions/925423/is-it-better-practice-to-use-string-format-over-string-concatenation-in-java
>>>>>>>> [2]
>>>>>>>> https://cwiki.apache.org/confluence/display/STRATOS/Developer+Guide
>>>>>>>> --
>>>>>>>> --
>>>>>>>> Lahiru Sandaruwan
>>>>>>>> Committer and PMC member, Apache Stratos,
>>>>>>>> Senior Software Engineer,
>>>>>>>> WSO2 Inc., http://wso2.com
>>>>>>>> lean.enterprise.middleware
>>>>>>>>
>>>>>>>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>>>>>>>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Rajkumar Rajaratnam
>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>> Software Engineer, WSO2
>>>>>>>
>>>>>>> Mobile : +94777568639
>>>>>>> Blog : rajkumarr.com
>>>>>>>
>>>>>>> --
>>>>>>> <http://rajkumarr.com>
>>>>>>> <http://rajkumarr.com>
>>>>>>> Isuru Perera
>>>>>>> Senior Software Engineer | WSO2, Inc. | <http://rajkumarr.com>
>>>>>>> http://wso2.com/
>>>>>>> Lean . Enterprise . Middleware
>>>>>>>
>>>>>>> about.me/chrishantha
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> --
>>>>> Lahiru Sandaruwan
>>>>> Committer and PMC member, Apache Stratos,
>>>>> Senior Software Engineer,
>>>>> WSO2 Inc., http://wso2.com
>>>>> lean.enterprise.middleware
>>>>>
>>>>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>>>>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>>>>
>>>>>
>>>>
>>>
>>
>>
>> --
>> --
>> Lahiru Sandaruwan
>> Committer and PMC member, Apache Stratos,
>> Senior Software Engineer,
>> WSO2 Inc., http://wso2.com
>> lean.enterprise.middleware
>>
>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>
>>
>


-- 
*Vishanth Balasubramaniam*
Software Engineer
WSO2 Inc.; http://wso2.com
lean.enterprise.middleware

mobile: *+94771737718*
about me: *http://about.me/vishanth <http://about.me/vishanth>*

Re: Stick to one practice while logging

Posted by Mariangela Hills <ma...@wso2.com>.
Thanks, Shavindri!

Regards,
Mariangela




*--*
Mariangela Hills
Senior Technical Writer

*WSO2, Inc.*


On Wed, Feb 25, 2015 at 11:00 AM, Lahiru Sandaruwan <la...@wso2.com>
wrote:

> Thanks Shavindri. Looks good.
>
> Thanks.
>
> On Wed, Feb 25, 2015 at 10:54 AM, Shavindri Dissanayake <
> shavindri@wso2.com> wrote:
>
>> Hi Team,
>>
>> The suggested content has been documented [1] under Logging.
>>
>> [1]
>> https://cwiki.apache.org/confluence/display/STRATOS/Coding+Standards+and+Best+Practices
>> [2] https://issues.apache.org/jira/browse/STRATOS-1212
>>
>> Thanks & Regards
>> Shavindri Dissanayake
>> Technical Writer
>> LinkedIn Profile
>> <https://www.linkedin.com/profile/view?id=112227277&trk=nav_responsive_tab_profile>
>> Mob: 0779966739
>>
>> WSO2 Inc.
>> lean.enterprise.middleware
>>
>> On Tue, Feb 24, 2015 at 11:53 AM, Mariangela Hills <ma...@wso2.com>
>> wrote:
>>
>>> +1
>>>
>>> Regards,
>>> Mariangela
>>>
>>>
>>>
>>>
>>> *--*
>>> Mariangela Hills
>>> Senior Technical Writer
>>>
>>> *WSO2, Inc.*lean.enterprise.middleware.
>>> m: +94 773 500185
>>> w: http://wso2.com
>>> <http://wso2.com/events/>
>>>
>>> On Mon, Feb 23, 2015 at 11:37 AM, Lahiru Sandaruwan <la...@wso2.com>
>>> wrote:
>>>
>>>>
>>>>
>>>> On Mon, Feb 23, 2015 at 11:32 AM, Isuru Perera <is...@apache.org>
>>>> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I agree with every point except for skipping isInfoEnabled(). I
>>>>> believe we must use these guard conditions. Some might decide to run
>>>>> Stratos with only Error/Warn level logs. We might avoid guard conditions
>>>>> for error/fatal level logs.
>>>>>
>>>>
>>>> Agree. Let's enable that flexibility as well. So if we use that, we
>>>> should use them all occasions we log info.
>>>>
>>>> Mari,
>>>>
>>>> Shall we go ahead and create a page?
>>>>
>>>> Thanks.
>>>>
>>>>>
>>>>> And use String.format. Always avoid concatenation. String.format is
>>>>> much better than concatenation and it helps string pooling as well.
>>>>>
>>>>> Thanks!
>>>>>
>>>>> On Mon, Feb 23, 2015 at 11:22 AM, Rajkumar Rajaratnam <
>>>>> rajkumarr@wso2.com> wrote:
>>>>>
>>>>>> +1 Lahiru.
>>>>>>
>>>>>> Also if you are logging an object, make sure you are overriding
>>>>>> toString() method of the class. Otherwise the log is nothing but a garbage.
>>>>>> Just got this log on master branch.
>>>>>>
>>>>>> *Rule executed for:
>>>>>> org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext@42c0a4d8*
>>>>>>
>>>>>> ClusterLevelPartitionContext class doesn't override toString()
>>>>>> method.
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> On Mon, Feb 23, 2015 at 7:27 AM, Lahiru Sandaruwan <la...@wso2.com>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi all,
>>>>>>>
>>>>>>> There are lot of different approaches of logging in Stratos code.
>>>>>>> May be we can follow same format so that code looks clean and
>>>>>>> understandable. This is to decide which way we should follow.
>>>>>>>
>>>>>>> *1. Separation of objects*
>>>>>>>
>>>>>>> We are using square brackets in most of the places. I think that is
>>>>>>> a good approach. May be we can use a comma after one object. We need to
>>>>>>> decide.
>>>>>>>
>>>>>>> E.g. 1
>>>>>>>
>>>>>>> [network-partition] network-partition-1 [cluster-instance]
>>>>>>> single-cartridge-app-1 [cluster] php1.php.domain
>>>>>>>
>>>>>>> E.g. 2
>>>>>>>
>>>>>>> [network-partition] network-partition-1, [cluster-instance]
>>>>>>> single-cartridge-app-1, [cluster] php1.php.domain
>>>>>>>
>>>>>>> *2. Using same text for identifying a particular type*
>>>>>>> E.g. We use [network-parition], [NW partition], [network partition]
>>>>>>> in different places. We could stick to one.
>>>>>>>
>>>>>>> *3. Using the String.format or concatenation. *
>>>>>>>
>>>>>>> String.format brings clarity and readability while it reduces the
>>>>>>> performance against concatenation. We need to decide what should be our
>>>>>>> choice. I would vote for String.format considering performance gain is
>>>>>>> negligible if we only have info level logs.
>>>>>>>
>>>>>>> *4. Use isDebugEnabled() and don't use isInfoEnabled()*
>>>>>>>
>>>>>>> Regarding this, we must use *isDebugEnabled* everywhere we do debug
>>>>>>> logging. But i think we can skip *isInfoEnabled *assuming we will
>>>>>>> have info logs in limited numbers. Wdyt?
>>>>>>>
>>>>>>> We can add a guidance at [2] for developers regarding all the
>>>>>>> matters here, after deciding.
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> [1]
>>>>>>> http://stackoverflow.com/questions/925423/is-it-better-practice-to-use-string-format-over-string-concatenation-in-java
>>>>>>> [2]
>>>>>>> https://cwiki.apache.org/confluence/display/STRATOS/Developer+Guide
>>>>>>> --
>>>>>>> --
>>>>>>> Lahiru Sandaruwan
>>>>>>> Committer and PMC member, Apache Stratos,
>>>>>>> Senior Software Engineer,
>>>>>>> WSO2 Inc., http://wso2.com
>>>>>>> lean.enterprise.middleware
>>>>>>>
>>>>>>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>>>>>>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Rajkumar Rajaratnam
>>>>>> Committer & PMC Member, Apache Stratos
>>>>>> Software Engineer, WSO2
>>>>>>
>>>>>> Mobile : +94777568639
>>>>>> Blog : rajkumarr.com
>>>>>>
>>>>>> --
>>>>>> <http://rajkumarr.com>
>>>>>> <http://rajkumarr.com>
>>>>>> Isuru Perera
>>>>>> Senior Software Engineer | WSO2, Inc. | <http://rajkumarr.com>
>>>>>> http://wso2.com/
>>>>>> Lean . Enterprise . Middleware
>>>>>>
>>>>>> about.me/chrishantha
>>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> --
>>>> Lahiru Sandaruwan
>>>> Committer and PMC member, Apache Stratos,
>>>> Senior Software Engineer,
>>>> WSO2 Inc., http://wso2.com
>>>> lean.enterprise.middleware
>>>>
>>>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>>>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>>>
>>>>
>>>
>>
>
>
> --
> --
> Lahiru Sandaruwan
> Committer and PMC member, Apache Stratos,
> Senior Software Engineer,
> WSO2 Inc., http://wso2.com
> lean.enterprise.middleware
>
> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>
>

Re: Stick to one practice while logging

Posted by Lahiru Sandaruwan <la...@wso2.com>.
Thanks Shavindri. Looks good.

Thanks.

On Wed, Feb 25, 2015 at 10:54 AM, Shavindri Dissanayake <sh...@wso2.com>
wrote:

> Hi Team,
>
> The suggested content has been documented [1] under Logging.
>
> [1]
> https://cwiki.apache.org/confluence/display/STRATOS/Coding+Standards+and+Best+Practices
> [2] https://issues.apache.org/jira/browse/STRATOS-1212
>
> Thanks & Regards
> Shavindri Dissanayake
> Technical Writer
> LinkedIn Profile
> <https://www.linkedin.com/profile/view?id=112227277&trk=nav_responsive_tab_profile>
> Mob: 0779966739
>
> WSO2 Inc.
> lean.enterprise.middleware
>
> On Tue, Feb 24, 2015 at 11:53 AM, Mariangela Hills <ma...@wso2.com>
> wrote:
>
>> +1
>>
>> Regards,
>> Mariangela
>>
>>
>>
>>
>> *--*
>> Mariangela Hills
>> Senior Technical Writer
>>
>> *WSO2, Inc.*lean.enterprise.middleware.
>> m: +94 773 500185
>> w: http://wso2.com
>> <http://wso2.com/events/>
>>
>> On Mon, Feb 23, 2015 at 11:37 AM, Lahiru Sandaruwan <la...@wso2.com>
>> wrote:
>>
>>>
>>>
>>> On Mon, Feb 23, 2015 at 11:32 AM, Isuru Perera <is...@apache.org> wrote:
>>>
>>>> Hi,
>>>>
>>>> I agree with every point except for skipping isInfoEnabled(). I believe
>>>> we must use these guard conditions. Some might decide to run Stratos with
>>>> only Error/Warn level logs. We might avoid guard conditions for error/fatal
>>>> level logs.
>>>>
>>>
>>> Agree. Let's enable that flexibility as well. So if we use that, we
>>> should use them all occasions we log info.
>>>
>>> Mari,
>>>
>>> Shall we go ahead and create a page?
>>>
>>> Thanks.
>>>
>>>>
>>>> And use String.format. Always avoid concatenation. String.format is
>>>> much better than concatenation and it helps string pooling as well.
>>>>
>>>> Thanks!
>>>>
>>>> On Mon, Feb 23, 2015 at 11:22 AM, Rajkumar Rajaratnam <
>>>> rajkumarr@wso2.com> wrote:
>>>>
>>>>> +1 Lahiru.
>>>>>
>>>>> Also if you are logging an object, make sure you are overriding
>>>>> toString() method of the class. Otherwise the log is nothing but a garbage.
>>>>> Just got this log on master branch.
>>>>>
>>>>> *Rule executed for:
>>>>> org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext@42c0a4d8*
>>>>>
>>>>> ClusterLevelPartitionContext class doesn't override toString()  method.
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Mon, Feb 23, 2015 at 7:27 AM, Lahiru Sandaruwan <la...@wso2.com>
>>>>> wrote:
>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> There are lot of different approaches of logging in Stratos code. May
>>>>>> be we can follow same format so that code looks clean and understandable.
>>>>>> This is to decide which way we should follow.
>>>>>>
>>>>>> *1. Separation of objects*
>>>>>>
>>>>>> We are using square brackets in most of the places. I think that is a
>>>>>> good approach. May be we can use a comma after one object. We need to
>>>>>> decide.
>>>>>>
>>>>>> E.g. 1
>>>>>>
>>>>>> [network-partition] network-partition-1 [cluster-instance]
>>>>>> single-cartridge-app-1 [cluster] php1.php.domain
>>>>>>
>>>>>> E.g. 2
>>>>>>
>>>>>> [network-partition] network-partition-1, [cluster-instance]
>>>>>> single-cartridge-app-1, [cluster] php1.php.domain
>>>>>>
>>>>>> *2. Using same text for identifying a particular type*
>>>>>> E.g. We use [network-parition], [NW partition], [network partition]
>>>>>> in different places. We could stick to one.
>>>>>>
>>>>>> *3. Using the String.format or concatenation. *
>>>>>>
>>>>>> String.format brings clarity and readability while it reduces the
>>>>>> performance against concatenation. We need to decide what should be our
>>>>>> choice. I would vote for String.format considering performance gain is
>>>>>> negligible if we only have info level logs.
>>>>>>
>>>>>> *4. Use isDebugEnabled() and don't use isInfoEnabled()*
>>>>>>
>>>>>> Regarding this, we must use *isDebugEnabled* everywhere we do debug
>>>>>> logging. But i think we can skip *isInfoEnabled *assuming we will
>>>>>> have info logs in limited numbers. Wdyt?
>>>>>>
>>>>>> We can add a guidance at [2] for developers regarding all the matters
>>>>>> here, after deciding.
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> [1]
>>>>>> http://stackoverflow.com/questions/925423/is-it-better-practice-to-use-string-format-over-string-concatenation-in-java
>>>>>> [2]
>>>>>> https://cwiki.apache.org/confluence/display/STRATOS/Developer+Guide
>>>>>> --
>>>>>> --
>>>>>> Lahiru Sandaruwan
>>>>>> Committer and PMC member, Apache Stratos,
>>>>>> Senior Software Engineer,
>>>>>> WSO2 Inc., http://wso2.com
>>>>>> lean.enterprise.middleware
>>>>>>
>>>>>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>>>>>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Rajkumar Rajaratnam
>>>>> Committer & PMC Member, Apache Stratos
>>>>> Software Engineer, WSO2
>>>>>
>>>>> Mobile : +94777568639
>>>>> Blog : rajkumarr.com
>>>>>
>>>>> --
>>>>> <http://rajkumarr.com>
>>>>> <http://rajkumarr.com>
>>>>> Isuru Perera
>>>>> Senior Software Engineer | WSO2, Inc. | <http://rajkumarr.com>
>>>>> http://wso2.com/
>>>>> Lean . Enterprise . Middleware
>>>>>
>>>>> about.me/chrishantha
>>>>>
>>>>
>>>
>>>
>>> --
>>> --
>>> Lahiru Sandaruwan
>>> Committer and PMC member, Apache Stratos,
>>> Senior Software Engineer,
>>> WSO2 Inc., http://wso2.com
>>> lean.enterprise.middleware
>>>
>>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>>
>>>
>>
>


-- 
--
Lahiru Sandaruwan
Committer and PMC member, Apache Stratos,
Senior Software Engineer,
WSO2 Inc., http://wso2.com
lean.enterprise.middleware

email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146

Re: Stick to one practice while logging

Posted by Shavindri Dissanayake <sh...@wso2.com>.
Hi Team,

The suggested content has been documented [1] under Logging.

[1]
https://cwiki.apache.org/confluence/display/STRATOS/Coding+Standards+and+Best+Practices
[2] https://issues.apache.org/jira/browse/STRATOS-1212

Thanks & Regards
Shavindri Dissanayake
Technical Writer
LinkedIn Profile
<https://www.linkedin.com/profile/view?id=112227277&trk=nav_responsive_tab_profile>
Mob: 0779966739

WSO2 Inc.
lean.enterprise.middleware

On Tue, Feb 24, 2015 at 11:53 AM, Mariangela Hills <ma...@wso2.com>
wrote:

> +1
>
> Regards,
> Mariangela
>
>
>
>
> *--*
> Mariangela Hills
> Senior Technical Writer
>
> *WSO2, Inc.*lean.enterprise.middleware.
> m: +94 773 500185
> w: http://wso2.com
> <http://wso2.com/events/>
>
> On Mon, Feb 23, 2015 at 11:37 AM, Lahiru Sandaruwan <la...@wso2.com>
> wrote:
>
>>
>>
>> On Mon, Feb 23, 2015 at 11:32 AM, Isuru Perera <is...@apache.org> wrote:
>>
>>> Hi,
>>>
>>> I agree with every point except for skipping isInfoEnabled(). I believe
>>> we must use these guard conditions. Some might decide to run Stratos with
>>> only Error/Warn level logs. We might avoid guard conditions for error/fatal
>>> level logs.
>>>
>>
>> Agree. Let's enable that flexibility as well. So if we use that, we
>> should use them all occasions we log info.
>>
>> Mari,
>>
>> Shall we go ahead and create a page?
>>
>> Thanks.
>>
>>>
>>> And use String.format. Always avoid concatenation. String.format is much
>>> better than concatenation and it helps string pooling as well.
>>>
>>> Thanks!
>>>
>>> On Mon, Feb 23, 2015 at 11:22 AM, Rajkumar Rajaratnam <
>>> rajkumarr@wso2.com> wrote:
>>>
>>>> +1 Lahiru.
>>>>
>>>> Also if you are logging an object, make sure you are overriding
>>>> toString() method of the class. Otherwise the log is nothing but a garbage.
>>>> Just got this log on master branch.
>>>>
>>>> *Rule executed for:
>>>> org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext@42c0a4d8*
>>>>
>>>> ClusterLevelPartitionContext class doesn't override toString()  method.
>>>>
>>>> Thanks.
>>>>
>>>> On Mon, Feb 23, 2015 at 7:27 AM, Lahiru Sandaruwan <la...@wso2.com>
>>>> wrote:
>>>>
>>>>> Hi all,
>>>>>
>>>>> There are lot of different approaches of logging in Stratos code. May
>>>>> be we can follow same format so that code looks clean and understandable.
>>>>> This is to decide which way we should follow.
>>>>>
>>>>> *1. Separation of objects*
>>>>>
>>>>> We are using square brackets in most of the places. I think that is a
>>>>> good approach. May be we can use a comma after one object. We need to
>>>>> decide.
>>>>>
>>>>> E.g. 1
>>>>>
>>>>> [network-partition] network-partition-1 [cluster-instance]
>>>>> single-cartridge-app-1 [cluster] php1.php.domain
>>>>>
>>>>> E.g. 2
>>>>>
>>>>> [network-partition] network-partition-1, [cluster-instance]
>>>>> single-cartridge-app-1, [cluster] php1.php.domain
>>>>>
>>>>> *2. Using same text for identifying a particular type*
>>>>> E.g. We use [network-parition], [NW partition], [network partition] in
>>>>> different places. We could stick to one.
>>>>>
>>>>> *3. Using the String.format or concatenation. *
>>>>>
>>>>> String.format brings clarity and readability while it reduces the
>>>>> performance against concatenation. We need to decide what should be our
>>>>> choice. I would vote for String.format considering performance gain is
>>>>> negligible if we only have info level logs.
>>>>>
>>>>> *4. Use isDebugEnabled() and don't use isInfoEnabled()*
>>>>>
>>>>> Regarding this, we must use *isDebugEnabled* everywhere we do debug
>>>>> logging. But i think we can skip *isInfoEnabled *assuming we will
>>>>> have info logs in limited numbers. Wdyt?
>>>>>
>>>>> We can add a guidance at [2] for developers regarding all the matters
>>>>> here, after deciding.
>>>>>
>>>>> Thanks.
>>>>>
>>>>> [1]
>>>>> http://stackoverflow.com/questions/925423/is-it-better-practice-to-use-string-format-over-string-concatenation-in-java
>>>>> [2]
>>>>> https://cwiki.apache.org/confluence/display/STRATOS/Developer+Guide
>>>>> --
>>>>> --
>>>>> Lahiru Sandaruwan
>>>>> Committer and PMC member, Apache Stratos,
>>>>> Senior Software Engineer,
>>>>> WSO2 Inc., http://wso2.com
>>>>> lean.enterprise.middleware
>>>>>
>>>>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>>>>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Rajkumar Rajaratnam
>>>> Committer & PMC Member, Apache Stratos
>>>> Software Engineer, WSO2
>>>>
>>>> Mobile : +94777568639
>>>> Blog : rajkumarr.com
>>>>
>>>> --
>>>> <http://rajkumarr.com>
>>>> <http://rajkumarr.com>
>>>> Isuru Perera
>>>> Senior Software Engineer | WSO2, Inc. | <http://rajkumarr.com>
>>>> http://wso2.com/
>>>> Lean . Enterprise . Middleware
>>>>
>>>> about.me/chrishantha
>>>>
>>>
>>
>>
>> --
>> --
>> Lahiru Sandaruwan
>> Committer and PMC member, Apache Stratos,
>> Senior Software Engineer,
>> WSO2 Inc., http://wso2.com
>> lean.enterprise.middleware
>>
>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>
>>
>

Re: Stick to one practice while logging

Posted by Mariangela Hills <ma...@wso2.com>.
+1

Regards,
Mariangela




*--*
Mariangela Hills
Senior Technical Writer

*WSO2, Inc.*lean.enterprise.middleware.
m: +94 773 500185
w: http://wso2.com
<http://wso2.com/events/>

On Mon, Feb 23, 2015 at 11:37 AM, Lahiru Sandaruwan <la...@wso2.com>
wrote:

>
>
> On Mon, Feb 23, 2015 at 11:32 AM, Isuru Perera <is...@apache.org> wrote:
>
>> Hi,
>>
>> I agree with every point except for skipping isInfoEnabled(). I believe
>> we must use these guard conditions. Some might decide to run Stratos with
>> only Error/Warn level logs. We might avoid guard conditions for error/fatal
>> level logs.
>>
>
> Agree. Let's enable that flexibility as well. So if we use that, we should
> use them all occasions we log info.
>
> Mari,
>
> Shall we go ahead and create a page?
>
> Thanks.
>
>>
>> And use String.format. Always avoid concatenation. String.format is much
>> better than concatenation and it helps string pooling as well.
>>
>> Thanks!
>>
>> On Mon, Feb 23, 2015 at 11:22 AM, Rajkumar Rajaratnam <rajkumarr@wso2.com
>> > wrote:
>>
>>> +1 Lahiru.
>>>
>>> Also if you are logging an object, make sure you are overriding
>>> toString() method of the class. Otherwise the log is nothing but a garbage.
>>> Just got this log on master branch.
>>>
>>> *Rule executed for:
>>> org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext@42c0a4d8*
>>>
>>> ClusterLevelPartitionContext class doesn't override toString()  method.
>>>
>>> Thanks.
>>>
>>> On Mon, Feb 23, 2015 at 7:27 AM, Lahiru Sandaruwan <la...@wso2.com>
>>> wrote:
>>>
>>>> Hi all,
>>>>
>>>> There are lot of different approaches of logging in Stratos code. May
>>>> be we can follow same format so that code looks clean and understandable.
>>>> This is to decide which way we should follow.
>>>>
>>>> *1. Separation of objects*
>>>>
>>>> We are using square brackets in most of the places. I think that is a
>>>> good approach. May be we can use a comma after one object. We need to
>>>> decide.
>>>>
>>>> E.g. 1
>>>>
>>>> [network-partition] network-partition-1 [cluster-instance]
>>>> single-cartridge-app-1 [cluster] php1.php.domain
>>>>
>>>> E.g. 2
>>>>
>>>> [network-partition] network-partition-1, [cluster-instance]
>>>> single-cartridge-app-1, [cluster] php1.php.domain
>>>>
>>>> *2. Using same text for identifying a particular type*
>>>> E.g. We use [network-parition], [NW partition], [network partition] in
>>>> different places. We could stick to one.
>>>>
>>>> *3. Using the String.format or concatenation. *
>>>>
>>>> String.format brings clarity and readability while it reduces the
>>>> performance against concatenation. We need to decide what should be our
>>>> choice. I would vote for String.format considering performance gain is
>>>> negligible if we only have info level logs.
>>>>
>>>> *4. Use isDebugEnabled() and don't use isInfoEnabled()*
>>>>
>>>> Regarding this, we must use *isDebugEnabled* everywhere we do debug
>>>> logging. But i think we can skip *isInfoEnabled *assuming we will have
>>>> info logs in limited numbers. Wdyt?
>>>>
>>>> We can add a guidance at [2] for developers regarding all the matters
>>>> here, after deciding.
>>>>
>>>> Thanks.
>>>>
>>>> [1]
>>>> http://stackoverflow.com/questions/925423/is-it-better-practice-to-use-string-format-over-string-concatenation-in-java
>>>> [2] https://cwiki.apache.org/confluence/display/STRATOS/Developer+Guide
>>>> --
>>>> --
>>>> Lahiru Sandaruwan
>>>> Committer and PMC member, Apache Stratos,
>>>> Senior Software Engineer,
>>>> WSO2 Inc., http://wso2.com
>>>> lean.enterprise.middleware
>>>>
>>>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>>>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>>>
>>>>
>>>
>>>
>>> --
>>> Rajkumar Rajaratnam
>>> Committer & PMC Member, Apache Stratos
>>> Software Engineer, WSO2
>>>
>>> Mobile : +94777568639
>>> Blog : rajkumarr.com
>>>
>>> --
>>> <http://rajkumarr.com>
>>> <http://rajkumarr.com>
>>> Isuru Perera
>>> Senior Software Engineer | WSO2, Inc. | <http://rajkumarr.com>
>>> http://wso2.com/
>>> Lean . Enterprise . Middleware
>>>
>>> about.me/chrishantha
>>>
>>
>
>
> --
> --
> Lahiru Sandaruwan
> Committer and PMC member, Apache Stratos,
> Senior Software Engineer,
> WSO2 Inc., http://wso2.com
> lean.enterprise.middleware
>
> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>
>

Re: Stick to one practice while logging

Posted by Lahiru Sandaruwan <la...@wso2.com>.
On Mon, Feb 23, 2015 at 11:50 AM, Chamila De Alwis <ch...@wso2.com>
wrote:

> Hi,
>
> +1 for all these changes. This might be crucial in the usability aspect of
> the product.  Another irregularity I've seen is the generic nature of a log
> entry. If a debug/info entry is there indicating a certain operation is to
> be done, it should indicate that the operation is *about* to be done, not
> being done or done. If, say, "Git checkout" is the log entry  before
> actually making that decision, it can be ambiguous.
>

A good point Chamila,

Talking about best practices, we should also try to log all the details we
have at the time we log. Shouldn't leave any information that are related
the information we give at the log.

We can have entries for these facts as well, in the doc.

Thanks.

>
>
>
>
> Regards,
> Chamila de Alwis
> Software Engineer | WSO2 | +94772207163
> Blog: code.chamiladealwis.com
>
>
>
> On Mon, Feb 23, 2015 at 11:37 AM, Lahiru Sandaruwan <la...@wso2.com>
> wrote:
>
>>
>>
>> On Mon, Feb 23, 2015 at 11:32 AM, Isuru Perera <is...@apache.org> wrote:
>>
>>> Hi,
>>>
>>> I agree with every point except for skipping isInfoEnabled(). I believe
>>> we must use these guard conditions. Some might decide to run Stratos with
>>> only Error/Warn level logs. We might avoid guard conditions for error/fatal
>>> level logs.
>>>
>>
>> Agree. Let's enable that flexibility as well. So if we use that, we
>> should use them all occasions we log info.
>>
>> Mari,
>>
>> Shall we go ahead and create a page?
>>
>> Thanks.
>>
>>>
>>> And use String.format. Always avoid concatenation. String.format is much
>>> better than concatenation and it helps string pooling as well.
>>>
>>> Thanks!
>>>
>>> On Mon, Feb 23, 2015 at 11:22 AM, Rajkumar Rajaratnam <
>>> rajkumarr@wso2.com> wrote:
>>>
>>>> +1 Lahiru.
>>>>
>>>> Also if you are logging an object, make sure you are overriding
>>>> toString() method of the class. Otherwise the log is nothing but a garbage.
>>>> Just got this log on master branch.
>>>>
>>>> *Rule executed for:
>>>> org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext@42c0a4d8*
>>>>
>>>> ClusterLevelPartitionContext class doesn't override toString()  method.
>>>>
>>>> Thanks.
>>>>
>>>> On Mon, Feb 23, 2015 at 7:27 AM, Lahiru Sandaruwan <la...@wso2.com>
>>>> wrote:
>>>>
>>>>> Hi all,
>>>>>
>>>>> There are lot of different approaches of logging in Stratos code. May
>>>>> be we can follow same format so that code looks clean and understandable.
>>>>> This is to decide which way we should follow.
>>>>>
>>>>> *1. Separation of objects*
>>>>>
>>>>> We are using square brackets in most of the places. I think that is a
>>>>> good approach. May be we can use a comma after one object. We need to
>>>>> decide.
>>>>>
>>>>> E.g. 1
>>>>>
>>>>> [network-partition] network-partition-1 [cluster-instance]
>>>>> single-cartridge-app-1 [cluster] php1.php.domain
>>>>>
>>>>> E.g. 2
>>>>>
>>>>> [network-partition] network-partition-1, [cluster-instance]
>>>>> single-cartridge-app-1, [cluster] php1.php.domain
>>>>>
>>>>> *2. Using same text for identifying a particular type*
>>>>> E.g. We use [network-parition], [NW partition], [network partition] in
>>>>> different places. We could stick to one.
>>>>>
>>>>> *3. Using the String.format or concatenation. *
>>>>>
>>>>> String.format brings clarity and readability while it reduces the
>>>>> performance against concatenation. We need to decide what should be our
>>>>> choice. I would vote for String.format considering performance gain is
>>>>> negligible if we only have info level logs.
>>>>>
>>>>> *4. Use isDebugEnabled() and don't use isInfoEnabled()*
>>>>>
>>>>> Regarding this, we must use *isDebugEnabled* everywhere we do debug
>>>>> logging. But i think we can skip *isInfoEnabled *assuming we will
>>>>> have info logs in limited numbers. Wdyt?
>>>>>
>>>>> We can add a guidance at [2] for developers regarding all the matters
>>>>> here, after deciding.
>>>>>
>>>>> Thanks.
>>>>>
>>>>> [1]
>>>>> http://stackoverflow.com/questions/925423/is-it-better-practice-to-use-string-format-over-string-concatenation-in-java
>>>>> [2]
>>>>> https://cwiki.apache.org/confluence/display/STRATOS/Developer+Guide
>>>>> --
>>>>> --
>>>>> Lahiru Sandaruwan
>>>>> Committer and PMC member, Apache Stratos,
>>>>> Senior Software Engineer,
>>>>> WSO2 Inc., http://wso2.com
>>>>> lean.enterprise.middleware
>>>>>
>>>>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>>>>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Rajkumar Rajaratnam
>>>> Committer & PMC Member, Apache Stratos
>>>> Software Engineer, WSO2
>>>>
>>>> Mobile : +94777568639
>>>> Blog : rajkumarr.com
>>>>
>>>> --
>>>> <http://rajkumarr.com>
>>>> <http://rajkumarr.com>
>>>> Isuru Perera
>>>> Senior Software Engineer | WSO2, Inc. | <http://rajkumarr.com>
>>>> http://wso2.com/
>>>> Lean . Enterprise . Middleware
>>>>
>>>> about.me/chrishantha
>>>>
>>>
>>
>>
>> --
>> --
>> Lahiru Sandaruwan
>> Committer and PMC member, Apache Stratos,
>> Senior Software Engineer,
>> WSO2 Inc., http://wso2.com
>> lean.enterprise.middleware
>>
>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>
>>
>


-- 
--
Lahiru Sandaruwan
Committer and PMC member, Apache Stratos,
Senior Software Engineer,
WSO2 Inc., http://wso2.com
lean.enterprise.middleware

email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146

Re: Stick to one practice while logging

Posted by Chamila De Alwis <ch...@wso2.com>.
Hi,

+1 for all these changes. This might be crucial in the usability aspect of
the product.  Another irregularity I've seen is the generic nature of a log
entry. If a debug/info entry is there indicating a certain operation is to
be done, it should indicate that the operation is *about* to be done, not
being done or done. If, say, "Git checkout" is the log entry  before
actually making that decision, it can be ambiguous.




Regards,
Chamila de Alwis
Software Engineer | WSO2 | +94772207163
Blog: code.chamiladealwis.com



On Mon, Feb 23, 2015 at 11:37 AM, Lahiru Sandaruwan <la...@wso2.com>
wrote:

>
>
> On Mon, Feb 23, 2015 at 11:32 AM, Isuru Perera <is...@apache.org> wrote:
>
>> Hi,
>>
>> I agree with every point except for skipping isInfoEnabled(). I believe
>> we must use these guard conditions. Some might decide to run Stratos with
>> only Error/Warn level logs. We might avoid guard conditions for error/fatal
>> level logs.
>>
>
> Agree. Let's enable that flexibility as well. So if we use that, we should
> use them all occasions we log info.
>
> Mari,
>
> Shall we go ahead and create a page?
>
> Thanks.
>
>>
>> And use String.format. Always avoid concatenation. String.format is much
>> better than concatenation and it helps string pooling as well.
>>
>> Thanks!
>>
>> On Mon, Feb 23, 2015 at 11:22 AM, Rajkumar Rajaratnam <rajkumarr@wso2.com
>> > wrote:
>>
>>> +1 Lahiru.
>>>
>>> Also if you are logging an object, make sure you are overriding
>>> toString() method of the class. Otherwise the log is nothing but a garbage.
>>> Just got this log on master branch.
>>>
>>> *Rule executed for:
>>> org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext@42c0a4d8*
>>>
>>> ClusterLevelPartitionContext class doesn't override toString()  method.
>>>
>>> Thanks.
>>>
>>> On Mon, Feb 23, 2015 at 7:27 AM, Lahiru Sandaruwan <la...@wso2.com>
>>> wrote:
>>>
>>>> Hi all,
>>>>
>>>> There are lot of different approaches of logging in Stratos code. May
>>>> be we can follow same format so that code looks clean and understandable.
>>>> This is to decide which way we should follow.
>>>>
>>>> *1. Separation of objects*
>>>>
>>>> We are using square brackets in most of the places. I think that is a
>>>> good approach. May be we can use a comma after one object. We need to
>>>> decide.
>>>>
>>>> E.g. 1
>>>>
>>>> [network-partition] network-partition-1 [cluster-instance]
>>>> single-cartridge-app-1 [cluster] php1.php.domain
>>>>
>>>> E.g. 2
>>>>
>>>> [network-partition] network-partition-1, [cluster-instance]
>>>> single-cartridge-app-1, [cluster] php1.php.domain
>>>>
>>>> *2. Using same text for identifying a particular type*
>>>> E.g. We use [network-parition], [NW partition], [network partition] in
>>>> different places. We could stick to one.
>>>>
>>>> *3. Using the String.format or concatenation. *
>>>>
>>>> String.format brings clarity and readability while it reduces the
>>>> performance against concatenation. We need to decide what should be our
>>>> choice. I would vote for String.format considering performance gain is
>>>> negligible if we only have info level logs.
>>>>
>>>> *4. Use isDebugEnabled() and don't use isInfoEnabled()*
>>>>
>>>> Regarding this, we must use *isDebugEnabled* everywhere we do debug
>>>> logging. But i think we can skip *isInfoEnabled *assuming we will have
>>>> info logs in limited numbers. Wdyt?
>>>>
>>>> We can add a guidance at [2] for developers regarding all the matters
>>>> here, after deciding.
>>>>
>>>> Thanks.
>>>>
>>>> [1]
>>>> http://stackoverflow.com/questions/925423/is-it-better-practice-to-use-string-format-over-string-concatenation-in-java
>>>> [2] https://cwiki.apache.org/confluence/display/STRATOS/Developer+Guide
>>>> --
>>>> --
>>>> Lahiru Sandaruwan
>>>> Committer and PMC member, Apache Stratos,
>>>> Senior Software Engineer,
>>>> WSO2 Inc., http://wso2.com
>>>> lean.enterprise.middleware
>>>>
>>>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>>>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>>>
>>>>
>>>
>>>
>>> --
>>> Rajkumar Rajaratnam
>>> Committer & PMC Member, Apache Stratos
>>> Software Engineer, WSO2
>>>
>>> Mobile : +94777568639
>>> Blog : rajkumarr.com
>>>
>>> --
>>> <http://rajkumarr.com>
>>> <http://rajkumarr.com>
>>> Isuru Perera
>>> Senior Software Engineer | WSO2, Inc. | <http://rajkumarr.com>
>>> http://wso2.com/
>>> Lean . Enterprise . Middleware
>>>
>>> about.me/chrishantha
>>>
>>
>
>
> --
> --
> Lahiru Sandaruwan
> Committer and PMC member, Apache Stratos,
> Senior Software Engineer,
> WSO2 Inc., http://wso2.com
> lean.enterprise.middleware
>
> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>
>

Re: Stick to one practice while logging

Posted by Lahiru Sandaruwan <la...@wso2.com>.
On Mon, Feb 23, 2015 at 11:32 AM, Isuru Perera <is...@apache.org> wrote:

> Hi,
>
> I agree with every point except for skipping isInfoEnabled(). I believe we
> must use these guard conditions. Some might decide to run Stratos with only
> Error/Warn level logs. We might avoid guard conditions for error/fatal
> level logs.
>

Agree. Let's enable that flexibility as well. So if we use that, we should
use them all occasions we log info.

Mari,

Shall we go ahead and create a page?

Thanks.

>
> And use String.format. Always avoid concatenation. String.format is much
> better than concatenation and it helps string pooling as well.
>
> Thanks!
>
> On Mon, Feb 23, 2015 at 11:22 AM, Rajkumar Rajaratnam <ra...@wso2.com>
> wrote:
>
>> +1 Lahiru.
>>
>> Also if you are logging an object, make sure you are overriding
>> toString() method of the class. Otherwise the log is nothing but a garbage.
>> Just got this log on master branch.
>>
>> *Rule executed for:
>> org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext@42c0a4d8*
>>
>> ClusterLevelPartitionContext class doesn't override toString()  method.
>>
>> Thanks.
>>
>> On Mon, Feb 23, 2015 at 7:27 AM, Lahiru Sandaruwan <la...@wso2.com>
>> wrote:
>>
>>> Hi all,
>>>
>>> There are lot of different approaches of logging in Stratos code. May be
>>> we can follow same format so that code looks clean and understandable. This
>>> is to decide which way we should follow.
>>>
>>> *1. Separation of objects*
>>>
>>> We are using square brackets in most of the places. I think that is a
>>> good approach. May be we can use a comma after one object. We need to
>>> decide.
>>>
>>> E.g. 1
>>>
>>> [network-partition] network-partition-1 [cluster-instance]
>>> single-cartridge-app-1 [cluster] php1.php.domain
>>>
>>> E.g. 2
>>>
>>> [network-partition] network-partition-1, [cluster-instance]
>>> single-cartridge-app-1, [cluster] php1.php.domain
>>>
>>> *2. Using same text for identifying a particular type*
>>> E.g. We use [network-parition], [NW partition], [network partition] in
>>> different places. We could stick to one.
>>>
>>> *3. Using the String.format or concatenation. *
>>>
>>> String.format brings clarity and readability while it reduces the
>>> performance against concatenation. We need to decide what should be our
>>> choice. I would vote for String.format considering performance gain is
>>> negligible if we only have info level logs.
>>>
>>> *4. Use isDebugEnabled() and don't use isInfoEnabled()*
>>>
>>> Regarding this, we must use *isDebugEnabled* everywhere we do debug
>>> logging. But i think we can skip *isInfoEnabled *assuming we will have
>>> info logs in limited numbers. Wdyt?
>>>
>>> We can add a guidance at [2] for developers regarding all the matters
>>> here, after deciding.
>>>
>>> Thanks.
>>>
>>> [1]
>>> http://stackoverflow.com/questions/925423/is-it-better-practice-to-use-string-format-over-string-concatenation-in-java
>>> [2] https://cwiki.apache.org/confluence/display/STRATOS/Developer+Guide
>>> --
>>> --
>>> Lahiru Sandaruwan
>>> Committer and PMC member, Apache Stratos,
>>> Senior Software Engineer,
>>> WSO2 Inc., http://wso2.com
>>> lean.enterprise.middleware
>>>
>>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>>
>>>
>>
>>
>> --
>> Rajkumar Rajaratnam
>> Committer & PMC Member, Apache Stratos
>> Software Engineer, WSO2
>>
>> Mobile : +94777568639
>> Blog : rajkumarr.com
>>
>> --
>> <http://rajkumarr.com>
>> <http://rajkumarr.com>
>> Isuru Perera
>> Senior Software Engineer | WSO2, Inc. | <http://rajkumarr.com>
>> http://wso2.com/
>> Lean . Enterprise . Middleware
>>
>> about.me/chrishantha
>>
>


-- 
--
Lahiru Sandaruwan
Committer and PMC member, Apache Stratos,
Senior Software Engineer,
WSO2 Inc., http://wso2.com
lean.enterprise.middleware

email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146

Re: Stick to one practice while logging

Posted by Isuru Perera <is...@apache.org>.
Hi,

I agree with every point except for skipping isInfoEnabled(). I believe we
must use these guard conditions. Some might decide to run Stratos with only
Error/Warn level logs. We might avoid guard conditions for error/fatal
level logs.

And use String.format. Always avoid concatenation. String.format is much
better than concatenation and it helps string pooling as well.

Thanks!

On Mon, Feb 23, 2015 at 11:22 AM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

> +1 Lahiru.
>
> Also if you are logging an object, make sure you are overriding toString()
> method of the class. Otherwise the log is nothing but a garbage. Just got
> this log on master branch.
>
> *Rule executed for:
> org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext@42c0a4d8*
>
> ClusterLevelPartitionContext class doesn't override toString()  method.
>
> Thanks.
>
> On Mon, Feb 23, 2015 at 7:27 AM, Lahiru Sandaruwan <la...@wso2.com>
> wrote:
>
>> Hi all,
>>
>> There are lot of different approaches of logging in Stratos code. May be
>> we can follow same format so that code looks clean and understandable. This
>> is to decide which way we should follow.
>>
>> *1. Separation of objects*
>>
>> We are using square brackets in most of the places. I think that is a
>> good approach. May be we can use a comma after one object. We need to
>> decide.
>>
>> E.g. 1
>>
>> [network-partition] network-partition-1 [cluster-instance]
>> single-cartridge-app-1 [cluster] php1.php.domain
>>
>> E.g. 2
>>
>> [network-partition] network-partition-1, [cluster-instance]
>> single-cartridge-app-1, [cluster] php1.php.domain
>>
>> *2. Using same text for identifying a particular type*
>> E.g. We use [network-parition], [NW partition], [network partition] in
>> different places. We could stick to one.
>>
>> *3. Using the String.format or concatenation. *
>>
>> String.format brings clarity and readability while it reduces the
>> performance against concatenation. We need to decide what should be our
>> choice. I would vote for String.format considering performance gain is
>> negligible if we only have info level logs.
>>
>> *4. Use isDebugEnabled() and don't use isInfoEnabled()*
>>
>> Regarding this, we must use *isDebugEnabled* everywhere we do debug
>> logging. But i think we can skip *isInfoEnabled *assuming we will have
>> info logs in limited numbers. Wdyt?
>>
>> We can add a guidance at [2] for developers regarding all the matters
>> here, after deciding.
>>
>> Thanks.
>>
>> [1]
>> http://stackoverflow.com/questions/925423/is-it-better-practice-to-use-string-format-over-string-concatenation-in-java
>> [2] https://cwiki.apache.org/confluence/display/STRATOS/Developer+Guide
>> --
>> --
>> Lahiru Sandaruwan
>> Committer and PMC member, Apache Stratos,
>> Senior Software Engineer,
>> WSO2 Inc., http://wso2.com
>> lean.enterprise.middleware
>>
>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>
>>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>
> Mobile : +94777568639
> Blog : rajkumarr.com
>
> --
> Isuru Perera
> Senior Software Engineer | WSO2, Inc. | http://wso2.com/
> Lean . Enterprise . Middleware
>
> about.me/chrishantha
>  <http://rajkumarr.com>
>

Re: Stick to one practice while logging

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
+1 Lahiru.

Also if you are logging an object, make sure you are overriding toString()
method of the class. Otherwise the log is nothing but a garbage. Just got
this log on master branch.

*Rule executed for:
org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext@42c0a4d8*

ClusterLevelPartitionContext class doesn't override toString()  method.

Thanks.

On Mon, Feb 23, 2015 at 7:27 AM, Lahiru Sandaruwan <la...@wso2.com> wrote:

> Hi all,
>
> There are lot of different approaches of logging in Stratos code. May be
> we can follow same format so that code looks clean and understandable. This
> is to decide which way we should follow.
>
> *1. Separation of objects*
>
> We are using square brackets in most of the places. I think that is a good
> approach. May be we can use a comma after one object. We need to decide.
>
> E.g. 1
>
> [network-partition] network-partition-1 [cluster-instance]
> single-cartridge-app-1 [cluster] php1.php.domain
>
> E.g. 2
>
> [network-partition] network-partition-1, [cluster-instance]
> single-cartridge-app-1, [cluster] php1.php.domain
>
> *2. Using same text for identifying a particular type*
> E.g. We use [network-parition], [NW partition], [network partition] in
> different places. We could stick to one.
>
> *3. Using the String.format or concatenation. *
>
> String.format brings clarity and readability while it reduces the
> performance against concatenation. We need to decide what should be our
> choice. I would vote for String.format considering performance gain is
> negligible if we only have info level logs.
>
> *4. Use isDebugEnabled() and don't use isInfoEnabled()*
>
> Regarding this, we must use *isDebugEnabled* everywhere we do debug
> logging. But i think we can skip *isInfoEnabled *assuming we will have
> info logs in limited numbers. Wdyt?
>
> We can add a guidance at [2] for developers regarding all the matters
> here, after deciding.
>
> Thanks.
>
> [1]
> http://stackoverflow.com/questions/925423/is-it-better-practice-to-use-string-format-over-string-concatenation-in-java
> [2] https://cwiki.apache.org/confluence/display/STRATOS/Developer+Guide
> --
> --
> Lahiru Sandaruwan
> Committer and PMC member, Apache Stratos,
> Senior Software Engineer,
> WSO2 Inc., http://wso2.com
> lean.enterprise.middleware
>
> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>
>


-- 
Rajkumar Rajaratnam
Committer & PMC Member, Apache Stratos
Software Engineer, WSO2

Mobile : +94777568639
Blog : rajkumarr.com

Re: Stick to one practice while logging

Posted by Imesh Gunaratne <im...@apache.org>.
+1

On Mon, Feb 23, 2015 at 7:27 AM, Lahiru Sandaruwan <la...@wso2.com> wrote:

> Hi all,
>
> There are lot of different approaches of logging in Stratos code. May be
> we can follow same format so that code looks clean and understandable. This
> is to decide which way we should follow.
>
> *1. Separation of objects*
>
> We are using square brackets in most of the places. I think that is a good
> approach. May be we can use a comma after one object. We need to decide.
>
> E.g. 1
>
> [network-partition] network-partition-1 [cluster-instance]
> single-cartridge-app-1 [cluster] php1.php.domain
>
I prefer this, we have used this in most of the logs

> E.g. 2
>
> [network-partition] network-partition-1, [cluster-instance]
> single-cartridge-app-1, [cluster] php1.php.domain
>
IMO square bracket itself becomes a separator

> *2. Using same text for identifying a particular type*
> E.g. We use [network-parition], [NW partition], [network partition] in
> different places. We could stick to one.
>
> I prefer [network-partition], we have used this in most of the logs


> *3. Using the String.format or concatenation. *
>
> String.format brings clarity and readability while it reduces the
> performance against concatenation. We need to decide what should be our
> choice. I would vote for String.format considering performance gain is
> negligible if we only have info level logs.
>
> +1 Yes this is the reason for using String.format()


> *4. Use isDebugEnabled() and don't use isInfoEnabled()*
>
> Regarding this, we must use *isDebugEnabled* everywhere we do debug
> logging. But i think we can skip *isInfoEnabled *assuming we will have
> info logs in limited numbers. Wdyt?
>
>
> Agree with Isuru on this.

Thanks


-- 
Imesh Gunaratne

Technical Lead, WSO2
Committer & PMC Member, Apache Stratos