-
Notifications
You must be signed in to change notification settings - Fork 324
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
Allow logs to be redirected to /dev/null #1154
Allow logs to be redirected to /dev/null #1154
Conversation
💚 CLA has been signed |
25bbcb3
to
95a7e30
Compare
|
||
if(!logFile.equalsIgnoreCase("/dev/null")) { | ||
System.out.println("Writing Elastic APM logs to " + logFile); | ||
} | ||
|
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.
Although this isn't very elegant, it seems to be the only way to retain the actual behavior while making the agent completely silent in case of /dev/null
.
You might be happy to hear that we're experimenting with some things regarding logging here. Out of curiosity, why can't just log to a file and ignore it? That way you at least have the option to manually look at the file if you need to. |
We tried with logging to a file first, but for instance, in case of errors, the agent logs a huge amount of messages. So the fear is, that this may silently flood our storages. Actually, the problem why it refuses to log to /dev/null is simply the writeable check on the parent directory, which for instance would also prevent you to log into a file you are allowed to write to, but if the directory is for instance not writeable. We are currently facing the problem, that our OPs department want's us to shut down all agents if we don't get the logging right or silence to agent at all. That's why I would really appreciate it if we could allow logging to /dev/null as a workaround until some more sophisticated solution is available. |
Btw, I just found a combination of directory/file permission where the MR fails, so I will push a fix together with a list of tested combinations (dir exists/writeable/file exists/writeable within the next hours). |
This is also something we're tackling. You'll be able to configure a max log file size. In the meantime, I think your fix can't do harm. |
Nice, thank you 🎉 I'll ping you when I finished testing all possible combinations and updated the pull requests description. |
95a7e30
to
ae1a33b
Compare
@felixbarny I just double-checked all possible combinations of directory/file existence/writeability and wrote them down in the pull requests description under |
@msievers Thanks! Your permissions-result matrix in the Author's checklist is 👍 @felixbarny I think this wouldn't work with the new logging we are about to add - since we are going to use rolling logs and the state file, the directory probably needs to be writeable. |
@msievers we discussed that - while your solution works great now, we are soon to introduce a very useful enhancement to the agent logging that will rely on the directory being writeable. However, what you really need is a silent agent, so let's do that 🙂. We thought of adding an |
@eyalkoren Sure, I can give it a try. I think I can report back by the end of the week 👍 |
@eyalkoren I couldn't keep my fingers from this and created a new PR to add |
What does this PR do?
The documentation of the APM agent states that the logging output can be redirected to a file. Currently, this does not work when specifying
/dev/null
to silence the APM logs completely. When trying to do so, the agent complains withChecklist
I have made corresponding changes to the documentationI have added tests that prove my fix is effective or that my feature worksI have updated supported-technologies.asciidocAdded an API method or config option? Document in which version this will be introducedAdded an instrumentation plugin? How did you make sure that old, non-supported versions are not instrumented by accident?Author's Checklist
/dev/null
)Related issues
Use cases
There are companies that have very strict requirements regarding application logs/log formats which may prevent the usage of Elastic APM agent, because there is currently no way, to configure/alter the log format, for example to output JSON.
As a workaround, it should be possible to silence the APM agent by redirecting its logs to
/dev/null
.Screenshots