Skip to content
pkorotkov edited this page Feb 12, 2012 · 21 revisions

File

Function: Writes received messages to a file

Element name: File

Allowed attributes:

  • formatid - format that will be used by this receiver
  • path - path to the log file

Example:

<seelog>
    <outputs>
        <file path="log.log"/>
    </outputs>
</seelog>

Console

Function: writes received messages to std out

Element name: console

Allowed attributes:

  • formatid - format that will be used by this receiver

Example:

<seelog>
    <outputs>
        <console/>
    </outputs>
</seelog>

Rolling file writer (or "Rotation file writer")

Function: writes received messages to a file, until date changes or file exceeds a specified limit. After that the current log file is renamed and writer starts to log into a new file. If you roll by size, you can set a limit for such renamed files count, if you want, and then the rolling writer would delete older ones when the files count exceed the specified limit.

Element name: rollingfile

Allowed attributes:

  • formatid - format that will be used by this receiver

  • filename - path to the log file. On creation, this path is split into folder path and actual file name. The latter will be used as a common part for all files, that act in rolling:

    • In case of 'date' rolling, the file names will be formed this way:
       time.LocalTime().Format(rollFileWriter.datePattern)+" "+rollFileWriter.fileName)
    • In case of 'size' rolling, the file names will be formed this way: "filename.#". For example: app.log, app.log.1, app.log.2, app.log.3, ...
  • type - rotation type: "date" or "size"

  • maxrolls - an attribute used only with type="size". Maximal count of renamed files. When this limit is exceeded, older rolls are removed. Should be >= zero.

  • maxsize - an attribute used only with type="size". This is the size limit (in bytes) exceeding which results in a roll.

  • datepattern - an attribute used only with type="date". This is the pattern that would be used in 'time.LocalTime().Format' to form a file name. The "date" (actually, this means both date & time) rolling occurs when 'time.LocalTime().Format(rollFileWriter.datePattern)' returns something different than the current file name. This means that you create daily rotation using a format with a day identifier like "02.01.2006". Or you can create an hourly rotation using a format with an hour identifier like "02.01.2006.15".

Important: Do not use any special symbols that are not allowed in filenames.

Example:

<seelog>
	<outputs>
		<rollingfile type="size" filename="logs/roll.log" maxsize="1000" maxrolls="5" />
	</outputs>
</seelog>
<seelog>
    <outputs>
        <rollingfile type="date" filename="logs/roll.log" datepattern="02.01.2006" />
    </outputs>
</seelog>

Buffered writer

Function: acts like a buffer wrapping other writer. Buffered writer stores data in memory and flushes it every flush period or when buffer is full.

Element name: buffered

Allowed attributes:

  • formatid - format that will be used by this receiver
  • size - buffer size (in bytes)
  • flushperiod - interval between buffer flushes (in milliseconds)

Example:

<seelog>
    <outputs>
        <buffered size="10000" flushperiod="1000">
            <file path="bufFile.log"/>
        </buffered>
    </outputs>
</seelog>
<seelog>
    <outputs>
        <buffered size="10000" flushperiod="1000" formatid="someFormat">
            <rollingfile type="date" filename="logs/roll.log" datepattern="02.01.2006" />
        </buffered>
    </outputs>
    <formats>
        ...
    </formats>
</seelog>

NOTE: this writer accumulates data written using a specific format and then flushes it into the inner writer. So inner writers couldn't have its own format: set 'formatid' only for buffered element, like in the last example.

Clone this wiki locally