audit4j / audit4j-core

An open source auditing framework.
http://audit4j.org
Apache License 2.0
125 stars 77 forks source link

Support for wildcard file filter #81

Open johno1985 opened 5 years ago

johno1985 commented 5 years ago

Version 2.5.0

For our different environments in our deployment pipeline, our audit4j config file will have an environment name infix in the filename, e.g. 'audit4j.conf-qa.yml'

We then set the path using:

System.setProperty("audit4j.conf.file.path", System.getProperty("user.home") + File.separator + "audit4j-conf*.yml");

But this results in the following exception:

java.nio.file.InvalidPathException: Illegal char <*> at index 30: C:\Users\Jonathan\audit4j-conf*.yml

Could you use the following instead?


FileFilter fileFilter = new WildcardFileFilter(filename);
File[] files = dir.listFiles(fileFilter);
int count = files.length;
if (count != 1) {
    //file not found handling goes here
}

//file found handling goes here```