You can use the ionic native File API and create file using createFile function of the File API.
I would recommend storing "access.log" file in cordova.file.dataDirectory as it just one file and would guess it is for internal usage of app. As you have not mentioned specific usage of the file I would suggest you check out Where To Store Files section of cordova documentation ( The Ionic File API is just a wrapper around it, so the docs are same ).
Example code:
import { Component } from '@angular/core';
import { File } from '@ionic-native/file';
@Component({
selector: 'demo-comp',
templateUrl: 'demo-comp.component.html',
})
export class DemoCompComponent {
constructor(private file: File) { }
createAccessLogFileAndWrite(text: string) {
this.file.checkFile(this.file.dataDirectory, 'access.log')
.then(doesExist => {
console.log("doesExist : " + doesExist);
return this.writeToAccessLogFile(text);
}).catch(err => {
return this.file.createFile(this.file.dataDirectory, 'access.log', false)
.then(FileEntry => this.writeToAccessLogFile(text))
.catch(err => console.log('Couldn't create file));
});
}
writeToAccessLogFile(text: string) {
this.file.writeExistingFile(this.file.dataDirectory, 'access.log', text)
}
someEventFunc() {
// This is an example usage of the above functions
// This function is your code where you want to write to access.log file
this.createAccessLogFileAndWrite("Hello World - someEventFunc was called");
}
}
This is a demo you need to call createAccessLogFileAndWrite from your own function and pass the text you want to append to the file.
Let me know in the comments if you face any problems.