Skip to content

Commit

Permalink
Update log level.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Oct 15, 2024
1 parent 2b8aa6f commit 9b6c1b2
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 99 deletions.
43 changes: 31 additions & 12 deletions i18n/en-us/docusaurus-plugin-content-docs/current/doc/log.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,45 @@ srs_log_tank file;

## LogLevel

The level is specified by `srs_log_level` and control which level of log to print:
* verbose: Lots of log, which hurts performance. SRS default to disable it when compile.
* info:Detail log, which huts performance. SRS default to disable it when compile.
* trace: Important log, less and SRS enable it as default level.
The level is specified by `srs_log_level_v2` and control which level of log to print:

* trace: Lots of log, which hurts performance. SRS default to disable it when compile.
* debug:Detail log, which huts performance. SRS default to disable it when compile.
* info: Important log, less and SRS enable it as default level.
* warn: Warning log, without debug log.
* error: Error level.

The level in config file:

```bash
# the log level, for all log tanks.
# can be: verbose, info, trace, warn, error
# defualt: trace
srs_log_level trace;
```
# The log level for logging to console or file. It can be:
# verbose, info, trace, warn, error
# If configure --log-level_v2=off, use SRS 4.0 level specs which is v1, the level text is:
# Verb, Info, Trace, Warn, Error
# If configure --log-level_v2=on, use SRS 5.0 level specs which is v2, the level text is:
# TRACE, DEBUG, INFO, WARN, ERROR
# Note: Do not support reloading, for SRS5+
# Overwrite by env SRS_LOG_LEVEL or SRS_SRS_LOG_LEVEL
# default: trace
srs_log_level trace;

# The log level v2, rewrite the config srs_log_level if not empty, it can be:
# trace, debug, info, warn, error
# If configure --log-level_v2=off, use SRS 4.0 level specs which is v1, the level text is:
# Verb, Info, Trace, Warn, Error
# If configure --log-level_v2=on, use SRS 5.0 level specs which is v2, the level text is:
# TRACE, DEBUG, INFO, WARN, ERROR
# Overwrite by env SRS_LOG_LEVEL_V2 or SRS_SRS_LOG_LEVEL_V2
srs_log_level_v2 info;
```

> Note: For SRS 5.0+, the `--log-level_v2` is default to `on`, which means we use the new log level by default.
Notes:

* Enable all high level, for example, enable trace/warn/error when set level to trace.
* The verbose and info level is disabled when compile. Modify the `srs_kernel_log.hpp` when need to enable this.
* Recomment to use trace level.
* The trace and debug level is disabled when compile. Modify the `srs_kernel_log.hpp` when need to enable this.
* Recomment to use `info` level.

## Log of tools

Expand Down Expand Up @@ -329,7 +348,7 @@ The 107 is a client which trigger the edge to fetch stream from origin. Find 110

The 110 is a flash player client.

### System info.
### System info

The system info and port listen at:

Expand Down
59 changes: 38 additions & 21 deletions i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/log.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,47 @@ srs_log_tank file;

## LogLevel

LogLevel就是log的级别,什么级别的日志才会打印出来。
日志级别由srs_log_level_v2指定,控制要打印哪个级别的日志:

SRS支持设置日志级别,通过设置`srs_log_level`
* verbose: 非常详细的日志,性能会很低,日志会非常多。SRS默认是编译时禁用这些日志,提高性能。
* info:较为详细的日志,性能也受影响。SRS默认编译时禁用这些日志。
* trace: 重要的日志,比较少,SRS默认使用这个级别。
* warn: 警告日志,SRS在控制台以黄色显示。若SRS运行较稳定,可以只打开这个日志。建议使用trace级别。
* error: 错误日志,SRS在控制台以红色显示。
* trace:大量日志,会影响性能。SRS默认在编译时禁用它。
* debug:详细日志,会影响性能。SRS默认在编译时禁用它。
* info:重要日志,较少,SRS将其作为默认级别启用。
* warn:警告日志,没有调试日志。
* error:错误级别。

配置文件中的说明
配置文件中的级别

```bash
# the log level, for all log tanks.
# can be: verbose, info, trace, warn, error
# The log level for logging to console or file. It can be:
# verbose, info, trace, warn, error
# If configure --log-level_v2=off, use SRS 4.0 level specs which is v1, the level text is:
# Verb, Info, Trace, Warn, Error
# If configure --log-level_v2=on, use SRS 5.0 level specs which is v2, the level text is:
# TRACE, DEBUG, INFO, WARN, ERROR
# Note: Do not support reloading, for SRS5+
# Overwrite by env SRS_LOG_LEVEL or SRS_SRS_LOG_LEVEL
# default: trace
srs_log_level trace;
srs_log_level trace;

# The log level v2, rewrite the config srs_log_level if not empty, it can be:
# trace, debug, info, warn, error
# If configure --log-level_v2=off, use SRS 4.0 level specs which is v1, the level text is:
# Verb, Info, Trace, Warn, Error
# If configure --log-level_v2=on, use SRS 5.0 level specs which is v2, the level text is:
# TRACE, DEBUG, INFO, WARN, ERROR
# Overwrite by env SRS_LOG_LEVEL_V2 or SRS_SRS_LOG_LEVEL_V2
srs_log_level_v2 info;
```

> Note: 对于SRS 5.0+,`--log-level_v2`默认为`on`,这意味着我们默认使用新的日志级别。
注意事项:
* 设置了低级别的日志,自动会打印高级别的。譬如设置为trace,那么trace/warn/error日志都会打印出来。
* 默认verbose和info是编译时禁用的,若需要打开这两个日志,需要修改`srs_kernel_log.hpp`,将对应的禁用编译宏打开。
* 推荐使用trace级别,重要的日志不多,对于排错很方便。如果有错误,建议用gdb调试,不要依赖日志。只有在不得已时才用日志排错。

## 工具的日志
* 启用所有高级别,例如,将级别设置为info时启用info/warn/error。
* 在需要启用此功能时,修改srs_kernel_log.hpp以启用trace和debug级别。
* 建议使用info级别。

## Log of tools

Transcode/Ingest等都是用到了外部工具,譬如FFMPEG,所以我们统称ffmpeg日志。

Expand All @@ -65,7 +82,7 @@ SRS可以配置ffmpeg的日志路径,若配置为`/dev/null`则禁用ffmpeg日
ff_log_dir ./objs;
```

## 日志格式
## Log Format

SRS的日志可以定位到某个连接,可以在混杂了成千上万个连接的日志中找到某一个连接的日志,譬如要看某个客户端的日志。这个功能和SRS的日志格式设计相关,譬如:

Expand Down Expand Up @@ -171,7 +188,7 @@ SRS的日志可以定位到某个连接,可以在混杂了成千上万个连

Encoder => Origin => Edge => Player,整个分发集群的日志都直接找到!O了,快速直接!

### 可倒追溯日志
### Reverse Tracable Log

可追溯日志,上一节所描述的,可以从播放器追溯到边缘服务器,从边缘追溯到上层,上层到上上层,一直到源站。

Expand Down Expand Up @@ -213,7 +230,7 @@ Encoder => Origin => Edge => Player,整个分发集群的日志都直接找到

可以看到有两个连接,一个是107,一个是110。连接107是播放后才回源,110是已经在回源了然后播放的。

### 可任意追溯
### Any Tracable Log

以为支持可追溯以及可倒追溯日志,所以我们在任意节点开始都可以找到整个分发链路。

Expand Down Expand Up @@ -332,7 +349,7 @@ Encoder => Origin => Edge => Player,整个分发集群的日志都直接找到

可见110也是个flash播放连接。

### 系统信息
### System info

日志中有版本和配置信息,以及使用的pid文件,侦听的端口,启动前几条日志就是:

Expand Down Expand Up @@ -377,7 +394,7 @@ Encoder => Origin => Edge => Player,整个分发集群的日志都直接找到
* <strong>侦听8080(HTTP服务)</strong>:[2014-04-04 11:39:24.177][trace][100][16] server started, listen at port=8080, type=2, fd=8
* <strong>侦听循环开始,准备接受连接</strong>:[2014-04-04 11:39:24.177][trace][101][16] listen cycle start, port=1935, type=0, fd=6

### 基于连接的日志
### Session oriented log

提供基于连接(会话, Sesssion, SrsId)的日志,对于排错至关重要。当然对于系统分析需要支持良好的api。

Expand Down Expand Up @@ -463,7 +480,7 @@ type=publish(FMLEPublish), stream_name=livestream

这个连接的日志就都出来了,重点关注warn和error日志。可以看到这个是客户端关闭了连接:`36:[2014-04-04 11:56:12.620][error][104][104] identify client failed. ret=207(Connection reset by peer)`

## 守护进程
## Daemon

为何默认启动srs时只有一条日志呢?原因是守护进程方式启动时,日志会打印到文件。

Expand Down
59 changes: 38 additions & 21 deletions i18n/zh-cn/docusaurus-plugin-content-docs/version-5.0/doc/log.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,47 @@ srs_log_tank file;

## LogLevel

LogLevel就是log的级别,什么级别的日志才会打印出来。
日志级别由srs_log_level_v2指定,控制要打印哪个级别的日志:

SRS支持设置日志级别,通过设置`srs_log_level`
* verbose: 非常详细的日志,性能会很低,日志会非常多。SRS默认是编译时禁用这些日志,提高性能。
* info:较为详细的日志,性能也受影响。SRS默认编译时禁用这些日志。
* trace: 重要的日志,比较少,SRS默认使用这个级别。
* warn: 警告日志,SRS在控制台以黄色显示。若SRS运行较稳定,可以只打开这个日志。建议使用trace级别。
* error: 错误日志,SRS在控制台以红色显示。
* trace:大量日志,会影响性能。SRS默认在编译时禁用它。
* debug:详细日志,会影响性能。SRS默认在编译时禁用它。
* info:重要日志,较少,SRS将其作为默认级别启用。
* warn:警告日志,没有调试日志。
* error:错误级别。

