How to extract the name of the file currently parsed by LogParser?

1.1k Views Asked by At

I would like to extract the file name and display it in a select when querying multiple log files with a wildcard in the from clause as in the following example:

suppose I have the following ,log files in c:\logs:

report-001.log

report-002.log

report-003.log

I would like the following pseudo-sql:

select *current_log_file_name* from 'c:\logs*.logs'

to produce the following output:

report-001.log

report-002.log

report-003.log

what function/expression can I use to accomplish this task?

1

There are 1 best solutions below

2
On

You don't need a function; almost all input formats export a field with the name or path of the log file being parsed. In most cases the field is named "LogFilename". You can then use the EXTRACT_FILENAME function to discard the path.