#11216 closed enhancement (duplicate)
[PATCH] Make syslog facility and socket configurable
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | general | Version: | |
Severity: | normal | Keywords: | syslog patch |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description (last modified by )
To filter trac log entries and store them in a separate log file with syslog-type logging, the syslog facility must be configurable. Otherwise, trac log entries cannot be distinguished from other log entries using the same facility. Using file-type logging is not an option for me, as I don't know how to safely rotate the resulting log files.
Therefore, I wrote a patch to configure the syslog facility and the syslog socket using the new options log_facility
and log_socket
for syslog-type logging. log_facility
is needed to distinguish trac log entries from other application's log entries. log_socket
is needed for operating systems where the syslog socket is not named /dev/log
.
Attachments (3)
Change History (12)
by , 11 years ago
Attachment: | syslog.patch added |
---|
comment:1 by , 11 years ago
Have you investigated if and how it would be possible to pass this extra information via the logging.config module? Given that beyond the basics, the logging
module can be configured in a very extensive way, I think it would make more sense to offer this extra level of configuration via a dedicated configuration file rather than by extending the Trac logging API itself.
Besides, another possibility for you would be to specify the use of a RotatingFileHandler (also via this logging.config
file).
comment:2 by , 11 years ago
Thank you for your feedback. I did not investigate this option, but will try if time permits. It seems that another trac patch is required to use logging.config. I will try to implement logging.config as a new log_type
with a log_config
option for the filename of the config file and see what can be done with it.
by , 11 years ago
Attachment: | logging_config.patch added |
---|
Patch introducing logging.config support. Applies to source:trunk@11822
follow-up: 9 comment:3 by , 11 years ago
I wrote another patch adding logging.config support. It adds a new log_type
config
and a new option log_config
for the configuration file. The patch has some rough edges:
- It prevents environment initialization if configuration file is missing or defective
- I had to remove the _trac_handler attribute from the logger (seems to be unused)
- There seems to be no way of determining the used handler. Therefore I return None for the handler, effectively preventing flush() in Environment.shutdown()
- Keyword substitution of $(path)s, $(basename)s and $(project)s is not possible for the new log type
config
comment:4 by , 11 years ago
Concerning RotatingFileHandler: I doubt it would work with multiple mod_wsgi processes.
comment:5 by , 11 years ago
Milestone: | → next-dev-1.1.x |
---|
Looks like good start! Unfortunately I won't be able to review your patch until end of next week, so I'd welcome any other TracTeam member to pick it up from there.
comment:6 by , 10 years ago
Keywords: | patch added |
---|
comment:7 by , 10 years ago
Description: | modified (diff) |
---|---|
Keywords: | bitesized added |
comment:8 by , 9 years ago
Keywords: | bitesized removed |
---|---|
Milestone: | next-dev-1.1.x |
Resolution: | → duplicate |
Status: | new → closed |
comment:9 by , 8 years ago
Replying to Sebastian Klemke <packet@…>:
I wrote another patch adding logging.config support. It adds a new
log_type
config
and a new optionlog_config
for the configuration file. The patch has some rough edges:
Patch is being integrated as part of #7820, but I thought it appropriate to reply to these comments.
- It prevents environment initialization if configuration file is missing or defective
The exception handling path is the same as for the Environment needs upgrade error. I considered trapping the exception in Environment.setup_log, but we'd have to choose a default logger in that case and the proper choice isn't clear to me. Alternatively we could try to trap the exception and add a warning to the request, but the changes look fairly extensive and I'm not sure it's worth the effort. Feedback welcome.
- I had to remove the _trac_handler attribute from the logger (seems to be unused)
- There seems to be no way of determining the used handler. Therefore I return None for the handler, effectively preventing flush() in Environment.shutdown()
From a cursory glance at the Python source, it looks like the loggers are held in WeakValueDictionary
, which I assume is so they get automatically cleaned up.
- Keyword substitution of $(path)s, $(basename)s and $(project)s is not possible for the new log type
config
I made some modifications in #7820 so that the keyword substitution is handled for log type config
.
Patch to add log_socket and log_facility options. Applies to trunk@11822