配置文件中的说明
配置文件中的级别

```bash
# the log level, for all log tanks.
# can be: verbose, info, trace, warn, error
# The log level for logging to console or file. It can be:
# verbose, info, trace, warn, error
# If configure --log-level_v2=off, use SRS 4.0 level specs which is v1, the level text is:
# Verb, Info, Trace, Warn, Error
# If configure --log-level_v2=on, use SRS 5.0 level specs which is v2, the level text is:
# TRACE, DEBUG, INFO, WARN, ERROR
# Note: Do not support reloading, for SRS5+
# Overwrite by env SRS_LOG_LEVEL or SRS_SRS_LOG_LEVEL
# default: trace
srs_log_level trace;
srs_log_level trace;

# The log level v2, rewrite the config srs_log_level if not empty, it can be:
# trace, debug, info, warn, error
# If configure --log-level_v2=off, use SRS 4.0 level specs which is v1, the level text is:
# Verb, Info, Trace, Warn, Error
# If configure --log-level_v2=on, use SRS 5.0 level specs which is v2, the level text is:
# TRACE, DEBUG, INFO, WARN, ERROR
# Overwrite by env SRS_LOG_LEVEL_V2 or SRS_SRS_LOG_LEVEL_V2
srs_log_level_v2 info;
```

> Note: 对于SRS 5.0+,`--log-level_v2`默认为`on`,这意味着我们默认使用新的日志级别。
注意事项:
* 设置了低级别的日志,自动会打印高级别的。譬如设置为trace,那么trace/warn/error日志都会打印出来。
* 默认verbose和info是编译时禁用的,若需要打开这两个日志,需要修改`srs_kernel_log.hpp`,将对应的禁用编译宏打开。
* 推荐使用trace级别,重要的日志不多,对于排错很方便。如果有错误,建议用gdb调试,不要依赖日志。只有在不得已时才用日志排错。

## 工具的日志
* 启用所有高级别,例如,将级别设置为info时启用info/warn/error。
* 在需要启用此功能时,修改srs_kernel_log.hpp以启用trace和debug级别。
* 建议使用info级别。

## Log of tools

Transcode/Ingest等都是用到了外部工具,譬如FFMPEG,所以我们统称ffmpeg日志。

Expand All @@ -65,7 +82,7 @@ SRS可以配置ffmpeg的日志路径,若配置为`/dev/null`则禁用ffmpeg日
ff_log_dir ./objs;
```

## 日志格式
## Log Format

SRS的日志可以定位到某个连接,可以在混杂了成千上万个连接的日志中找到某一个连接的日志,譬如要看某个客户端的日志。这个功能和SRS的日志格式设计相关,譬如:

Expand Down Expand Up @@ -171,7 +188,7 @@ SRS的日志可以定位到某个连接,可以在混杂了成千上万个连

Encoder => Origin => Edge => Player,整个分发集群的日志都直接找到!O了,快速直接!

### 可倒追溯日志
### Reverse Tracable Log

可追溯日志,上一节所描述的,可以从播放器追溯到边缘服务器,从边缘追溯到上层,上层到上上层,一直到源站。

Expand Down Expand Up @@ -213,7 +230,7 @@ Encoder => Origin => Edge => Player,整个分发集群的日志都直接找到

可以看到有两个连接,一个是107,一个是110。连接107是播放后才回源,110是已经在回源了然后播放的。

### 可任意追溯
### Any Tracable Log

以为支持可追溯以及可倒追溯日志,所以我们在任意节点开始都可以找到整个分发链路。

Expand Down Expand Up @@ -332,7 +349,7 @@ Encoder => Origin => Edge => Player,整个分发集群的日志都直接找到

可见110也是个flash播放连接。

### 系统信息
### System info

日志中有版本和配置信息,以及使用的pid文件,侦听的端口,启动前几条日志就是:

Expand Down Expand Up @@ -377,7 +394,7 @@ Encoder => Origin => Edge => Player,整个分发集群的日志都直接找到
* <strong>侦听8080(HTTP服务)</strong>:[2014-04-04 11:39:24.177][trace][100][16] server started, listen at port=8080, type=2, fd=8
* <strong>侦听循环开始,准备接受连接</strong>:[2014-04-04 11:39:24.177][trace][101][16] listen cycle start, port=1935, type=0, fd=6

### 基于连接的日志
### Session oriented log

提供基于连接(会话, Sesssion, SrsId)的日志,对于排错至关重要。当然对于系统分析需要支持良好的api。

Expand Down Expand Up @@ -463,7 +480,7 @@ type=publish(FMLEPublish), stream_name=livestream

这个连接的日志就都出来了,重点关注warn和error日志。可以看到这个是客户端关闭了连接:`36:[2014-04-04 11:56:12.620][error][104][104] identify client failed. ret=207(Connection reset by peer)`

## 守护进程
## Daemon

为何默认启动srs时只有一条日志呢?原因是守护进程方式启动时,日志会打印到文件。

Expand Down
Loading

0 comments on commit 9b6c1b2

Please sign in to comment.