Description
If your bug is about how AppSignal works in your app specifically we recommend you contact us at [email protected] with your bug report instead.
Describe the bug
Appsignal does not accept log messages that arrive as a non-String and are formatted into a String. Instead, it triggers the "Logger message was ignored, because it was not a String" in the appsignal internal logger.
Specific example: Sidekiq::LogstashJobLogger (from sidekiq-logstash) feeds a Hash into the logger, and Sidekiq::Logging::LogstashFormatter converts that to a string. However, since cd2f9fb, the check whether the message is a String happens before the message is formatted, not after (see lib/appsignal/logger lines 76-83).
If the two lines were reversed, the JSON would be accepted by Appsignal, and it would show the various key-value pairs as attributes.
To Reproduce
(Please see https://github.com/andreaswachowski/appsignal_reproduction/blob/main for a working reproduction.)
In brief: Create a Rails application with the Gems
- appsignal
- sidekiq
- sidekiq-logstash
And a config/initializer/sidekiq.rb
including
Sidekiq::Logstash.setup
Sidekiq.configure_server do |config|
appsignal_logger = Appsignal::Logger.new('sidekiq', format: Appsignal::Logger::JSON)
appsignal_logger.formatter = Sidekiq::Logging::LogstashFormatter.new
appsignal_logger.broadcast_to(config.logger)
config.logger = appsignal_logger
# ... (more configuration)
end
Create a trivial Sidekiq job
class HelloWorldJob < ApplicationJob
queue_as :default
def perform(*args)
nil
end
end
and, while Sidekiq is running on a different terminal, execute it from the Rails console with HelloWorldJob.perform_later
. The Sidekiq terminal shows the log message
{"severity":"INFO","retry":true,"queue":"default","wrapped":"HelloWorldJob","args":[{"job_class":...
log/appsignal.log
includes
[2025-06-04T14:21:16 (process) #74631][WARN] Logger message was ignored, because it was not a String: {"retry" => true, "queue" => "default", "wrapped" => "HelloWorldJob", "args" => [{"job_ ...
Edit: Initialize the formatter directly on the appsignal_logger
. Otherwise, the formatter is nil
, and hence the formatting wouldn't happen even if the suggested fix is applied. This simply fixes the reproduction, it doesn't change the core problem.