为什么我的logback / logstash json编码器配置在Mac OS上不起作用?

时间:2018-09-17 19:14:40

标签: java logstash logback

运行以下logback-test.xml配置时,我的日志记录在Windows上运行良好。但是在Mac上,它会创建logfile.json,但无法向其中写入任何json数据吗?在Mac OS上我没有日志,但是在Mac上它确实输出到SDOUT完全没有问题。

<configuration>
    <timestamp key="time" datePattern="yyyy-MM-dd'_'HH-mm-ss.SSS"/>
    <appender name="RootSiftAppender" class="ch.qos.logback.classic.sift.SiftingAppender">
        <discriminator>
            <Key>test</Key>
            <DefaultValue>logfile</DefaultValue>
        </discriminator>
        <sift>
            <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
                <File>src\\main\\resources\\${test}.json</File>
                <encoder class="net.logstash.logback.encoder.LogstashEncoder">
                    <timestampPattern>yy:MM:dd'_'HH:mm:ss</timestampPattern>
                    <jsonGeneratorDecorator class="net.logstash.logback.decorate.PrettyPrintingJsonGeneratorDecorator"/>
                    <providers>
                        <logLevel/>
                        <timestamp/>
                        <message/>
                        <loggerName/>
                        <threadName/>
                    </providers>
                </encoder>
                <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
                    <FileNamePattern>${test_name}.%i.json</FileNamePattern>
                    <MinIndex>1</MinIndex>
                    <MaxIndex>100</MaxIndex>
                </rollingPolicy>
                <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
                    <MaxFileSize>50MB</MaxFileSize>
                </triggeringPolicy>
            </appender>
        </sift>
    </appender>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%n %d{HH:mm:ss} %thread %level %logger{0} %msg</pattern>
        </encoder>
    </appender>

    <root level="RootSiftAppender">
        <appender-ref ref="RootSiftAppender"/>
    </root>
    <root level="DEBUG">
        <appender-ref ref="STDOUT"/>
    </root>
</configuration>

0 个答案:

没有答案