Bug 37122 - Console redirection in 1.2.12 causes infinite loop in JBoss
Summary: Console redirection in 1.2.12 causes infinite loop in JBoss
Status: CLOSED FIXED
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Appender (show other bugs)
Version: 1.2
Hardware: All other
: P2 normal
Target Milestone: ---
Assignee: log4j-dev
URL:
Keywords:
: 37452 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-10-17 16:29 UTC by Jasper Rosenberg
Modified: 2005-11-10 15:30 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jasper Rosenberg 2005-10-17 16:29:07 UTC
JBoss's Log4jService loads the log4j.xml file, and then overwrites
System.err/System.out to redirect to log4j.

This used to work before 1.2.12 because the ConsoleAppender would always use the
stream with which it was initialized.  Unfortunately, with the fix of bug 31056
this trick no longer works, and an infinite loop is created.  

This seems like reasonable behavior to support, wanting to use the
ConsoleAppender, but also wanting to redirect all System.out/err to the logging
system.

Perhaps a boolean flag can be added to ConsoleAppender such as "cacheTarget", so
that in activateOptions() it behaves like 1.2.11 if cacheTarget is true, and
1.2.12 if cacheTarget is false.

Thanks,
Jasper
Comment 1 Mark Womack 2005-10-17 18:17:02 UTC
1.2.13 candidate
Comment 2 Curt Arnold 2005-10-18 16:52:05 UTC
I think "followReassignment" or something containing "redirect" might be clearer than "cacheTarget".  

I don't think it would be good to have the behavior differ between versions and the 1.2.11 and earlier 
behavior should be the default (that is followReassignment=false) at least in the 1.2.x series.

It would be possible to attempt to detect the JBoss redirection class, but I think that would not be a 
good solution since other applications may want to do the same thing.

I don't think it would be possible to implement followReassignment=false in log4cxx.  Don't know 
about the other log4X's.

I think it would be better to associate the changes with this bug than continue work on 31506.
Comment 3 Mark Womack 2005-10-18 18:48:49 UTC
We can have the 1.2.X behavior be consistent (ie restore previous behavior with
options to change the behavior with a flag), but then do the "right" thing in
1.3 going forward.  Just so long as we document it, it should be fine, I think.
Comment 4 Curt Arnold 2005-10-19 18:44:23 UTC
Fixed in SVN revision 326604 (trunk) and 326599 (v1_2-branch).  Added honorReassignment attribute to 
configuration with default value of false (1.2.12 behavior).
Comment 5 Mark Womack 2005-10-20 07:56:17 UTC
Fix is in the 1.2.13rc1 build which can be located at 
http://cvs.apache.org/builds/logging/log4j/log4j-1.2.13rc1/.  Please check the 
fix and let us know if it is now fixed for you.  Thanks.
Comment 6 Jasper Rosenberg 2005-10-20 15:10:21 UTC
ConsoleAppender now behaves as before (1.2.11) by default.  
I also tested with <param name="HonorReassignment" value="true"/> and it did
behave as it does in 1.2.12.  Looks good!

Thanks for the quick fix!
Comment 7 Mark Womack 2005-10-20 23:25:57 UTC
Fix verified by reporter (thanks!). Closing.
Comment 8 Curt Arnold 2005-11-11 00:30:21 UTC
*** Bug 37452 has been marked as a duplicate of this bug. ***