Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
metamod:logging [2010-06-30 09:21:33] oysteint Changed description of configuration. Added some about monitoring |
metamod:logging [2022-05-31 09:29:32] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Application logging ===== | + | ====== Application logging |
- | METAMOD logs events that happen in the system. The logging of these events can be used for IT operations and simplifying development. | + | METAMOD logs events that happen in the system. The logging of these events can be used for IT operations and for simplifying development. |
- | ==== Logging framework ==== | + | ===== Logging framework |
- | To provide scalable and standardised logging, METAMOD uses the Log:: | + | To provide scalable and standardised logging, METAMOD uses the Log:: |
It is important to understand how the log4p* frameworks work before you start using them. In particular it is important to understand how categories, levels and appenders work. This article gives a good introduction to the central concepts of the frameworks: http:// | It is important to understand how the log4p* frameworks work before you start using them. In particular it is important to understand how categories, levels and appenders work. This article gives a good introduction to the central concepts of the frameworks: http:// | ||
- | ==== Configuration | + | ===== Synopsis ===== |
- | Log:: | + | Perl: |
+ | |||
+ | <code perl> | ||
+ | #There are three possbilities for initialising the logger | ||
+ | |||
+ | # 1. Initialise it at compile time like this. This method assumes the use of the default master_config.txt file | ||
+ | use Metamod:: | ||
+ | |||
+ | # 2. Use the Metamod:: | ||
+ | use Metamod:: | ||
+ | my $config = Metamod:: | ||
+ | $config-> | ||
+ | |||
+ | # 3. Use the static class function | ||
+ | use Metamod:: | ||
+ | Metamod:: | ||
+ | |||
+ | #after initialisation | ||
+ | use Log:: | ||
+ | |||
+ | my $logger = get_logger($category); | ||
+ | $logger-> | ||
+ | </ | ||
+ | |||
+ | PHP: | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | # There are three possible ways to initialise the logger | ||
+ | |||
+ | # 1. Initialise the default config | ||
+ | require_once(" | ||
+ | |||
+ | $mmConfig-> | ||
+ | |||
+ | # 2. Initialise using a different config | ||
+ | require_once(" | ||
+ | $otherConfig = new MMConfig($path_to_other_config); | ||
+ | $otherConfig-> | ||
+ | |||
+ | # 3. Initialise using a static function that is basically option 2. reduced to one statement | ||
+ | require_once(" | ||
+ | $otherConfig = MMConfig:: | ||
+ | |||
+ | # after the logger is initialised you can do this | ||
+ | # Note that you don't need to include the log4php library as that has already been done | ||
+ | $logger = Logger:: | ||
+ | $logger-> | ||
+ | |||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | ===== Configuration ===== | ||
+ | |||
+ | Log:: | ||
The meta configuration contains lines that start with either log4all, log4php or log4perl. All lines starting with log4all will inserted in the configuration for both PHP and Perl. The log4php and log4perl lines will only be inserted into the configuration file for the respective framework. | The meta configuration contains lines that start with either log4all, log4php or log4perl. All lines starting with log4all will inserted in the configuration for both PHP and Perl. The log4php and log4perl lines will only be inserted into the configuration file for the respective framework. | ||
- | ==== Levels ==== | + | To make logging setup simple, METAMOD contains a default logging configuration that will be read by '' |
+ | |||
+ | See the documentation of '' | ||
+ | |||
+ | ==== Example additional configuration ==== | ||
+ | |||
+ | The following will log debug messages for the '' | ||
+ | |||
+ | log4perl.logger.metamod.search=DEBUG, | ||
+ | # prevent garbage from reaching the root logger | ||
+ | log4perl.additivity.metamod.search=0 | ||
+ | log4perl.appender.SEARCH_LOGGER=Log:: | ||
+ | log4perl.appender.SEARCH_LOGGER.filename = / | ||
+ | log4perl.appender.SEARCH_LOGGER.layout=Log:: | ||
+ | log4perl.appender.SEARCH_LOGGER.layout.ConversionPattern=%F on line: %L msg: %m%n | ||
+ | |||
+ | ==== Example screen appender ==== | ||
+ | |||
+ | The following configuration will send all log messages to the screen. | ||
+ | |||
+ | log4perl.rootLogger=DEBUG, | ||
+ | log4perl.appender.SCREEN=Log:: | ||
+ | log4perl.appender.SCREEN.stderr = 1 | ||
+ | log4perl.appender.SCREEN.layout=Log:: | ||
+ | log4perl.appender.SCREEN.layout.ConversionPattern=[%p] %c %m in %F at line %L%n | ||
+ | |||
+ | ===== Levels | ||
METAMOD uses the following log levels with the following definition. | METAMOD uses the following log levels with the following definition. | ||
Line 21: | Line 101: | ||
* FATAL: requires instant human assistance (IT operations). For instance full disks, lack of connection to database servers, file servers or LDAP. | * FATAL: requires instant human assistance (IT operations). For instance full disks, lack of connection to database servers, file servers or LDAP. | ||
* ERROR: serious error, but isolated to current task/ | * ERROR: serious error, but isolated to current task/ | ||
+ | * Exceptions, even if caught later | ||
* WARNING: Might be an error, but not necessarily. Should be looked at to see if it is an actual problem. | * WARNING: Might be an error, but not necessarily. Should be looked at to see if it is an actual problem. | ||
- | | + | * milder Exceptions, usually caught |
+ | | ||
+ | * tracking user | ||
+ | * log in | ||
+ | * log out | ||
+ | * generate/ | ||
+ | * tracking of data: | ||
+ | * uploads | ||
+ | * moving | ||
+ | * deletion | ||
+ | * tracking of metadata | ||
+ | * source (ncdigest, harvest), ownertag | ||
+ | * installing/ | ||
+ | * changes of xmd-metadata | ||
+ | * uploading to search-database(s) | ||
+ | * | ||
* DEBUG: Free to be used by the developers as they see fit during development. DEBUG logging should rarely be used in production. | * DEBUG: Free to be used by the developers as they see fit during development. DEBUG logging should rarely be used in production. | ||
- | ==== Categories ==== | + | ===== Categories |
METAMOD uses the following categories for log messages. The categories correspond with the main parts of the application. | METAMOD uses the following categories for log messages. The categories correspond with the main parts of the application. | ||
- | * Metamod | + | * metamod |
* search | * search | ||
* harvest | * harvest | ||
Line 38: | Line 134: | ||
* common | * common | ||
- | ==== Appenders ==== | + | In log4php each level in the logger hierarchy is separated using dots. Example: '' |
+ | |||
+ | In Log:: | ||
+ | |||
+ | ===== Appenders | ||
By default METAMOD uses two appenders. One for logging just FATAL and ERROR messages and one for logging all messages in the same file. | By default METAMOD uses two appenders. One for logging just FATAL and ERROR messages and one for logging all messages in the same file. | ||
- | ==== METAMOD configuration variables ==== | + | ===== METAMOD configuration variables |
The following configuration variables in the METAMOD configuration file is used to configure the logging. | The following configuration variables in the METAMOD configuration file is used to configure the logging. | ||
Line 49: | Line 149: | ||
* LOG4PERL_WATCH_TIME: | * LOG4PERL_WATCH_TIME: | ||
* LOG4PHP_CONFIG: | * LOG4PHP_CONFIG: | ||
+ | * LOG4ALL_SYSTEM_LOG: | ||
- | ==== Runtime configuration changes ==== | + | ===== Runtime configuration changes |
The configuration files will be watched for changes so it is possible to change the logging configuration at runtime without restarting the application. This is for instance useful for turning on debugging in a production system. | The configuration files will be watched for changes so it is possible to change the logging configuration at runtime without restarting the application. This is for instance useful for turning on debugging in a production system. | ||
- | ==== Monitoring ==== | + | ===== Monitoring |
The monitoring of logs is the responsibility of IT operations and is not implemented by METAMOD it self. | The monitoring of logs is the responsibility of IT operations and is not implemented by METAMOD it self. |