0

I have problem with file permissions with RollingFile and log4j2 configuration. Application is creating log file as follows:

-rwxr-xr-x. 1 centos centos 10379932 Feb 8 13:55 application.log

after rolling files read permissions for others are missing. I'm not using any permissions setting with log4j

-rw-r-----. 1 root   root        524 Feb  9 13:42 application.log
-rw-r-----. 1 root   root     462705 Feb  9 10:24 application.log.1.gz

umask is: 0022

my log4j2.xml

        <RollingFile name="test_app" fileName="${sys:application.home}/logs/application.log" ignoreExceptions="false" filePattern="${sys:application.home}/logs/application.log.%i.gz">
            <PatternLayout pattern="%d{dd-MMM-yyyy HH:mm:ss,SSS} - %X{userId} - %X{sessionId} %-5p %c{1}:%L - %m%n"/>
            <Policies>
                <SizeBasedTriggeringPolicy size="10MB"/>
            </Policies>
            <DefaultRolloverStrategy max="50"/>
        </RollingFile>

I have 2 environments and on the second one permissions are as expected (application and log4j2 configuration is the same) Where can I search the problem?

  • How is your application running? Are you sure the application does not overwrite the umask (e.g. Tomcat does overwrite it)? Is your application running as `root`? If not another process might be rotating the logs. – Piotr P. Karwasz Feb 09 '23 at 14:24
  • I have just find out that problem exists only on tomcat environment so I have to check tomcat umask. thanks for tip. – Filip M Feb 10 '23 at 11:31
  • Tomcat overwrites `umask` in its initialization scripts: see [this question](https://stackoverflow.com/q/41975808/11748454) – Piotr P. Karwasz Feb 10 '23 at 13:31

0 Answers0