在Springboot中创建2个日志文件

时间:2017-09-05 02:28:19

标签: java spring logging spring-boot

我在//using `@php` @php function assignMainMenuPageType($mainMenu) { if($mainMenu->page_type == "link-page") { return $mainMenu->link; }else if($mainMenu->page_type == "predefine-link") { return route('home').'/'.$mainMenu->link; } return 'page/'.$mainMenu->slug; } @endphp // use the function in your view <ul> @foreach($main_nav as $mainMenu) <li> <a href="{{ assignMainMenuPageType($mainMenu) }}"> {{ $mainMenu->title }} </a> </li> @endforeach </ul> Springboot

中创建了多个日志文件
log-back.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <property name="HOME" value="./logs" />
    <appender name="SYSLOG" class="ch.qos.logback.classic.net.SyslogAppender">-->
        <syslogHost>10.0.3.20</syslogHost>
        <facility>SYSLOG</facility>
        <suffixPattern>abc [%thread] %logger %msg</suffixPattern>
    </appender>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <layout class="ch.qos.logback.classic.PatternLayout">
        <Pattern>
        %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
        </Pattern>
        </layout>
    </appender>

    <appender name="FILE-AUDIT" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${HOME}/abc.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- daily rollover -->
            <fileNamePattern>${HOME}/abc.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>30</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%relative [%thread] %-5level %logger{35} - %msg%n</pattern>
        </encoder>
    </appender>

当我在日志目录中查看时,我只看到了// another log file <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${HOME}mon.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- daily rollover --> <fileNamePattern>${HOME}/mon.%d{yyyy-MM-dd}.log</fileNamePattern> <maxHistory>30</maxHistory> </rollingPolicy> <encoder> <pattern>%relative [%thread] %-5level %logger{35} - %msg%n</pattern> </encoder> </appender> <logger name="com.rh.project" level="debug"> <appender-ref ref="STDOUT" /> <appender-ref ref="SYSLOG" /> <appender-ref ref="FILE-AUDIT" /> </logger> <logger name="mail-log" level="debug"> <appender-ref ref="STDOUT" /> <appender-ref ref="SYSLOG" /> <appender-ref ref="FILE" /> </logger> </configuration> ,但没有abc.log

1 个答案:

答案 0 :(得分:2)

您是否注意到第二个记录器内部缺少斜线?

<file>${HOME}/mon.log</file>  

我相信这就是问题所在。但是,与春季靴子无关:)