Skip to content
dmitrybond edited this page Nov 25, 2012 · 21 revisions

File writer

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 writer

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".

  • archivetype - an attribute used to specify the type of the archive where old rolls are stored instead of removal. Possible values: "none", "zip". If set to "none", no archivation is performed (old rolls are just deleted).

  • archivepath - an attribute used when archivetype is not set to "none". Specifies the path of the archive where old rolls are stored.

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.

SMTP writer

Function: Sends emails to the specified recipients using a password-protected (but generally unsecured) email account at a given post server.

Element name: smtp

Allowed attributes:

  • senderaddress - email address of the sender
  • sendername - name of the sender
  • hostname - host name of a post server (typically - mail.XXX.YYY)
  • hostport - TCP port of the post server (typically - 587)
  • username - user name used to login to the post server
  • password - password to the post server

Subelement: recipient

Allowed attributes:

  • address - email address of the recipient (who receives messages from notifiers)

Example:

<seelog>
  <outputs>
   <smtp senderaddress="noreply-notification-service@none.org" sendername="Automatic notification service" hostname="mail.none.org" hostport="587" username="nns" password="123">
    <recipient address="john-smith@none.com"/>
    <recipient address="hans-meier@none.com"/>
   </smtp>
  </outputs>
 </seelog>
<seelog>
  <outputs>
   <filter levels="error,critical">
    <smtp senderaddress="nns@none.org" sendername="ANS" hostname="mail.none.org" hostport="587" username="nns" password="123">
     <recipient address="hans-meier@none.com"/>
    </smtp>
   </filter>
  </outputs>
 </seelog>

NOTE 1: Look at the first above example to get an idea of how to use SMTP writer. Keep in mind that email noreply-notification-service@none.org must not be considered as security reliable. It's potentially exposed to hacking attacks due to explicit password publication in configs and we strongly recommend you not to use personal or corporate post accounts for SMTP writer. The best practice suggests dedicating an isolated post account especially for email notification service.

NOTE 2: The second example demonstrates the most sensible way to use this writer - notifications from the application on (rare) extraordinary situations. Technically, you can set other filter levels, yet get ready for being flooded with diagnostic emails.

Conn writer

Function: Writes received messages to a network connection.

Element name: conn

Allowed attributes:

  • formatid - format that will be used by this receiver
  • net - network ( "tcp", "udp", "tcp4", "udp4", ... )
  • addr - network address ( ":1000", "127.0.0.1:8888", ... )
  • reconnectonmsg - If true connection will be opened on each write otherwise on first write. Default - false.

Example:

<seelog type="sync">
	<outputs>
		<conn net="tcp" addr=":8888" />
	</outputs>
</seelog>