wiki:LogViewerPlugin

View the trac.log file via the web frontend

Description

This plugin allows you to view your trac.log logfile without needing shell access to the server, just via the admin interface. You can select to only display messages from a specified log level (e.g. only warnings), as well as optionally including higher levels. So if you select "Debug" and all higher levels, this means the entire log will be displayed. Moreover, you may restrict the output to the latest N lines, and even filter for lines containing a specified string or even matching a regular expression.

Be careful with large log files: use the tail-function to limit the output to the last few lines, because it would otherwise take a long time to display.

You find the Log Viewer on the Admin page in the General section (see below). Having this page called, select the log level you wish to see the entries for, using the drop-down. Optionally, you may chose to display all "higher priority" as well, where "higher" means the entries on top of the one you selected.

You now can further restrict the amount of lines displayed: the Tail input works similar to the tail -f shell command, only showing the last N lines. If you input nothing here, this restriction is skipped, but if you do, the following search will be limited to these lines. In the Search input box you can enter a term which must be found in a line to be displayed. You can also use regular expressions here, in which case you must check the corresponding button. If you additionally check the "not" button, that search will be inverted, ie only lines not containing/matching your search term will be shown.

Hovering your mouse over the input areas shows a tooltip with the meanings.

Once you made your selections, push the button and the matching lines from the trac.log will be displayed.

Here is what it may look like, having selected "Info and above":

Viewing selected log entries

As you can see, the log lines are color-coded: each log level has its distinct color assigned. If you like to change the choice of colors here, you can easily apply your own style sheets. All elements can be identified without problems: the different log levels use classes, and even the other elements of the GUI use classes and ids. Furthermore, in this example you might note that obviously nothing was logged at "Info" level.

A viewer for any log file that resides on the same disk as your Trac project is LogWatcherPlugin.

Bugs/Feature Requests

Existing bugs and feature requests for LogViewerPlugin are here.

If you have any issues, create a new ticket.

defect

3 / 3

enhancement

1 / 2

task

1 / 2

Download

Download the zipped source from here (development version). You can also download the Python Egg of the latest release from this page.

Source

You can check out LogViewerPlugin from here using Subversion, or browse the source with Trac.

Installation

The easiest way to install this plugin is:

# Trac before "localization" started somewhere in 0.11:
pip install svn+https://trac-hacks.org/svn/logviewerplugin/branches/0.11
# Trac versions 0.12 and higher:
pip install svn+https://trac-hacks.org/svn/logviewerplugin/trunk

If you want to be sure to get stable code, you can alternatively use the latest tag, replacing /trunk by e.g. /tags/0.2 (for v0.2). You can also checkout the code from the repository, or download and unpack the zipped source (see above), and then run either easy_install or python setup.py from where the setup.py file resides.

Moreover, you will need to enable the plugin for your Trac environment(s) in your trac.ini file:

[components]
logviewer.* = enabled

Configuration

If you want the LogViewerPlugin to immediately load and show content from your log file without the need to first (fill some form and) push the button, you can do so. With the IniAdminPlugin installed, just call up the logviewer section, and it will explain the details. For everybody else, the details are here:

You need to introduce a new section to your trac.ini file. Using the default settings, it would look like this:

[logviewer]
autoload = false
autotail = 1000
autolevel = 3
autoup = true
autoload
Decides whether you want to turn this feature on (true) or not. By default, it is turned off (false). All the other auto* settings only apply if you set autoload = true.
autotail
Limit LogViewerPlugin to those many lines from the end of the file. Normally, 1000 lines will be enough, but if you want to show everything, simply set it to an empty value as shown below for defaulttail. Keep in mind that a large log file will take some time to display. So keep this value to something reasonable, and do the unusual full display on demand only.
autolevel
Specifies the log level to display, and autoup decides whether higher priority levels, ie those with lower numbers, shall be included:
  • 1 = critical
  • 2 = error
  • 3 = warning (default)
  • 4 = info
  • 5 = debug

If you are not happy with the default presets of the form fields, you can change them for some of the fields:

[logviewer]
defaultlevel = 3
defaultup = true
defaulttail =

The meaning of those three settings corresponds to the similarly named items from the autoload, with the difference that the values here only apply when autoload is disabled.

Recent Changes

17738 by rjollos on 2020-05-12 06:57:04
TracLogViewer 0.4dev: Translate panel name

Refs #13816.

17737 by rjollos on 2020-05-12 06:17:58
TracLogViewer 0.4dev: Fix missing import from r17736

Refs #13816.

17736 by rjollos on 2020-05-12 05:06:57
TracLogViewer 0.4dev: Refactor

Start adapting to Trac 1.4 API.

Refs #13816.

(more)

Author/Contributors

Author: izzy
Maintainer: izzy
Contributors:

Last modified 5 years ago Last modified on May 13, 2020, 10:59:04 PM

Attachments (3)

Download all attachments as: .zip