You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using SM for many years, and that's the first time I have issues, and I think they come from SolidQueue thread model or something.
Ok, the problem is SM prints only part of logs: from SolidQueue (supervisor?) but not from the job processing code.
My job class:
moduleJobs# Base is an ActiveJob::Base subclass, nothing fancyclassGenerateIdeas < Basequeue_as:defaultdefperform(category_id)putslogger.class.name# SemanticLogger::Logger <- ok here# Returns <SemanticLogger::Appender::IO:0x000000012d18d2a0# I believe that is the configured oneputsSemanticLogger.appenders.inspectputsSemanticLogger.appenders.count# 1logger.fatal("STARTING JOB")# nothingendendend
After some time of double-checking everything I found workaround: an attempt to re-add $stdout appender resets something, and fix logging:
moduleJobsclassBase < ActiveJob::Basebefore_perform:fix_logging_v4_17deffix_logging_v4_17# This logs error (attempt to add another console logger) but forces SM to workSemanticLogger.add_appender(io: $stdout,formatter: :color)endendend
The log message about this dirty hack appears, but at least this works :)
There's even worse hack: call SemanticLogger#sync!.
Thank you for your work!
The text was updated successfully, but these errors were encountered:
Does someone in the community that uses Active Job have a solution they want to submit as a PR?
Or, even just submit a PR with a failing test for the above scenario?
2 small cents from me.
I'm not sure it is fully on SemanticLogger side.
After I switched for test purposes to Sidekiq from SolidQueue, I'm able to see log entries. So maybe it is SolidQueue that passes logger object down to job (thread) in a way that is incompatible with SemanticLogger.
Environment
Provide at least:
Rails configuration:
Expected Behavior
Log to $stdout
Actual Behavior
I've been using SM for many years, and that's the first time I have issues, and I think they come from SolidQueue thread model or something.
Ok, the problem is SM prints only part of logs: from SolidQueue (supervisor?) but not from the job processing code.
My job class:
Log dump:
This code works, but that is not what we all want :)
After some time of double-checking everything I found workaround: an attempt to re-add $stdout appender resets something, and fix logging:
The log message about this dirty hack appears, but at least this works :)
There's even worse hack: call
SemanticLogger#sync!
.Thank you for your work!
The text was updated successfully, but these errors were encountered: