Types of log appender
An appender specifies where your log messages are written to. There is a wide choice of appenders available. All appenders are direct or indirect subclasses of the AppenderSkeleton. Therefore we can find all options on the following API page:
The console and the file appender are a subclass of WriterAppender.
Later on, we are going to choose examples for the following appenders.
|ConsoleAppender||Logs to console|
|FileAppender||Logs to a file|
|SMTPAppender||Logs by email|
|RollingFileAppender||Logs to a file, starts a new file once the max size is reached. (An alternative is the DailyRollingFileAppender which creates on file per day)|
But there are as well:
AsyncAppender, JDBCAppender, JMSAppender, LF5Appender, NTEventLogAppender, NullAppender, NullAppender, SMTPAppender, SocketAppender, SocketHubAppender, SyslogAppender, TelnetAppender, DailyRollingFileAppender, RollingFileAppender.
Custom appenders can be created as well. The log4j download comes with a whole bunch of samples in the examples directory.
For more information on log4j, visit the source below.