C++跨平台日志库:log4z

jopen 11年前

log4z是一款开源的轻量级的跨平台日志库 主要针对7*24小时服务器程序的日志输出与跟踪调试, 支持64/32位的debian, redhat, centos, suse, windows等多操作系统.


log4z 提供多日志分流机制, 用户可通过配置文件或者在程序中动态创建的方式生成多个日志器进行不同的日志输出工作. [log4z provide multiple log triage mechanism, the user can configure the file or created dynamically in the program means for generating a plurality of different logger log output work]

例如 在一个完整的后端服务中, 可以创建一个日志器进行打印DB操作产生的警告与错误日志, 然后再创建一个日志器进行打印网络底层可能产生的网络错误信息, 而逻辑部分则使用log4z默认的主日志器进行打印输出, 并且他们都是线程安全的.[For example, in a complete back-end service, you can create a logger for printing DB operation generated warnings and error logs, and then create a logger for printing network infrastructure network may produce an error message, and the logical part of the default using log4z master logger for print output, and they are thread-safe.]

log4z的所有日志器都可以通过配置文件进行初始化设定或者通过SetXXX接口进行动态更改其属性, 这些属性包括日志器的文件名, 日志过滤等级, 屏幕输出控制等, 每个日志器对应一个日志输出文件, 每个文件每天自动更换一次 每月更换一次目录.[log4z all logger can be set via the configuration file to initialize or through SetXXX interface to dynamically change its properties, which include the log's file name, log filter level, the screen output control, etc., each corresponding to a logger log output files, each file automatically replaced once a day once a month replacement directory.]

log4z另外一个优秀的地方则是根据日志的等级不同予以不同的颜色展示, 日志级别越高 则颜色越醒目, 因此可以在调试程序时候非常舒适的找到警告或者错误日志.[Log4z is another good place is according to different log level to different colors, higher log level more eye-catching color, so it can be in the debugger when very comfortable to find a warning or error log.]

这些特性整理成条目大致如下[These feature into entry is as follows]:

  1. MIT open source license,very liberal.
    MIT开源授权 无限制使用.
  2. lightweight and cross platform.
    轻量级, 跨平台 可在linux与windows上共同使用.
  3. complete priority level control.
    完整的日志优先级控制.
  4. multi log output, thread safe.
    多日志分流 线程安全.
  5. complete file's configure.
    可通过配置文件全程配置.
  6. display to screen with different color.
    屏幕日志为彩色输出, 信息简约整洁.

The log output file

日志文件的输出可以通过配置文件或者在程序启动时进行灵活的配置[The output log file through a configuration file or when the program starts a flexible configuration]

项目主页:http://www.open-open.com/lib/view/home/1376463462834