zap
zap copied to clipboard
Can zap support dedicate file permission for log?
When set logpath for zap, it always to create with file mode 0644 for log file.
Does it support dedicate file permission mode, such as 0664?
It's not possible to customize the permissions used for creating the file. However, this permission is only used if the file doesn't exist, so if you want a custom file permission, create the file beforehand with the permission you want, and then zap will use the existing file.
It's not possible to customize the permissions used for creating the file. However, this permission is only used if the file doesn't exist, so if you want a custom file permission, create the file beforehand with the permission you want, and then zap will use the existing file.
So, this isn't quite right:
- the typical way of customizing, especially in a scenario where one wants group write, is via umask
- the correct thing for an application that doesn't care per-se about file permissions is to pass
0666
or0777
to syscalls likeos.OpenFile
andos.Mkdir
- the OS then applies umask and you end up with
0644
or0755
typically - only security sensitive apps typically pass otherwise, and then it's things like
0700
or0600
for something like a private key file - usually when you see os.OpenFile with 0644, the developer didn't actually care, and their intent was "standard / default behavior", which should have been
0666
Sorry, I meant it's not possible to customize the permission value used by zap, it's hard-coded today and we don't have an easy way to customize it.
We can definitely change it to 0666
and rely on the umask.