LogsConfig

From Request Tracker Wiki
Jump to navigation Jump to search

Introduction

This page is about logging various information in log files and streams.

Logging in RT

Logging in RT is controlled from SiteConfig file with several LogXxx options, such as:

Set($LogToSyslog    , 'info');
Set($LogToScreen    , 'info');

Set($LogToFile , 'debug'); #debug is very noisy
Set($LogDir, '/var/log/request-tracker3.8');
Set($LogToFileNamed , "rt.log");    #log to rt.log

Available log levels

Here is the list of available log levels:

  • debug
  • info
  • notice
  • warning
  • error
  • critical
  • alert
  • emergency

RT almost doesn't use the alert and emergency levels, so critical is the highest. The debug log level is very noisy.

Available logging streams

In RT you can log to syslog, screen (console/server's log) and into a file.

In production environment it's recommended to log to screen and/or syslog.

Logging into syslog

This way is recommended in production environment, but don't turn off logging to screen completly.

Set($LogToSyslog, "warning");

You can tune logging into syslog with @LogToSyslogConf option. Here a few examples:

Change ident ('RT' by default):

 Set(@LogToSyslogConf, ident => 'RTTEST');

Connect to remote syslog (requires Sys::Syslog 0.28 or newer):

 Set(@LogToSyslogConf, socket => [{type => 'udp', host => 'logger.example.com', port => 12345 }]);

Details about socket option you can read in the module's documentation. Just put what the page describes in the following template:

 Set(@LogToSyslogConf, socket => [... setlogsock options here ...]);

Change facility:

 Set(@LogToSyslogConf, facility => 'local0');

All combined:

 Set(@LogToSyslogConf,
     ident => 'RTTEST',
     facility => 'local0',
     socket => [{type => 'udp', host => 'logger.example.com', port => 12345 }],
 );

Logging to screen (console/server's log)

Log messages can be logged to screen (STDERR). When we talk about the web UI these messages usually end up in server's log (at least for apache) and for command utilities it's console.

Don't disable this type of logging completly. Some command line scripts may fail silently if this type of logging is disabled as they log errors instead of printing them directly.

Set($LogToScreen, "warning");

Logging into standalone file

This is useful on development setup. Don't use in production, especially if people run command line scripts on the server as those scripts would fail unable to open the log.

Set($LogToFile,      'debug');
Set($LogToFileNamed, 'rt.log');
Set($LogDir,         '/opt/rt3/var/log');

In shell

touch /opt/rt3/var/log/rt.log
chown apache:apache /opt/rt3/var/log/rt.log

Additional logging options

Log SQL queries

StatementLog option allows you to log all SQL queries RT runs per request to the server. Yes, it only works with web UI.

Set( $StatementLog, 'debug' ); # statements would be logged at debug level

See also "Logging in MySQL" below for alternatives.

Log stack traces

It's possible to add stack traces to messages that are logged. Useful to report errors and for figuring out chain of calls that caused a problem.

# add stack traces to error messages and messages with higher priority
Set($LogStackTraces, 'error');

Logging in MySQL

It's not complete documentation on logging in MySQL, but most useful things for RT admin.

Logging slow queries

This is useful to debug perfomance issues.

In MySQL conf (usually /etc/my.cnf)

[mysqld]
log-slow-queries=/var/log/mysql_slow.log
long_query_time=1 # time in seconds

NOTE: MySQL perfomance is OK when 2-seconds log is empty.

RT itself can log SQL queries with timings. It only works in the web UI and logs all queries, but time reported has higher resolution. Look at StatementLog above.

Logging all queries

This is useful when RT generates wrong queries. This is useful when you expect some results shown, but RT skips data.

Edit MySQL conf (usually /etc/my.cnf)

[mysqld]
log=/var/log/mysql_full.log

Then in shell

touch /var/log/mysql_full.log
chown mysql:mysql /var/log/mysql_full.log

Restart MySQL

A request to the server usually starts from string: SELECT GET_LOCK('Apache-Session-...', ...) Ends with SELECT RELEASE_LOCK('Apache-Session-...')

Note: Don't turn on on production servers for long time.

For full info see 'Logging' section in SiteConfig