You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Bruce Brouwer <br...@gmail.com> on 2014/03/04 14:26:30 UTC

Extending loggers

There are a number of JIRAs out there that have issues related to making
sure we get the correct caller location logged. I'm attaching a patch which
is in no way complete but demonstrates an idea that might make it easier to
extend loggers. For example, this makes the slf4j-impl quite a bit simpler.
It also impacts the jcl code, which I don't think was working to record the
caller location.

The idea is to create a LoggerExtension from the original logger which
simply remembers the FQCN that will ultimately be the extension. Also by
doing this, we can switch a bunch of methods that ended up being public
back to protected. I'm guessing they became public so extensions could call
them.

I also like how extensions (such as slf4j, jcl, custom extensions, logger
streams) don't have to pass in the FQCN to that special log method anymore.
Also, you don't have to wrap every extended log method with a check to see
if the logging is enabled. Finally, you don't need to have any access to
the MessageFactory.

This is very much a work in progress, but please take a look (but don't
commit it as is) and give me your thoughts. I think it could help with some
of the issues we've been seeing. But if it is too much

-- 

Bruce Brouwer

Re: Extending loggers

Posted by Matt Sicker <bo...@gmail.com>.
What I like to do is check out the Git mirror (see git.apache.org), do my
work in Git locally, then use `git format-patch trunk` to generate a p1
patch file (which means you apply it using `patch -p1
<0001-Some-patch.patch` in the command line, or use "ignore leading
directory" or similar setting when using an IDE).

If you do that, you could even use GitHub (or BitBucket, whatever really)
to publicly host it if you've got a large branch going.


On 4 March 2014 09:03, Gary Gregory <ga...@gmail.com> wrote:

> Ah, sorry, I did not realize you did not have commit rights. A diff file
> in JIRA is the way to go then.
>
> Gary
>
>
> On Tue, Mar 4, 2014 at 10:00 AM, Bruce Brouwer <br...@gmail.com>wrote:
>
>> Without me having the ability to commit code, I would have to work with a
>> comitter to apply psyched to this new branch. Can I be granted commit
>> privileges only to this branch? That way I cannot mess up the trunk.
>>  On Mar 4, 2014 9:18 AM, "Matt Sicker" <bo...@gmail.com> wrote:
>>
>>> I could create one for this if you like. Any particular name you want?
>>> Or is "feature/caller-info" good?
>>>
>>> Matt Sicker
>>>
>>> On Mar 4, 2014, at 8:13, Bruce Brouwer <br...@gmail.com> wrote:
>>>
>>> I can create a JIRA. I don't think I have rights to create a branch, do
>>> I?
>>> On Mar 4, 2014 8:48 AM, "Gary Gregory" <ga...@gmail.com> wrote:
>>>
>>>> Hi Bruce,
>>>>
>>>> Can you create a JIRA and attach your code there? I think it will make
>>>> it easier to track. Or better yet, create a branch if you think the
>>>> experiment will be long lived enough.
>>>>
>>>> Gary
>>>>
>>>>
>>>> On Tue, Mar 4, 2014 at 8:26 AM, Bruce Brouwer <br...@gmail.com>wrote:
>>>>
>>>>> There are a number of JIRAs out there that have issues related to
>>>>> making sure we get the correct caller location logged. I'm attaching a
>>>>> patch which is in no way complete but demonstrates an idea that might make
>>>>> it easier to extend loggers. For example, this makes the slf4j-impl quite a
>>>>> bit simpler. It also impacts the jcl code, which I don't think was working
>>>>> to record the caller location.
>>>>>
>>>>> The idea is to create a LoggerExtension from the original logger which
>>>>> simply remembers the FQCN that will ultimately be the extension. Also by
>>>>> doing this, we can switch a bunch of methods that ended up being public
>>>>> back to protected. I'm guessing they became public so extensions could call
>>>>> them.
>>>>>
>>>>> I also like how extensions (such as slf4j, jcl, custom extensions,
>>>>> logger streams) don't have to pass in the FQCN to that special log method
>>>>> anymore. Also, you don't have to wrap every extended log method with a
>>>>> check to see if the logging is enabled. Finally, you don't need to have any
>>>>> access to the MessageFactory.
>>>>>
>>>>> This is very much a work in progress, but please take a look (but
>>>>> don't commit it as is) and give me your thoughts. I think it could help
>>>>> with some of the issues we've been seeing. But if it is too much
>>>>>
>>>>> --
>>>>>
>>>>> Bruce Brouwer
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>>>>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>> Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>> Blog: http://garygregory.wordpress.com
>>>> Home: http://garygregory.com/
>>>> Tweet! http://twitter.com/GaryGregory
>>>>
>>>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
Matt Sicker <bo...@gmail.com>

Re: Extending loggers

Posted by Gary Gregory <ga...@gmail.com>.
Ah, sorry, I did not realize you did not have commit rights. A diff file in
JIRA is the way to go then.

Gary


On Tue, Mar 4, 2014 at 10:00 AM, Bruce Brouwer <br...@gmail.com>wrote:

> Without me having the ability to commit code, I would have to work with a
> comitter to apply psyched to this new branch. Can I be granted commit
> privileges only to this branch? That way I cannot mess up the trunk.
> On Mar 4, 2014 9:18 AM, "Matt Sicker" <bo...@gmail.com> wrote:
>
>> I could create one for this if you like. Any particular name you want? Or
>> is "feature/caller-info" good?
>>
>> Matt Sicker
>>
>> On Mar 4, 2014, at 8:13, Bruce Brouwer <br...@gmail.com> wrote:
>>
>> I can create a JIRA. I don't think I have rights to create a branch, do I?
>> On Mar 4, 2014 8:48 AM, "Gary Gregory" <ga...@gmail.com> wrote:
>>
>>> Hi Bruce,
>>>
>>> Can you create a JIRA and attach your code there? I think it will make
>>> it easier to track. Or better yet, create a branch if you think the
>>> experiment will be long lived enough.
>>>
>>> Gary
>>>
>>>
>>> On Tue, Mar 4, 2014 at 8:26 AM, Bruce Brouwer <br...@gmail.com>wrote:
>>>
>>>> There are a number of JIRAs out there that have issues related to
>>>> making sure we get the correct caller location logged. I'm attaching a
>>>> patch which is in no way complete but demonstrates an idea that might make
>>>> it easier to extend loggers. For example, this makes the slf4j-impl quite a
>>>> bit simpler. It also impacts the jcl code, which I don't think was working
>>>> to record the caller location.
>>>>
>>>> The idea is to create a LoggerExtension from the original logger which
>>>> simply remembers the FQCN that will ultimately be the extension. Also by
>>>> doing this, we can switch a bunch of methods that ended up being public
>>>> back to protected. I'm guessing they became public so extensions could call
>>>> them.
>>>>
>>>> I also like how extensions (such as slf4j, jcl, custom extensions,
>>>> logger streams) don't have to pass in the FQCN to that special log method
>>>> anymore. Also, you don't have to wrap every extended log method with a
>>>> check to see if the logging is enabled. Finally, you don't need to have any
>>>> access to the MessageFactory.
>>>>
>>>> This is very much a work in progress, but please take a look (but don't
>>>> commit it as is) and give me your thoughts. I think it could help with some
>>>> of the issues we've been seeing. But if it is too much
>>>>
>>>> --
>>>>
>>>> Bruce Brouwer
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>>>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>>>>
>>>
>>>
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>> Spring Batch in Action <http://www.manning.com/templier/>
>>> Blog: http://garygregory.wordpress.com
>>> Home: http://garygregory.com/
>>> Tweet! http://twitter.com/GaryGregory
>>>
>>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Extending loggers

Posted by Bruce Brouwer <br...@gmail.com>.
Without me having the ability to commit code, I would have to work with a
comitter to apply psyched to this new branch. Can I be granted commit
privileges only to this branch? That way I cannot mess up the trunk.
On Mar 4, 2014 9:18 AM, "Matt Sicker" <bo...@gmail.com> wrote:

> I could create one for this if you like. Any particular name you want? Or
> is "feature/caller-info" good?
>
> Matt Sicker
>
> On Mar 4, 2014, at 8:13, Bruce Brouwer <br...@gmail.com> wrote:
>
> I can create a JIRA. I don't think I have rights to create a branch, do I?
> On Mar 4, 2014 8:48 AM, "Gary Gregory" <ga...@gmail.com> wrote:
>
>> Hi Bruce,
>>
>> Can you create a JIRA and attach your code there? I think it will make it
>> easier to track. Or better yet, create a branch if you think the experiment
>> will be long lived enough.
>>
>> Gary
>>
>>
>> On Tue, Mar 4, 2014 at 8:26 AM, Bruce Brouwer <br...@gmail.com>wrote:
>>
>>> There are a number of JIRAs out there that have issues related to making
>>> sure we get the correct caller location logged. I'm attaching a patch which
>>> is in no way complete but demonstrates an idea that might make it easier to
>>> extend loggers. For example, this makes the slf4j-impl quite a bit simpler.
>>> It also impacts the jcl code, which I don't think was working to record the
>>> caller location.
>>>
>>> The idea is to create a LoggerExtension from the original logger which
>>> simply remembers the FQCN that will ultimately be the extension. Also by
>>> doing this, we can switch a bunch of methods that ended up being public
>>> back to protected. I'm guessing they became public so extensions could call
>>> them.
>>>
>>> I also like how extensions (such as slf4j, jcl, custom extensions,
>>> logger streams) don't have to pass in the FQCN to that special log method
>>> anymore. Also, you don't have to wrap every extended log method with a
>>> check to see if the logging is enabled. Finally, you don't need to have any
>>> access to the MessageFactory.
>>>
>>> This is very much a work in progress, but please take a look (but don't
>>> commit it as is) and give me your thoughts. I think it could help with some
>>> of the issues we've been seeing. But if it is too much
>>>
>>> --
>>>
>>> Bruce Brouwer
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>>>
>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>

Re: Extending loggers

Posted by Matt Sicker <bo...@gmail.com>.
I could create one for this if you like. Any particular name you want? Or is "feature/caller-info" good?

Matt Sicker

> On Mar 4, 2014, at 8:13, Bruce Brouwer <br...@gmail.com> wrote:
> 
> I can create a JIRA. I don't think I have rights to create a branch, do I?
> 
>> On Mar 4, 2014 8:48 AM, "Gary Gregory" <ga...@gmail.com> wrote:
>> Hi Bruce,
>> 
>> Can you create a JIRA and attach your code there? I think it will make it easier to track. Or better yet, create a branch if you think the experiment will be long lived enough.
>> 
>> Gary
>> 
>> 
>>> On Tue, Mar 4, 2014 at 8:26 AM, Bruce Brouwer <br...@gmail.com> wrote:
>>> There are a number of JIRAs out there that have issues related to making sure we get the correct caller location logged. I'm attaching a patch which is in no way complete but demonstrates an idea that might make it easier to extend loggers. For example, this makes the slf4j-impl quite a bit simpler. It also impacts the jcl code, which I don't think was working to record the caller location. 
>>> 
>>> The idea is to create a LoggerExtension from the original logger which simply remembers the FQCN that will ultimately be the extension. Also by doing this, we can switch a bunch of methods that ended up being public back to protected. I'm guessing they became public so extensions could call them. 
>>> 
>>> I also like how extensions (such as slf4j, jcl, custom extensions, logger streams) don't have to pass in the FQCN to that special log method anymore. Also, you don't have to wrap every extended log method with a check to see if the logging is enabled. Finally, you don't need to have any access to the MessageFactory. 
>>> 
>>> This is very much a work in progress, but please take a look (but don't commit it as is) and give me your thoughts. I think it could help with some of the issues we've been seeing. But if it is too much 
>>> 
>>> -- 
>>> 
>>> Bruce Brouwer
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>> 
>> 
>> 
>> -- 
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>> Java Persistence with Hibernate, Second Edition
>> JUnit in Action, Second Edition
>> Spring Batch in Action
>> Blog: http://garygregory.wordpress.com 
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory

Re: Extending loggers

Posted by Bruce Brouwer <br...@gmail.com>.
I can create a JIRA. I don't think I have rights to create a branch, do I?
On Mar 4, 2014 8:48 AM, "Gary Gregory" <ga...@gmail.com> wrote:

> Hi Bruce,
>
> Can you create a JIRA and attach your code there? I think it will make it
> easier to track. Or better yet, create a branch if you think the experiment
> will be long lived enough.
>
> Gary
>
>
> On Tue, Mar 4, 2014 at 8:26 AM, Bruce Brouwer <br...@gmail.com>wrote:
>
>> There are a number of JIRAs out there that have issues related to making
>> sure we get the correct caller location logged. I'm attaching a patch which
>> is in no way complete but demonstrates an idea that might make it easier to
>> extend loggers. For example, this makes the slf4j-impl quite a bit simpler.
>> It also impacts the jcl code, which I don't think was working to record the
>> caller location.
>>
>> The idea is to create a LoggerExtension from the original logger which
>> simply remembers the FQCN that will ultimately be the extension. Also by
>> doing this, we can switch a bunch of methods that ended up being public
>> back to protected. I'm guessing they became public so extensions could call
>> them.
>>
>> I also like how extensions (such as slf4j, jcl, custom extensions, logger
>> streams) don't have to pass in the FQCN to that special log method anymore.
>> Also, you don't have to wrap every extended log method with a check to see
>> if the logging is enabled. Finally, you don't need to have any access to
>> the MessageFactory.
>>
>> This is very much a work in progress, but please take a look (but don't
>> commit it as is) and give me your thoughts. I think it could help with some
>> of the issues we've been seeing. But if it is too much
>>
>> --
>>
>> Bruce Brouwer
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>

Re: Extending loggers

Posted by Gary Gregory <ga...@gmail.com>.
Hi Bruce,

Can you create a JIRA and attach your code there? I think it will make it
easier to track. Or better yet, create a branch if you think the experiment
will be long lived enough.

Gary


On Tue, Mar 4, 2014 at 8:26 AM, Bruce Brouwer <br...@gmail.com>wrote:

> There are a number of JIRAs out there that have issues related to making
> sure we get the correct caller location logged. I'm attaching a patch which
> is in no way complete but demonstrates an idea that might make it easier to
> extend loggers. For example, this makes the slf4j-impl quite a bit simpler.
> It also impacts the jcl code, which I don't think was working to record the
> caller location.
>
> The idea is to create a LoggerExtension from the original logger which
> simply remembers the FQCN that will ultimately be the extension. Also by
> doing this, we can switch a bunch of methods that ended up being public
> back to protected. I'm guessing they became public so extensions could call
> them.
>
> I also like how extensions (such as slf4j, jcl, custom extensions, logger
> streams) don't have to pass in the FQCN to that special log method anymore.
> Also, you don't have to wrap every extended log method with a check to see
> if the logging is enabled. Finally, you don't need to have any access to
> the MessageFactory.
>
> This is very much a work in progress, but please take a look (but don't
> commit it as is) and give me your thoughts. I think it could help with some
> of the issues we've been seeing. But if it is too much
>
> --
>
> Bruce Brouwer
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory