loggerpro icon indicating copy to clipboard operation
loggerpro copied to clipboard

How to get current log file name?

Open MarcosCunhaLima opened this issue 11 months ago • 2 comments

Using file appender, how can I get the current filename in order to download it? Is there any issues regarding this? I am thinking of opening the file to read, copy it to a stream, close file and then download it.

MarcosCunhaLima avatar Dec 18 '24 12:12 MarcosCunhaLima

The file can be renamed, deleted and so on. Having the "current" file name is not a thing because it can change very fastly. What about a log clone with static file name? In such case you can just download the "remaining file" in your storage.

danieleteti avatar Mar 20 '25 15:03 danieleteti

For instance, I have a log that is in a headless server and there is a controller of that server (in other computer) in which a user needs to download the server log (or even read it online). So the controller needs the latest (or remaining file) filename in order to download or open in read mode to read it. What I have done is create an inherited Appender which has a sole function getCurrentLogFileName:

 TLoggerProFileAppenderFutura = class( TLoggerProFileAppender )
    public
      function getCurrentLogFileName: string;
  end;

and (as the function getLogFileName is protected) then coded the function above:

function TLoggerProFileAppenderFutura.getCurrentLogFileName: string;
begin
  result := getLogFileName('main',0); // para obter o nome do log atual
end;

MarcosCunhaLima avatar Mar 24 '25 16:03 MarcosCunhaLima