-2

On a development server, I'd like to turn logging on only when needed for specific debugging operations. One way I can think of is Apache checks for the existence of certain dotfile somewhere and decides no a SetEnvIf dontlog variable value based on that. How would I configure this or is there a more optimal way?

I'd like to avoid a full-server reload to toggle this switch.

5
  • You mean like a .htaccess file?
    – GregL
    Jun 11, 2015 at 14:37
  • This doesn't meet your stated requirements, but I wanted to make sure you had heard about graceful restart httpd.apache.org/docs/2.2/stopping.html#graceful
    – sa289
    Jun 11, 2015 at 23:28
  • @sa289 I am aware about the graceful restart, which is why I said "reload" instead of "restart". But this still does a lot of things to apps running i.e. reloading their states as well. Does too much for my liking.
    – lkraav
    Jun 12, 2015 at 12:41
  • @GregL yes, .htaccess is of course an option, but is there anything more performance-optimal? .htaccess has a lot of logic behind it. Wouldn't checking for a single, single-purpose, specific file name or a similar technique be a lot faster?
    – lkraav
    Jun 12, 2015 at 12:44
  • I don't think the existence of a .htaccess would be much of a performance issue seeing as how Apache is looking for them anyway.
    – GregL
    Jun 12, 2015 at 12:46

2 Answers 2

2

You have the possibility to pipe logs to a program when using CustomLog. An example usecase would be log rotation, as desribed here: rotatelogs

Depending on your skills, you could write a custom logger which would only log under whatever critera you desire.

The benefit here would be, that you wouldn't have to restart or reload Apache at all.

Here a more general description of piped logging: piped logs

1

You can use the third argument of the CustomLog directive to specify a condition which determines whether or not to log that request.

The third argument can be an environment variable or as of Apache 2.4 it can be an expression (like checking HTTP_COOKIE).

1
  • @lkraav I hope you were able to get your issue resolved. If my answer was helpful to you, I'd appreciate if you could mark it as accepted so I can get credit for it. Thanks
    – sa289
    Jul 13, 2015 at 20:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .