Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use logback configuration (as the standard application log) in Sentinel logging? #1163

Open
goudai opened this issue Nov 18, 2019 · 4 comments
Labels
area/logging Issues or PRs related to logging of Sentinel kind/question Category issues related to questions or problems

Comments

@goudai
Copy link

goudai commented Nov 18, 2019

你好,请问我该如何配置让sentinel中的日志变成标准的应用日志(跟随我的logback配置),而不是输出到奇怪位置的文件。

@goudai goudai changed the title 你好,请问我该如何配置让sentinel中的日志变成标准的应用日志,而不是输出到奇怪位置的文件中。 你好,请问我该如何配置让sentinel中的日志变成标准的应用日志(跟随我的logback配置,而不是输出到奇怪位置的文件中。 Nov 18, 2019
@sczyh30 sczyh30 added area/logging Issues or PRs related to logging of Sentinel kind/question Category issues related to questions or problems labels Nov 18, 2019
@sczyh30
Copy link
Member

sczyh30 commented Nov 18, 2019

Currently, Sentinel does not support delegating logs to other logging libraries (e.g. slf4j). You may configure the log directory via the csp.sentinel.log.dir property item.

Related document:

Further discussion about logging SPI: #757

@sczyh30 sczyh30 changed the title 你好,请问我该如何配置让sentinel中的日志变成标准的应用日志(跟随我的logback配置,而不是输出到奇怪位置的文件中。 How to use logback configuration (as the standard application log) in Sentinel logging? Nov 19, 2019
@qixiaobo
Copy link

Very stranger

@sczyh30
Copy link
Member

sczyh30 commented Mar 16, 2020

Related issue: #1340. Contributions are welcomed!

@copilot-fe
Copy link

copilot-fe commented Aug 6, 2024

Sentinel 的日志分好几个 Metrics log record log 还有block log 前两个需要自己配置
`

<appender name="sentinel_record" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${catalina.base}/logs/sentinel-record.log</file>
    <append>true</append>
    <encoder>
        <pattern>${sentinel-pattern}</pattern>
        <charset>${encoding}</charset>
    </encoder>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>${catalina.base}/logs/sentinel-record.%d{yyyy-MM-dd-HH}.log</fileNamePattern>
    </rollingPolicy>
</appender>
<appender name ="async_sentinel_record" class= "ch.qos.logback.classic.AsyncAppender">
    <discardingThreshold >0</discardingThreshold>
    <queueSize>512</queueSize>
    <neverBlock>true</neverBlock>
    <appender-ref ref ="sentinel_record"/>
</appender>

<!--sentinel_metric日志输出-->
<appender name="sentinel_metric" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${catalina.base}/logs/sentinel-metric.log</file>
    <append>true</append>
    <encoder>
        <pattern>${sentinel-pattern}</pattern>
        <charset>${encoding}</charset>
    </encoder>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>${catalina.base}/logs/sentinel-metric.%d{yyyy-MM-dd-HH}.log</fileNamePattern>
    </rollingPolicy>
</appender>
<appender name ="async_sentinel_metric" class= "ch.qos.logback.classic.AsyncAppender">
    <discardingThreshold >0</discardingThreshold>
    <queueSize>512</queueSize>
    <neverBlock>true</neverBlock>
    <appender-ref ref ="sentinel_metric"/>
</appender>

`

另外设置 VM OPTIONS -Dcsp.sentinel.log.dir={YOUR LOG DIR}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/logging Issues or PRs related to logging of Sentinel kind/question Category issues related to questions or problems
Projects
None yet
Development

No branches or pull requests

4 participants