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 Paul Smith <ps...@aconex.com> on 2007/04/20 05:57:40 UTC

Chainsaw+log4j12 == LocationInfo oddness

I'm getting a weird NPE here:

Daemon Thread [Chainsaw-WorkerThread] (Suspended (breakpoint at line  
539 in PatternParser$ClassNamePatternConverter))	
	PatternParser$ClassNamePatternConverter.getFullyQualifiedName 
(LoggingEvent) line: 539	
	PatternParser$ClassNamePatternConverter(PatternParser 
$NamedPatternConverter).convert(LoggingEvent) line: 512	
	PatternParser$ClassNamePatternConverter(PatternConverter).format 
(StringBuffer, LoggingEvent) line: 65	
	PatternLayout.format(LoggingEvent) line: 504	
	EventDetailLayout.format(LoggingEvent) line: 280	
	LogPanel$DetailPaneUpdater.updateDetailPane() line: 2552	
	LogPanel$DetailPaneUpdater.setSelectedRow(int) line: 2531	
	LogPanel$DetailPaneUpdater.access$1(LogPanel$DetailPaneUpdater, int)  
line: 2529	
	LogPanel.receiveEventBatch(String, List) line: 1398	
	ChainsawAppenderHandler$WorkQueue$WorkerThread.dispatchEventBatch 
(ChainsawEventBatch) line: 343	
	ChainsawAppenderHandler$WorkQueue$WorkerThread.run() line: 299	

This is because the fqnOfCategoryClass variable is null, as is the  
LocationInfo.  This obviously never happened with 1.3.  I wonder if  
the 'fake' appender that dispatches events to the GUI is required to  
handle something slightly different.

Anyway, I'm looking at this, just thought I'd let people know where I  
was progress wise.

Also on a maven front, I've finally started getting log4j12 branch  
working with maven.  I basically copied the dependency list from the  
trunk pom.xml, and fought with the maven repos to get all the sun  
jars downloaded into my local repo.  Curse Sun and their jar  
licensing.  Why can't it 'just work'.   If all the sun jars were in  
maven repos, then I think Maven would look extra schmick.  Together  
with the maven-eclipse plugin, I'm seriously thinking that mavenizing  
Chainsaw isn't a bad idea.

Paul

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Re: Chainsaw+log4j12 == LocationInfo oddness

Posted by Curt Arnold <ca...@apache.org>.
On Apr 20, 2007, at 8:40 PM, Paul Smith wrote:
> So, just a subtle change required in the if block in 1.2 code.   
> This change was done by Ceki in 1.3 trunk via revision 310506:
>
> http://svn.apache.org/viewvc?view=rev&revision=310506
>
> I think we should port this change as well.  Any objections?
>
> Paul
>

No objections.

It is the same underlying bug that I ran into in bug 41186.  But  
since I did not want to touch established log4j 1.2 to fix behavior  
in new async appender, I passed a bogus string literal as a class  
name.  However, it sure seems like doing it in LoggingEvent is a  
better place.  I'm make the change referencing bug 41186 and revert  
my previous change.






Re: Chainsaw+log4j12 == LocationInfo oddness

Posted by Paul Smith <ps...@aconex.com>.
On 20/04/2007, at 1:57 PM, Paul Smith wrote:

