Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1771950
  • 博文数量: 184
  • 博客积分: 10122
  • 博客等级: 上将
  • 技术积分: 5566
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-08 12:32
文章存档

2011年(1)

2008年(183)

我的朋友

分类: LINUX

2008-03-03 21:31:40

3.2. Defining global objects

Global objects are defined in the syslog-ng configuration file. Object definitions consist of the following elements:

# 注释 :全局对象是在 syslog-ng 配置文件中定义的。对象定义由4部分组成 :

#     -)1、类型 :可选的值有 source、destination、log、filter、template

#     -)2、名称 :对象的名称。如果名称刚好是某个保留字,则必须用 " " 括起来。建议对象的名称以它们的类型开头,例如 s_ , d_ 。

#     -)3、参数。多个参数由 { } 括起来。

#     -)4、分号。分号用于结束一个对象的定义

  • Type of the object: One of source, destination, log, filter, or template.

  • Identifier of the object: A unique name identifying the object. When using a reserved word as an identifier, enclose the identifier in quotation marks.

    [Tip] Tip

    Use identifiers that refer to the type of the object they identify. For example, prefix source objects with s_, destinations with d_, and so on.

  • Parameters: The parameters of the object, enclosed in braces {parameters}.

  • Semicolon: Object definitions end with a semicolon (;).

The syntax is summarized as follows:

# 注释 :总的来说,格式如下 :

type identifier { parameters };

Objects have parameters; some of them are required, others are optional. Required parameters are positional, meaning that they must be specified in a defined order. Optional arguments can be specified in any order using the option(value) format. If a parameter (optional or required) is not specified, its default value is used. The parameters and their default values are listed in the reference section of the particular object. See for details.

# 注释 :对于一个对象来说,某些参数是必须的,某些则是可选的。必选的参数是有顺序要求的,也就是说它们必须按一定的顺序定义。

# 可选的参数则可以按任意的顺序定义。它们的格式是 option(value) 。如果某个选项(不管是必须还是可选的)没有明确定义,则使用默认值。

[Example] Example 3.1. Using required and optional parameters

The unix-stream() source driver has a single required argument: the name of the socket to listen on. Optional parameters follow the socket name in any order, so the following source definitions have the same effect:

# 注释 :例如下面就是一个对象的定义。其中 unix-stream 就是一个参数。

source s_demo_stream1 { 
unix-stream("/dev/log" max-connections(10) group(log)); };
source s_demo_stream2 {
unix-stream("/dev/log" group(log) max-connections(10)); };

To add comments to the configuration file, start a line with # and write your comments. These lines are ignored by syslog-ng.

# 注释 :要在配置文件中增加注释,使用 # 开头的行。

# Comment: This is a stream source
source s_demo_stream {
unix-stream("/dev/log" max-connections(10) group(log)); };

阅读(805) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~