https://rt-wiki.bestpractical.com/index.php?title=LogsConfig&feed=atom&action=historyLogsConfig - Revision history2024-03-29T06:13:56ZRevision history for this page on the wikiMediaWiki 1.37.2https://rt-wiki.bestpractical.com/index.php?title=LogsConfig&diff=1876&oldid=prevAdmin: 9 revisions imported2016-04-06T20:14:19Z<p>9 revisions imported</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 16:14, 6 April 2016</td>
</tr>
<!-- diff cache key bestpractical_mediawiki1459887241:diff::1.12:old-1875:rev-1876 -->
</table>Adminhttps://rt-wiki.bestpractical.com/index.php?title=LogsConfig&diff=1875&oldid=prev128.82.44.7: Corrected some grammatical errors.2014-02-24T18:53:36Z<p>Corrected some grammatical errors.</p>
<p><b>New page</b></p><div>= Introduction =<br />
<br />
This page is about logging various information in log files and streams.<br />
<br />
= Logging in RT =<br />
<br />
Logging in RT is controlled from [[SiteConfig]] file with several LogXxx options, such as:<br />
<br />
<pre><br />
Set($LogToSyslog , 'info');<br />
Set($LogToScreen , 'info');<br />
<br />
Set($LogToFile , 'debug'); #debug is very noisy<br />
Set($LogDir, '/var/log/request-tracker3.8');<br />
Set($LogToFileNamed , "rt.log"); #log to rt.log<br />
</pre><br />
<br />
== Available log levels ==<br />
<br />
Here is the list of available log levels:<br />
<br />
* debug<br />
* info<br />
* notice<br />
* warning<br />
* error<br />
* critical<br />
* alert<br />
* emergency<br />
<br />
RT almost doesn't use the alert and emergency levels, so critical is the highest. The debug log level is very noisy.<br />
<br />
== Available logging streams ==<br />
<br />
In RT you can log to syslog, screen (console/server's log) and into a file.<br />
<br />
In production environment it's recommended to log to screen and/or syslog.<br />
<br />
=== Logging into syslog ===<br />
<br />
This way is recommended in production environment, but don't turn off logging to screen completly.<br />
<br />
Set($LogToSyslog, "warning");<br />
<br />
You can tune logging into syslog with @LogToSyslogConf option. Here a few examples:<br />
<br />
Change ident ('RT' by default):<br />
<br />
Set(@LogToSyslogConf, ident => 'RTTEST');<br />
<br />
Connect to remote syslog (requires Sys::Syslog 0.28 or newer):<br />
<br />
Set(@LogToSyslogConf, socket => [{type => 'udp', host => 'logger.example.com', port => 12345 }]);<br />
<br />
Details about socket option you can read<br />
[http://search.cpan.org/dist/Sys-Syslog/Syslog.pm#setlogsock in the module's documentation].<br />
Just put what the page describes in the following template:<br />
<br />
Set(@LogToSyslogConf, socket => [... setlogsock options here ...]);<br />
<br />
Change facility:<br />
<br />
Set(@LogToSyslogConf, facility => 'local0');<br />
<br />
All combined:<br />
<br />
Set(@LogToSyslogConf,<br />
ident => 'RTTEST',<br />
facility => 'local0',<br />
socket => [{type => 'udp', host => 'logger.example.com', port => 12345 }],<br />
);<br />
<br />
=== Logging to screen (console/server's log) ===<br />
<br />
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.<br />
<br />
'''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.<br />
<br />
Set($LogToScreen, "warning");<br />
<br />
=== Logging into standalone file ===<br />
<br />
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.<br />
<br />
<pre><br />
Set($LogToFile, 'debug');<br />
Set($LogToFileNamed, 'rt.log');<br />
Set($LogDir, '/opt/rt3/var/log');<br />
</pre><br />
<br />
In shell<br />
<br />
touch /opt/rt3/var/log/rt.log<br />
chown apache:apache /opt/rt3/var/log/rt.log<br />
<br />
== Additional logging options ==<br />
<br />
=== Log SQL queries ===<br />
<br />
StatementLog option allows you to log all SQL queries RT runs per request to the server. Yes, it only works with web UI.<br />
<br />
Set( $StatementLog, 'debug' ); # statements would be logged at debug level<br />
<br />
See also "Logging in MySQL" below for alternatives.<br />
<br />
=== Log stack traces ===<br />
<br />
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.<br />
<br />
# add stack traces to error messages and messages with higher priority<br />
Set($LogStackTraces, 'error');<br />
<br />
= Logging in MySQL =<br />
<br />
It's not complete documentation on logging in MySQL, but most useful things for RT admin.<br />
<br />
== Logging slow queries ==<br />
<br />
This is useful to debug perfomance issues.<br />
<br />
In MySQL conf (usually /etc/my.cnf)<br />
<br />
[mysqld]<br />
log-slow-queries=/var/log/mysql_slow.log<br />
long_query_time=1 # time in seconds<br />
<br />
'''NOTE:''' MySQL perfomance is OK when 2-seconds log is empty.<br />
<br />
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.<br />
<br />
== Logging all queries ==<br />
<br />
This is useful when RT generates wrong queries. This is useful when you expect some results shown, but RT skips data.<br />
<br />
Edit MySQL conf (usually /etc/my.cnf)<br />
<br />
[mysqld]<br />
log=/var/log/mysql_full.log<br />
<br />
Then in shell<br />
<br />
touch /var/log/mysql_full.log<br />
chown mysql:mysql /var/log/mysql_full.log<br />
<br />
Restart MySQL<br />
<br />
A request to the server usually starts from string: <code>SELECT GET_LOCK('Apache-Session-...', ...)</code> Ends with <code>SELECT RELEASE_LOCK('Apache-Session-...')</code><br />
<br />
'''Note:''' Don't turn on on production servers for long time.<br />
<br />
For full info see 'Logging' section in [[SiteConfig]]<br />
[[Category:documentation]]<br />
[[Category:config]]<br />
[[Category:logging]]</div>128.82.44.7