> I'm getting a weird NPE here:
>
> Daemon Thread [Chainsaw-WorkerThread] (Suspended (breakpoint at  
> line 539 in PatternParser$ClassNamePatternConverter))	
> 	PatternParser$ClassNamePatternConverter.getFullyQualifiedName 
> (LoggingEvent) line: 539	
> 	PatternParser$ClassNamePatternConverter(PatternParser 
> $NamedPatternConverter).convert(LoggingEvent) line: 512	
> 	PatternParser$ClassNamePatternConverter(PatternConverter).format 
> (StringBuffer, LoggingEvent) line: 65	
> 	PatternLayout.format(LoggingEvent) line: 504	
> 	EventDetailLayout.format(LoggingEvent) line: 280	
> 	LogPanel$DetailPaneUpdater.updateDetailPane() line: 2552	
> 	LogPanel$DetailPaneUpdater.setSelectedRow(int) line: 2531	
> 	LogPanel$DetailPaneUpdater.access$1(LogPanel$DetailPaneUpdater,  
> int) line: 2529	
> 	LogPanel.receiveEventBatch(String, List) line: 1398	
> 	ChainsawAppenderHandler$WorkQueue$WorkerThread.dispatchEventBatch 
> (ChainsawEventBatch) line: 343	
> 	ChainsawAppenderHandler$WorkQueue$WorkerThread.run() line: 299	
>
> This is because the fqnOfCategoryClass variable is null, as is the  
> LocationInfo.  This obviously never happened with 1.3.  I wonder if  
> the 'fake' appender that dispatches events to the GUI is required  
> to handle something slightly different.


I've been staring at the current 1.2 code and now I finally see the  
light.

In EventDetailLayout, we make a copy of the event setting the  
fqnCategoryClassName value to null (first constructor arg):

     LoggingEvent copy = new LoggingEvent(null,
	   logger, event.getTimeStamp(),
	   event.getLevel(),
	   msg,
	   threadName,
	   event.getThrowableInformation(),
	   ndc,
	   li,
	   properties);


Later on, when the PatternParser wants the LocationInfo, because  
that's null, it generates a new one, but inside LocationInfo  
constructor:

     public LocationInfo(Throwable t, String fqnOfCallingClass) {
       if(t == null)
	return;
......
	      ibegin = s.lastIndexOf(fqnOfCallingClass);

Since fqnOfCallingClass is null, blam-o inside String.lastIndexOf 
(String).

So, why does it fail now in 1.2?

In LoggingEvent in 1.3:

     if (locationInfo == null && fqnOfCategoryClass != null) {
       locationInfo = new LocationInfo(new Throwable(),  
fqnOfCategoryClass);
     }

In LoggingEvent in 1.2:

   /**
      Set the location information for this logging event. The collected
      information is cached for future use.
    */
   public LocationInfo getLocationInformation() {
     if(locationInfo == null) {
       locationInfo = new LocationInfo(new Throwable(),  
fqnOfCategoryClass);
     }
     return locationInfo;
   }

So, just a subtle change required in the if block in 1.2 code.  This  
change was done by Ceki in 1.3 trunk via revision 310506:

http://svn.apache.org/viewvc?view=rev&revision=310506

I think we should port this change as well.  Any objections?

Paul




Re: Chainsaw+log4j12 == LocationInfo oddness

Posted by Curt Arnold <ca...@apache.org>.
On Apr 19, 2007, at 10:57 PM, Paul Smith wrote:
> Also on a maven front, I've finally started getting log4j12 branch  
> working with maven.  I basically copied the dependency list from  
> the trunk pom.xml, and fought with the maven repos to get all the  
> sun jars downloaded into my local repo.  Curse Sun and their jar  
> licensing.  Why can't it 'just work'.   If all the sun jars were in  
> maven repos, then I think Maven would look extra schmick.  Together  
> with the maven-eclipse plugin, I'm seriously thinking that  
> mavenizing Chainsaw isn't a bad idea.
>
> Paul
>

I've been working on the site generation stuff for components.  There  
is still a few odd bits, but its looking pretty good.  I'm going to  
try to get as many bells and whistles on the components site before  
duplicating the same approach on the other companions.  I'm not quite  
finished with it, but I'm committing my current state in case you  
want to look.  I wasn't contemplating migrating away from the Ant  
build for log4j 1.2, but I'm quite interested in using Maven for a  
lot of the web content.

Did you try Patrick Wyss suggestion of adding Sun's Maven repo to the  
list of repos?  It didn't have JMS, but it did was supposed to have  
most of the others.



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org