-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show logger name in log message per default #24
Comments
Yea no problem... you can't do it right now, but I'll let you know when I have it working. |
Thank you Rudi for letting me know! Looking forward to this feature 👍 |
Thanks! |
@rudionrails I wanted to ask if it would it be possible to create a new tag for this feature? |
Hello @rudionrails! Thanks for creating the new tag! I still have a question. On command line this works just fine: logger = Yell.new STDOUT, :format => "%N %m" logger.name = "LOGGER_NAME" logger.info "Hello World!" However I'm not sure how to add the format in my project since there I use the 'block' approach: log = Yell.new do |logger| logger.name = name ... end How do I set the format correctly in this 'block' approach? |
Hi, you can simply do: logger = Yell.new do |logger|
logger.name = name
# Since Yell allows to use a multitude adapters, you set the format on a pre-adapter basis
logger.adapter STDOUT, format: "%N %m"
end |
Hi Rudi! I see now yes that seems to work indeed for logging into a file! I already tried this out before and only checked the result on the graylog server, since I thought in this way (format: "%N %m") the name of the logger would be automatically appended to the log message itself. That however doesn't seem to be the case and on the log server there is only the message without the name in it. Do you have any ideas if this is a graylog2 issue or if this is an issue that can be handled within the yell-adapters-gelf gem? |
I think this is the way to do it via gelf: I can just define an additional key to the adapter lets call it "name" and then pass the name of the logger. Then create an additional field in graylog2 that show me the name. |
Hi, for now, you'd have to pass additional keys like so: logger = Yell.new do |l|
l.adapter :gelf
end
# Any additional keys starting with an underscore (_) will be recognized by Graylog2
logger.info "Hello World", _name: "Name of the logger"
# Also... you could use the Graylog2 `:facility` as your logger's name
logger = Yell.new do |l|
l.adapter :gelf, facility: "Name of the logger"
end
logger.info "Hello World" |
I see I would have to append it directly to to the info/warning/error... message. Yes the facility that would be also an idea to use that, it is just currently I'm using this for "another" purpose. The best for me would be to be able to set this additional message in a centralized way like this : logger.adapter :gelf, :host => '192.168.65.144', :port => 12201, :facility => DAEMON_NAME + curr_env, "_logger_name" => name So that "_logger_name" would apply to all messages. |
I can create a logger like this
Now I was wondering if there is a possibility to set the logger name in front of every log message in this configuration so that the name is automatically added to every log message?
I'm not sure this might be a stupid question, but I couldn't find a way to do that.
thanks
The text was updated successfully, but these errors were encountered: