Skip to content

Feature Request: different destinations based upon log_level #198

Answered by MadBomber
MadBomber asked this question in Q&A
Discussion options

You must be logged in to vote

For the next guy/gal ... filtering is easy. semantic_logger is now my favorite logger libraru!

# level_index #=> 0     1     2    3    4     5
level_names = %w[ trace debug info warn error fatal ]

level_names.each_with_index do |level_name, level_index|
  SemanticLogger.add_appender(
    file_name:  "#{level_name}.log",
    filter:     Proc.new { |log| level_index == log.level_index }
  )
end

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by reidmorrison
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #118 on January 17, 2022 20:57.