You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by mc1392 <mc...@columbia.edu> on 2009/12/08 22:48:45 UTC

DailyRollingFileAppender

Is there any way to get the log entries to have the most recent on top?
Currently I am using html layout and the newest entry ends up at the bottom
of the file.
I'd like the newest on top.


-- 
View this message in context: http://old.nabble.com/DailyRollingFileAppender-tp26701419p26701419.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


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


Re: DailyRollingFileAppender (newest on top)

Posted by mc1392 <mc...@columbia.edu>.
Thank you. I thought about that, but was hoping there was some easier
alternative.
I will give it a shot.
: )

Curt Arnold-3 wrote:
> 
> 
> On Dec 8, 2009, at 3:48 PM, mc1392 wrote:
> 
>> 
>> Is there any way to get the log entries to have the most recent on top?
>> Currently I am using html layout and the newest entry ends up at the
>> bottom
>> of the file.
>> I'd like the newest on top.
>> 
> 
> Appending content is within the capabilities of java.io, prepending is
> not.   To do it without support from the IO system, you'd end up rewriting
> the entire log file for every entry.   logging is write often, read
> rarely, so it makes more sense to optimize writing. 
> 
> Since you are using the HTMLLayout and presumably reading the log file
> within a modern browser, you could instead use the XMLLayout, write the
> log in the traditional order and then use an XSLT stylesheet to format and
> reorder the entries in the browser.  To do that, you'd need a shell
> document,
> 
> logfile.xml
> 
> <!DOCTYPE logfile [
> <!ENTITY events SYSTEM 'events.xml'>
> ]>
> <?xml-stylesheet href="mystylesheet.xsl"?>
> <logfile>
> 	&events;
> </logfile>
> 
> 
> And have your file appender write to events.xml.  A browser reading
> logfile.xml will read in the contents of events.xml and then will run the
> transform in mystylesheet.xsl which could convert the logging events to
> the order and format of your choice.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/DailyRollingFileAppender-tp26701419p26758939.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


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


Re: DailyRollingFileAppender (newest on top)

Posted by Curt Arnold <ca...@apache.org>.
On Dec 8, 2009, at 3:48 PM, mc1392 wrote:

> 
> Is there any way to get the log entries to have the most recent on top?
> Currently I am using html layout and the newest entry ends up at the bottom
> of the file.
> I'd like the newest on top.
> 

Appending content is within the capabilities of java.io, prepending is not.   To do it without support from the IO system, you'd end up rewriting the entire log file for every entry.   logging is write often, read rarely, so it makes more sense to optimize writing. 

Since you are using the HTMLLayout and presumably reading the log file within a modern browser, you could instead use the XMLLayout, write the log in the traditional order and then use an XSLT stylesheet to format and reorder the entries in the browser.  To do that, you'd need a shell document,

logfile.xml

<!DOCTYPE logfile [
<!ENTITY events SYSTEM 'events.xml'>
]>
<?xml-stylesheet href="mystylesheet.xsl"?>
<logfile>
	&events;
</logfile>


And have your file appender write to events.xml.  A browser reading logfile.xml will read in the contents of events.xml and then will run the transform in mystylesheet.xsl which could convert the logging events to the order and format of your choice.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: DailyRollingFileAppender

Posted by Michael Erskine <mi...@ketech.com>.
> Is there any way to get the log entries to have the most recent on top?
> Currently I am using html layout and the newest entry ends up at the bottom
> of the file.
> I'd like the newest on top.

Turn your screen upside down :)

Seriously though - I don't mean to poke fun but there's a proliferation of posts asking for esoteric "features" that belong elsewhere. Can the users of libraries no longer write code?

BTW: I'm sure you could log to LF5 and have it display the most recent log entry first. Personally I'd use tail and sort on a plain text log or write a custom appender that is a "prepender" with an ajax servlet if I wanted to get fancy web output.

Regards,
Michael Erskine.


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