Edgewall Software
Modify

Opened 11 years ago

Closed 9 years ago

Last modified 8 years ago

#11216 closed enhancement (duplicate)

[PATCH] Make syslog facility and socket configurable

Reported by: Sebastian Klemke <packet@…> 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 Ryan J Ollos)

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)

syslog.patch (2.9 KB ) - added by Sebastian Klemke <packet@…> 11 years ago.
Patch to add log_socket and log_facility options. Applies to trunk@11822
logging_config.patch (6.2 KB ) - added by Sebastian Klemke <packet@…> 11 years ago.
Patch introducing logging.config support. Applies to source:trunk@11822
logging.ini (331 bytes ) - added by Sebastian Klemke <packet@…> 11 years ago.
Example log configuration

Download all attachments as: .zip

Change History (12)

by Sebastian Klemke <packet@…>, 11 years ago

Attachment: syslog.patch added

Patch to add log_socket and log_facility options. Applies to trunk@11822

comment:1 by Christian Boos, 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 Sebastian Klemke <packet@…>, 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.

Last edited 8 years ago by Ryan J Ollos (previous) (diff)

by Sebastian Klemke <packet@…>, 11 years ago

Attachment: logging_config.patch added

Patch introducing logging.config support. Applies to source:trunk@11822

by Sebastian Klemke <packet@…>, 11 years ago

Attachment: logging.ini added

Example log configuration

comment:3 by Sebastian Klemke <packet@…>, 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 Sebastian Klemke <packet@…>, 11 years ago

Concerning RotatingFileHandler: I doubt it would work with multiple mod_wsgi processes.

Last edited 9 years ago by Ryan J Ollos (previous) (diff)

comment:5 by Christian Boos, 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 Ryan J Ollos, 9 years ago

Keywords: patch added

comment:7 by Ryan J Ollos, 9 years ago

Description: modified (diff)
Keywords: bitesized added

comment:8 by Ryan J Ollos, 9 years ago

Keywords: bitesized removed
Milestone: next-dev-1.1.x
Resolution: duplicate
Status: newclosed

Closing as a duplicate of #7820. A note has been added to #7820 to investigate the integration of the patches in this ticket.

in reply to:  3 comment:9 by Ryan J Ollos, 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 option log_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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.