-
-
Notifications
You must be signed in to change notification settings - Fork 136
logging into different files #201
-
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? :)
Beta Was this translation helpful? Give feedback.
All reactions
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
-
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
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
I'll close this, since my question was answered. Thanks again @reidmorrison
Beta Was this translation helpful? Give feedback.