LogShark Configuration Reference

Configuration of LogShark is done using a text file with a simple custom format. Before being processed all whitespace at the start and end of a line is removed.

Global file structure

Comments

Lines starting with a # are single-line comments.

Directories

Directories are specified by putting their full path on a line. The path may contain spaces.

You can use relative paths but then you have to make sure you start LogShark in the correct directory.

Files

A filename pattern must follow a directory or another filename pattern. It must start with a dash or an equals sign followed by a space.

The lines of files matching a pattern with a dash as the prefix are not wrapped, with an equals sign as the prefix the lines are wrapped.

The pattern is a regular expression with a number of custom tokens. The custom tokens start and end with a colon. The following tokens are available:

:year:
the current year
:month:
the current month without leading zeros
:month-lz:
the current month with leading zeros
:day:
the current day without leading zeros
:day-lz:
the current day with leading zeros

Global options

Global options are specified before directory paths and file patterns. Their lines start with an asterisk and a space. These are followed by the option name, an equals sign and its value.

Window title

When running multiple LogShark instances it is difficult to distinguish them because they use the same window title. To make it easier to determine which LogShark shows which logs you can specify the window title suffix in the configuration:

* title = MyServer 1.03

Font

If you don't like the default font and/or its size you can change the font by specifying another using font. The option must be followed by the font name. After the font name you can specify the optional font size. Separate the values using a comma. Empty values are not allowed. Whitespace at the start and end of a value is allowed and will be considered not to be part of the value:

* font = Arial,10

Window position

You can specify the position of the LogShark window borders or maximize the window. The window border positions are specified using position. The value consists of the four distances to the screen edge separated by commas in this order: left, top, right and bottom. The distances are specified in percentages of the width and height from the respective edge:

# 10% of screen width from left edge
# 10% of screen height from top edge
# 50% of screen width from right edge
# 50% of screen height from bottom edge
* position = 10, 10, 50, 50

If you prefer to use a maximized window use maximized instead. This option takes precendence over position:

* maximized = true

Display

If you have multiple monitors you can make LogShark appear on the monitor you want by specifying display:

* display = \Display1

The values to use after display are platform-specific. To get a list of valid values append an exclamation mark after display and enter a dummy value. LogShark will display the valid values for your environment in a dialog:

* display! = x

Look and feel

By default LogShark will use the default look and feel of the platform on which it is running. If you want to use another look and feel add the option lookAndFeel and use the name of the look and feel for the value:

* lookAndFeel = Metal

Just like with display you can get LogShark to display a list of valid look and feel names by appending an exclamation mark and entering a dummy value:

* lookAndFeel! = x

You must make sure the JAR files of the look-and-feel that you want to use are on the class path with which LogShark is started.

Directory options

Directory options are specified directly below the directory paths and before the file patterns. They start with a backslash instead of an asterisk.

Directory identification by color

LogShark always assigns a number to a directory and displays a directory number on the tabs of files, so you can easily identify in which directory a file is stored. If you need quicker identification of in which directory a file is stored, you can assign colors to directories. The specified color will be used as the background color of the directory label at the top, and a circle in the same color will be added to file tabs. The color is specified in hexadecimal RGB format:

\ color = FFCC66

Recursive scanning

By default subdirectories are ignored. If you want LogShark to also scan subdirectories add the recursive option:

\ recursive = true

File pattern options

File pattern options are specified directly below the file patterns. Just like directory options they start with a backslash.

Pattern case sensitivity

Normally filenames are matched with case sensitivity enabled. If you want to match filenames with case sensitivity disabled, add option caseInsensitive:

\ caseInsensitive = true

Encoding

LogShark will read files in the encoding of your platform by default. If you want to monitor files that use a different encoding, you can add the encoding option:

\ encoding = UTF-8

Age of modification

If you have lots of log files in a directory and only some have been modified recently it can be cumbersome to have all files open. By adding the modifiedWithin option you can specify that only files that have been modified within a specified period must be shown. The format of the value is: n h n m n s. Where h, m and s stand for hours, minutes and seconds respectively. If one of the values is zero you can omit it, but you must specify the values in this order. Whitespace between the values and the unit letters is ignored:

\ modifiedWithin = 2 h15s

Keeping tabs of disappeared files

