loggerpro
loggerpro copied to clipboard
How to get current log file name?
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.
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.
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;