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
19 Replies
Project ID:
N/A
does your project contain a public folder?
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
wait why are you writing logs to a file anyway?
For my company
We are adding security
And we want to know who did what
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
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
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
Ohhh
Axiom seems good
Let me try it
Thank you for the advice
axiom is very good, use their sdk
it should not take much work for you to refactor your code
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?
dont log to axiom as a blocking event, do it asynchronously
So like this it doesnt going to slow down the application?
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.
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?
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
Okey, thank you, i liked axiom and it is easy to use
Solution
axiom is pretty good indeed