12 | | '''file''':: Log messages to a file, specified with the `log_file` option in [wiki:TracIni trac.ini]. |
13 | | '''stderr''':: Output all log entries to console ([wiki:TracStandalone tracd] only). |
14 | | '''syslog''':: (UNIX) Send messages to local syslogd via named pipe `/dev/log`. |
15 | | '''eventlog''':: (Windows) Use the system's NT eventlog for Trac logging. |
| 13 | '''file''':: Log messages to a file, specified with the [TracIni#logging-log_file-option "[logging] log_file"] option. Relative paths for `log_file` are resolved relative to the environment `log` directory. |
| 14 | '''stderr''':: Output log entries to console ([TracStandalone tracd] only). |
| 15 | '''syslog''':: (UNIX) Send log messages to the local syslogd via named pipe `/dev/log`. By default, syslog will write them to the `/var/log/messages` file. |
| 16 | '''eventlog''':: (Windows) Use the system's NT Event Log. |
| 28 | Additionally, you can enable logging of SQL statements at debug level. This is turned off by default, as it's very verbose. Set [TracIni#trac-debug_sql-option "[trac] debug_sql = yes"] to activate. |
| 29 | |
| 30 | == Log Format |
| 31 | |
| 32 | The output format for log entries can be specified in the [TracIni#logging-log_format-option "[logging] log_format"] option. The format is a string which can contain any of the [https://docs.python.org/2/library/logging.html#logrecord-attributes Python logging Formatter variables]. Additionally, the following Trac-specific variables can be used: |
| 33 | '''$(basename)s''':: The environment directory name. |
| 34 | '''$(path)s''':: The absolute path of the environment directory. |
| 35 | '''$(project)s''':: The originating project's name. |
| 36 | |
| 37 | Note that variables are identified using a dollar sign (`$(...)s`) instead of percent sign (`%(...)s`). |
| 38 | |
| 39 | The default format is: |
| 40 | {{{#!ini |
| 41 | log_format = Trac[$(module)s] $(levelname)s: $(message)s |
| 42 | }}} |
| 43 | |
| 44 | In a multi-project environment where all logs are sent to the same place (e.g. `syslog`), it makes sense to add the project name. In this example we use `basename` since that can generally be used to identify a project: |
| 45 | {{{#!ini |
| 46 | log_format = Trac[$(basename)s:$(module)s] $(levelname)s: $(message)s |
| 47 | }}} |
| 48 | |