Error EACCES: permission denied

I am trying to write in a file that is in my server in ./reqLog.txt, but it says that i do not have permision to do that, i tried moving it to the public folder but that doesn't work either, it works in my localhost, but in railway doesnt
No description
Solution:
axiom is pretty good indeed
Jump to solution
19 Replies
Percy
Percy5mo ago
Project ID: N/A
Brody
Brody5mo ago
does your project contain a public folder?
carlostrevino3583
Yes But idealy this the file doesnt have to be in the public folder Just in the app ./reqLog.txt How can i give permission to do it? Or do i have to change the function that create the logs
Brody
Brody5mo ago
wait why are you writing logs to a file anyway?
carlostrevino3583
For my company We are adding security And we want to know who did what
Brody
Brody5mo ago
but what do you plan on doing with that file that you are writing to the container, there is no native way for you to grab that file from the container
carlostrevino3583
Sometimes there are problems, that someone delete o edited something that we do not wanted, so just i bring the server into my vscode and i will see there the file And saw who did it
Brody
Brody5mo ago
but thats not how it works, you are storing that file as a temp file in the container on railway, you cant just open that file up in vscode when its stored as a temp file in the container please for the sake of scalability and best practices, dont save access logs to a temp txt file, send your logs to axiom or better stack or even https://railway.app/template/h_WWDP
carlostrevino3583
Ohhh Axiom seems good Let me try it Thank you for the advice
Brody
Brody5mo ago
axiom is very good, use their sdk it should not take much work for you to refactor your code
carlostrevino3583
I am new in this things, adding middlewares slow down the application? Like if i ask for a GET users, and it has to pass in a logger middleware, validate middleare etc, that request is going to take longer?
Brody
Brody5mo ago
dont log to axiom as a blocking event, do it asynchronously
carlostrevino3583
So like this it doesnt going to slow down the application?
No description
No description
Brody
Brody5mo ago
looks like you are creating a new axiom client on every log event, you dont wanna do that. it also looks like you are hardcoding the axiom token and dataset, please use environment variables!! is the call to axiom.ingest sync or async? if its sync then it will slow down the api.
carlostrevino3583
Yes i am going to use enviroment variables, i just was seeing if it worked first jaja, If axiom.ingest doesnt need await means that is sync?
No description
Brody
Brody5mo ago
not sure, I'm not a JavaScript dev, you would need to read axioms documentation or even have a quick peak at the source code for that function
carlostrevino3583
Okey, thank you, i liked axiom and it is easy to use
Solution
Brody
Brody5mo ago
axiom is pretty good indeed