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 bu...@apache.org on 2007/02/21 20:29:40 UTC

DO NOT REPLY [Bug 41670] New: - Allow to flush a given Logger or Appender or all of them

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41670>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41670

           Summary: Allow to flush a given Logger or Appender or all of them
           Product: Log4j
           Version: 1.3alpha
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Appender
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: olivier.dupuy@pwgsc.gc.ca


Hi,

See my post #15 in the bug 28647
As indicated in the reply #16, it makes more sense to make this an RFE of its 
own so here it is
http://issues.apache.org/bugzilla/show_bug.cgi?id=28647

I totally aggree with the flushing being tied to the level of the event (as in 
28647). This totally makes sense and would be good to have it in the default 
log4J.

My use cases for a flush of a given Logger, of one Appender or of all the 
Logger/Appender are the following
1) application shuting down. You don't want to loose any logging done so far
2) need to see the whole log in production (or in a production like 
environment) from an administrative interface or not without penaly for the 
normal performance (so you just flush for this purpose). So you need a way to 
force a flush of one or all Logger/Appender

As Simon in 28647, I also use a shutdown hook in my application to address the 
issue in case 1) The only way that I found to flush was to close all the 
appenders. This is fine as I am stopping the application but a way to flush 
globally all the logs without closing the appenders in a very simple way should 
also be there. But what do I know about other libraries/jars outside of my 
code ? They could also use Log4J and log something after this closing 
operation. Closing the appenders could forbid them to log normally and would 
create confusing error messages about closed appenders. A simple way to flush 
would be very convenient.

Case 2). I am simply stuck. I don't want to close all the appenders to reopen 
them later (if I can). I could loose some logging in the mean time and create 
some serious mess. So flushing should be present in each appender that could 
delegate to sub appenders if required. Here I am totally stuck with the default 
implementation. I want to use out of the box functions of log4j without 
creating my own appenders and others

The current implementation looks like the app runs forever or never needs to be 
maintained/troubleshooted but this is not always the case in real life.

Regarding the API, I am proposing a method
- Logger.flush() (not static) sends a flush order to all the appenders this 
logger is connected to
- Appender.flush() (not static) sends a flush order to all this appender 
(implementation) and sub appenders if any
- Logger.flushAll() (static) and/or Appender.flushAll() (static) sends a flush 
order to all the opened appenders
I insist on the fact that you may want flushing a Logger or/and an Appender (or 
all) based on your situation. 

Implementation.
Guys you are the specialists. You could add these methods, create an interface 
FlushableLogger/Appender with the new methods to preserve the compatibility, 
decide to create a new kind of LoggingEvent forcing a flush.... It's up to you

Thanks a lot for this great library.

Olivier DUPUY

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 41670] - Allow to flush a given Logger or Appender or all of them

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41670>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41670


carnold@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |LATER




------- Additional Comments From carnold@apache.org  2007-08-22 19:57 -------
log4j 2.0 design goal.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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