Three Important Steps for Log4cpp Programming
When you start working with log4cpp, you need to take care of the following steps
- Initializing an Appender
- Deciding on the Layout
- Finalize on the Category
Let’s see what each of these mean.
Appender: Appender in log4cpp corresponds to the destination of logs. A suitable appender is initialized based on your requirements. The destination of the logs can be a file, the standard output, the system log. log4cpp provides the additional support of rolling and backing up log files.
Layout: This is needed to decided on the format of the log. The log format may be something like the date, time, type of message followed by the message itself. log4cpp provides 2 layouts like the basic and simple layout. You can make a layout of your own
Category: Category decides on which message to be printed. You may have a lot of messages in your program. But you don’t want to print all the messages at all times. So you categorize messages into warnings, notices, errors, trace or information messages. Based on the category you have chosen, the messages will be printed
Take a sample look of all these steps in action in this simple log4cpp example.
Comments: