1

I have log4j2.xml properties:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout
                    pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%t}{bright,blue}] %style{%C{1.}}{bright,yellow}: %msg%n%throwable" />
        </Console>

        <RollingFile name="RollingFile"
                     fileName="/opt/tomcat/mylogs/logs.log"
                     filePattern="/opt/tomcat/mylogs/$${date:yyyy-MM}/log-%d{-dd-MMMM-yyyy}-%i.log.gz">
            <PatternLayout>
                <pattern>%d %p %C{1.} [%t] %m%n</pattern>
            </PatternLayout>
            <Policies>
                <!-- rollover on startup, daily and when the file reaches 50 MegaBytes -->
                <OnStartupTriggeringPolicy />
                <SizeBasedTriggeringPolicy
                        size="50 MB" />
                <TimeBasedTriggeringPolicy />
            </Policies>
        </RollingFile>
    </Appenders>

    <Loggers>
        <!-- LOG everything at INFO level -->
        <Root level="info">
            <AppenderRef ref="Console" level="info" />
            <AppenderRef ref="RollingFile" level="info" />
            <AppenderRef ref="SmtpAppender" level="exception"/>
        </Root>
        <Logger name="com.kot" level="debug">
            <AppenderRef ref="RollingFile"/>
        </Logger>
    </Loggers>

</Configuration>

But this properteis create logg files on another folder on server: "/opt/tomcat/mylogs/logs.log" I want to split catalina.out logs. This logs are located on "/opt/tomcat/logs/catalina.out" by default Also, how to split server logs and application logs?

Du-Lacoste
  • 11,530
  • 2
  • 71
  • 51
NEWjers
  • 11
  • 1
  • 1
    One approach is to use `logrotate` - see [logrotate doesn't rotate catalina.out](https://stackoverflow.com/a/60638500/12567365) for an example. I have used something very similar to that answer's example with no issues. – andrewJames Jun 25 '21 at 18:14
  • `catalina.out` is the file to which Tomcat's standard output and error are connected (on UNIX). If you want to remove your application logs from `catalina.out`, just remove the `Console` appender. – Piotr P. Karwasz Jun 25 '21 at 20:03

0 Answers0