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

feat: set max log files to 720 by default, info log only #4787

Merged
merged 9 commits into from
Oct 4, 2024
13 changes: 11 additions & 2 deletions src/common/telemetry/src/logging.rs
Kev1n8 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ pub struct LoggingOptions {

/// The logging options of slow query.
pub slow_query: SlowQueryOptions,

/// The maximum number of log files set by default.
pub max_log_files: usize,
Kev1n8 marked this conversation as resolved.
Show resolved Hide resolved
Kev1n8 marked this conversation as resolved.
Show resolved Hide resolved
}

/// The options of slow query.
Expand Down Expand Up @@ -116,6 +119,8 @@ impl Default for LoggingOptions {
tracing_sample_ratio: None,
append_stdout: true,
slow_query: SlowQueryOptions::default(),
// Rotation hourly, 24 files per day, keeps info log files of 30 days
max_log_files: 720,
}
}
}
Expand Down Expand Up @@ -206,8 +211,12 @@ pub fn init_global_logging(

// Configure the file logging layer with rolling policy.
let file_logging_layer = if !opts.dir.is_empty() {
let rolling_appender =
RollingFileAppender::new(Rotation::HOURLY, &opts.dir, "greptimedb");
let rolling_appender = RollingFileAppender::builder()
.rotation(Rotation::HOURLY)
.filename_prefix("greptimedb")
.max_log_files(opts.max_log_files)
.build(&opts.dir)
.expect("initializing rolling file appender failed");
v0y4g3r marked this conversation as resolved.
Show resolved Hide resolved
let (writer, guard) = tracing_appender::non_blocking(rolling_appender);
guards.push(guard);

Expand Down
Loading