Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

logging into different files #201

Answered by reidmorrison
gingerlime asked this question in Q&A
Discussion options

Sorry if this is a silly question, but I might have missed something very obvious...

My Sidekiq is currently set to log to a separate log file, set inside the config.yml. When SemanticLogger replaces the logger, then all log output goes to the same file as the rails log, and it doesn't use this config directive any more.

Even if it ignores the config, is there a way to tell SemanticLogger to log sidekiq log output into one file, and other rails log output into another? I tried to probe SemanticLogger[Sidekiq] but can't work out a way to assign it with a different appender (which I thought would be the right thing to do?)

What am I missing? :)

You must be logged in to vote

Correct, by design Semantic Logger writes all log messages to the same file (appenders). This becomes more relevant when you move up to a centralized logging solution so that all the log entries can be alerted on or searched centrally.

If you really want to log to 2 different files, that can be done by using 2 file logging appenders pointing to 2 different files.

On the first log file appender add a filter to exclude all Sidekiq log messages. On the second log file appender add a filter that only includes Sidekiq log messages. https://rocketjob.github.io/semantic_logger/filtering.html

With a single log file it is simple to use grep to include or exclude all Sidekiq messages when viewing t...

Replies: 3 comments

Comment options

Correct, by design Semantic Logger writes all log messages to the same file (appenders). This becomes more relevant when you move up to a centralized logging solution so that all the log entries can be alerted on or searched centrally.

If you really want to log to 2 different files, that can be done by using 2 file logging appenders pointing to 2 different files.

On the first log file appender add a filter to exclude all Sidekiq log messages. On the second log file appender add a filter that only includes Sidekiq log messages. https://rocketjob.github.io/semantic_logger/filtering.html

With a single log file it is simple to use grep to include or exclude all Sidekiq messages when viewing the log files.

Exclude Sidekiq:
grep -v Sidekiq production.log | less -R

Sidekiq only:
grep Sidekiq production.log | less -R

You must be logged in to vote
0 replies
Answer selected by reidmorrison
Comment options

Thanks for clarifying, @reidmorrison. I was just wondering if there was an option I was missing. Nothing wrong with consolidating logs, and I agree it's easy to grep/match based on certain patterns in one log file. It's just that currently our logs are split, so I'm trying to keep things "compatible" if we switch over to SemanticLogger. At least at first. But I don't see any real downside to having them all in one log.

Using the SemanticLogger filters seems awkward to me in this case, and probably adds unnecessary load. So I would just use one log file.

You must be logged in to vote
0 replies
Comment options

I'll close this, since my question was answered. Thanks again @reidmorrison

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

This discussion was converted from issue #59 on January 17, 2022 21:05.

AltStyle によって変換されたページ (->オリジナル) /