1
answer

I have a directory with multiple sub directories where I need to get logs from.

Under my original plan for getting all files types in a single directory, I can get it to work by appending "\\\*.log" for instance at the end of the path, but unfortunately it gets every log file and not just the ones I am looking for.

Is there a way to have NxLog Community Edition search through sub directories to find the files?

This is my lab setup:

C:\users\admin\Desktop\testfiles\Server1\w3c1\test.log
\w3c2\test.log
\Server2\w3c1\test.log
\w3c2\test.log

I've tried using these, but they don't work
"C:\\users\\admin\\Desktop\\testfiles\\*\\w3c*\\\*.log"
"C:\\users\\admin\\Desktop\\testfiles\\\*\\w3c\*\\\*.log"

We need it like something close to this because Server1 also has other logs that we don't want like firewall.log files.

Any advice would be great.

Thanks

AskedMay 7, 2019 - 9:52pm

Answer (1)

The way you are trying currently is not supported as directory wildcards are not supported.
If all of the files you are looking for are called test.log then you could use the Recursive directive as it was meant as a directory wildcard replacement, of sorts.

File  C:\users\admin\Desktop\testfiles\test.log
Recursive  True

This should match test.log in any subdirectory. NXLog EE also has an Exclude directive that could prove to be useful as well being able to use multiple File directives.

AnsweredMay 7, 2019 - 11:17pm

Comments (2)

  • motts's picture

    Yeah, I found that in the CE manual, but I wasn't sure if there was another trick to do that.

    I got the Recursive flag to work, which is actually set to True by default, but again I am pulling logs, like firewalls that aren't needed.

    However, all the logs I need to pull start with either "u_ex" or "ex", so I tried to modify the Path for that with no success.

    \\\^u?_?ex*.log
    \\\^u\?\_\?ex\*.log

    Any other ideas?

    May 7, 2019 - 11:43pm
  • Zhengshi's picture
    (NXLog)

    Straight regex doesn't currently work in the File directive.
    The current options I think are to use two File directives with Recursive True in NXLog EE or to use two im_file modules, one for each of those file patterns in NXLog CE.

    May 9, 2019 - 12:17am