To keep the LogShark window from being filled with tabs when filenames of logs change a lot, LogShark will close tabs for files that no longer exist. If you want to inspect the contents of a log file after it has disappeared you can add the option keepOpenIfDisappears. You can close the tab yourself once you are finished with it:

\ keepOpenIfDisappears = true

If you use this option and a file disappears, a dash will be appended to the tab of the file to indicate that the file no longer exists.

File identification by color

In addition to being able to specify a color for all files stored in a directory, you can also specify a color for all files matching a file pattern. If you specify a color for a file pattern a circle in this color will be added to the tabs of files:

\ color = FFCCFF

Line filters

This is an advanced option which allows you to specify which lines must appear in the tab and which lines must be hidden. In addition you can specify the foreground and background colors for lines that are shown.

WARNING: this option requires more memory and can require lots of CPU time, especially when monitoring huge log files. Read the instructions below carefully, especially the regular expression tip about performance, and test your configuration files before you use them in a production environment.

Line filters are specified using option visibility. There are three types of filters: show, hide and highlight. You can specify multiple filters per file pattern. Each line will be matched against all filters in the order the filters where specified. The last matching filter determines how the line must be treated.

The default list of filters for all file patterns is shown below. This will display all lines in the default colors. The filters you specify will be appended to this list:

\ visibility=show:.?

Filter types

The show filter will display lines that match its regular expression:

\ visibility = show:ERROR

The hide filter will hide lines that match its regular expression:

\ visibility = hide:DEBUG

The highlight filter will display lines that match its regular expression, and you can specify the background and optionally the foreground color for a line:

# Show lines containing 'WARNING' using an orange background
\ visibility = highlight,FF9966:WARNING
# Show lines containing 'ERROR' using white letters on a red background
\ visibility = highlight,FF0000,FFFFFF:ERROR

Regular expression tips

Because the colon is used as a separator between the filter type and the regular expression you cannot use a colon directly in the regular expression. If you have to match a colon use \x3A:

\ visibility = show:ERROR\x3A

The lines are matched with case sensitivity. If you want to match lines using case insensitivity prepend (?iu) to your regular expressions:

\ visibility = highlight,FF0000,FFFFFF:(?iu)error

Because lots of regular expression matches have to be performed (for each file: the number of lines × the number of line filters), it is necessary to match as little as possible to make sure performance remains acceptable. For example, the following two lines have the same effect, but the second one is more expensive:

\ visibility = show:.?
\ visibility = show:.*

So always try to match the smallest possible fragment of a line. If a fragment always appears at the start or end of a line, then the use of the start-of-line (^) and end-of-line ($) markers will also speed up line matching.

Line filters example

The example below will only show lines containing INFO:, WARNING: or ERROR:. The lines containing WARNING: or ERROR: will be displayed using a different color. The default filter is included, but commented out, so the full list of filters that is used is shown:

# Default filter
# \ visibility=show:.?
# Not interested in all the other lines
\ visibility=hide:.?
# Show lines containing 'INFO:'
\ visibility=show:INFO\x3A
# Give warnings an orange background
\ visibility=highlight,FF9966:WARNING\x3A
# Show errors in white letters on a red background
\ visibility=highlight,FF0000,FFFFFF:ERROR\x3A

Full configuration example

Here is an example configuration file showing many of the configuration options:

# LogShark configuration for MyServer instance at C:\MyServer-1.03
* title = MyServer 1.03
* font = Lucida Console, 12

# The directory containing the server logs
C:\MyServer-1.03\logs
\ recursive = true
# Today's request log
- request-:year:-:month-lz:-:day-lz:\.log
\ keepOpenIfDisappears = true

# The directory containing the logs for the Foo application
C:\MyServer-1.03\apps\Foo\logs
# Mark files in this directory with a green circle
\ color = 99FF99
# The Foo application clears its log on every restart and puts the
# time in the filename. Regular expression are used to match any
# file with a certain prefix
# The lines of these files will be wrapped
= foo-errors-.+\.log
# Only display if modified within the last 2 and a half hours
\ modifiedWithin = 2h 30m

# The directory containing the logs for the Bar application
C:\MyServer-1.03\apps\Bar\logs
  # The Bar application uses a log with a fixed name
  - bar-application\.log
  \ encoding = UTF-8
  # Mark files matching this pattern with a blue cirle
  \ color = CCCCFF

Visit the project page of LogShark at SourceForge.net: