-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Switch to Lager for logging #491
Conversation
Fixes #94 . |
Spend most time trying to make tests with old config working too support same behaviour. |
7a1e7f9
to
1cdf814
Compare
Erlang unit tests fail with
Other test suites pass. |
Created pull request for test branch |
{lager, [ | ||
%% Lager application config to control logs. | ||
%% See https://github.com/basho/lager for more documentation | ||
%% Log direcrory. Loads authomaticaly from RABBITMQ_LOG_BASE variable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be automatically
|
@michaelklishin I don't have any errors with |
@@ -118,6 +118,7 @@ start_rabbitmq_server() { | |||
-sasl sasl_error_logger "$SASL_ERROR_LOGGER" \ | |||
-rabbit error_logger "$RABBIT_ERROR_LOGGER" \ | |||
-rabbit sasl_error_logger "$RABBIT_SASL_ERROR_LOGGER" \ | |||
-rabbit log_base "\"$RABBITMQ_LOG_BASE\"" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we add this in rabbitmq-server
, we need to do the same in rabbitmq-server.bat
.
I tested the branch on Windows and it works fine with the default settings, including log rotation. However, logging to stdout is broken. You can test with:
In
Lager complains with the following message:
Note that, on Windows, this depends on a patch I didn't commit yet ( This could be specific to Windows though. I will test on FreeBSD once the profiling of lazy queues is finished (erlgrind is already running for almost three hours...) |
Fixing TTY logging is the only thing that's left, it seems. |
I'm starting to look at this. |
The problem with TTY is only present on Windows. It works as expected on Unix. |
Apparently, this is a known limitation: It's not a regression as it was impossible to enable console logging on Windows anyway. I'm testing a few more things but this branchs looks ready to be merged. My concern about the |
We can't override the log file locations anymore using the environment variables, if lager is configured in |
@dumbbell priority of |
I agree it's more flexible and powerful. However, I find it handy if I can just set |
I still have a few things I would like to fix before merging this branch:
|
Or as an option we can configure |
Using Lager directly will break a lot of plugins. Lets hold off on that and do it for 3.8. |
As for deprecating |
@hairyhum: That's interesting! I will look at that. |
@dumbbell no objections to that. |
@dumbbell it's mentioned in sinks doc section https://github.com/rabbitmq/lager#sinks |
Here is what I propose to fully use Lager and its features, while still maintaining compatibility for those using
Let's try to sum up this with a simple drawing of the default configuration:
Now, about categories.
Let's expand the previous drawing:
Admittedly, this is more complicated to configure than what we have currently, but it's also way more powerful. Lager allows finer-grain control of the log levels: instead of a bare minimum, it supports masks and ranges. |
So the extra sinks would be used to allow for finer-grained configuration of things we currently allow to configure. That sounds reasonable to me. As does respecting Should |
There is nothing RabbitMQ-specific in it and currently, it lives in rabbitmq-common (where rabbit_log and rabbit_lager should probably go). We could even ship it separately. |
Fair enough. |
34b80ae
to
b64e673
Compare
I just pushed the proposed patch so you can read the code and test if you want. |
I have one test failure:
(with rabbitmq-test switched to |
I didn't update the testsuite yet. I want to make sure the behavior is what we want first. |
That said, I should commit |
@dumbbell I still have the test failure but otherwise no objections to your plan. |
Thanks, I will update the testsuite, then. |
The testsuite is up-to-date so this issue is ready for a final test :-) |
With a few more tweaks in the We should also cut a milestone release after the dust from this change settles. |
aa80925
to
196753a
Compare
By default, RabbitMQ now logs messages to a single file ($RABBITMQ_LOGS). The $RABBITMQ_SASL_LOGS variable is unused. To configure how and which messages are logged, it's recommended to do it from rabbitmq.config, not from the environment variable. The old `log_levels` parameter is unsupported and categories are replaced by Lager extra sinks. If you had in your rabbitmq.config: {rabbit, [ {log_levels, [{connection, info}]} ]} You can now configure Lager like this: {lager, [ {extra_sinks, [ {rabbit_connection_lager_event, [ {handlers, [{lager_forwarder_backend, [lager_event, info]}]} ]} ]} ]} rabbitmq-build.mk from rabbitmq-common is included in the top-level Makefile. It sets the appropriate compiler options to enable Lager's lager_transform parse_transform module. rabbit_log calls are now converted by this parse_transform to direct calls to lager:log(). To keep backward compatibility with other plugins, the rabbit_log module still implements all the <level>() functions. Compared to the parse_transformed calls, the main difference is the logged message does not carry the file:line metadata. Fixes #94.
196753a
to
670d986
Compare
Tried to make lager work with all default logging locations and settings.
Log rotation have 2 sec sleep now to let lager finish all writes to old file and open a new one.
Support for configuring lager from
.config
, so it's not overwritten by default rabbit config.Need review