C++跨平臺日志庫:log4z
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]:
- MIT open source license,very liberal.
MIT開源授權 無限制使用. - lightweight and cross platform.
輕量級, 跨平臺 可在linux與windows上共同使用. - complete priority level control.
完整的日志優先級控制. - multi log output, thread safe.
多日志分流 線程安全.
- complete file's configure.
可通過配置文件全程配置.
- 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]